Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. #Persistent ; Keep this script running until the user explicitly exits it.
  2. CurrentState = 0
  3. SetTimer, WatchPOV, 5
  4. return
  5.  
  6. WatchPOV:
  7. GetKeyState, POV, JoyPOV ; Get position of the POV control.
  8. KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any).
  9. GetKeyState, JoyZ, JoyZ ; Get position of Z axis.
  10. Move1Prev = %Move1%
  11. Move2Prev = %Move2%
  12.  
  13. ; Some joysticks might have a smooth/continous POV rather than one in fixed increments.
  14. ; To support them all, use a range:
  15.  
  16. ToolTip %POV%
  17.  
  18. if POV < 0 ; no angle
  19. {
  20. Move1 =
  21. Move2 =
  22. }
  23. else if POV > 32500
  24. {
  25. Move1 = w
  26. Move2 =
  27. }
  28. else if POV < 4000
  29. {
  30. Move1 = w
  31. Move2 =
  32. }
  33. else if POV < 8000
  34. {
  35. Move1 = w
  36. Move2 = d
  37. }
  38. else if POV < 12500
  39. {
  40. Move1 =
  41. Move2 = d
  42. }
  43. else if POV < 17000
  44. {
  45. Move1 = s
  46. Move2 = d
  47. }
  48. else if POV < 22000
  49. {
  50. Move1 = s
  51. Move2 =
  52. }
  53. else if POV < 26000
  54. {
  55. Move1 = s
  56. Move2 = a
  57. }
  58. else if POV < 30500
  59. {
  60. Move1 =
  61. Move2 = a
  62. }
  63. else if POV > 28000
  64. {
  65. Move1 = w
  66. Move2 = a
  67. }
  68.  
  69. ;if POV < 0 ; No angle to report
  70. ; KeyToHoldDown =
  71. ;else if POV > 31500 ; 315 to 360 degrees: Forward
  72. ; KeyToHoldDown = w
  73. ;else if POV between 0 and 4500 ; 0 to 45 degrees: Forward
  74. ; KeyToHoldDown = w
  75. ;else if POV between 4501 and 13500 ; 45 to 135 degrees: Right
  76. ; KeyToHoldDown = d
  77. ;else if POV between 13501 and 22500 ; 135 to 225 degrees: Down
  78. ; KeyToHoldDown = s
  79. ;else ; 225 to 315 degrees: Left
  80. ; KeyToHoldDown = a
  81.  
  82. if JoyZ < 40 OR JoyZ > 55
  83. Send {Shift}
  84.  
  85. SetKeyDelay -1
  86.  
  87. CurrentState = 0
  88.  
  89. if Move1 = %Move1Prev%
  90. {
  91. ;do nothing
  92. }
  93. else
  94. {
  95. if Move1Prev
  96. {
  97. Send, {%Move1Prev% up}
  98. }
  99.  
  100. if Move1
  101. {
  102. Send, {%Move1% down}
  103. CurrentState = %CurrentState% | 1
  104. }
  105. }
  106.  
  107. if Move2 = %Move2Prev%
  108. {
  109. ;do nothing
  110. }
  111. else
  112. {
  113. if Move2Prev
  114. {
  115. Send, {%Move2Prev% up}
  116. }
  117.  
  118. if Move2
  119. {
  120. Send, {%Move2% down}
  121. CurrentState = %CurrentState% | 2
  122. }
  123. }
  124.  
  125. ;if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down (or no key is needed).
  126. ; return ; Do nothing.
  127.  
  128. ; Otherwise, release the previous key and press down the new key:
  129.  
  130. ;SetKeyDelay -1 ; Avoid delays between keystrokes.
  131. ;if KeyToHoldDownPrev ; There is a previous key to release.
  132. ;{
  133. ; Send, {%KeyToHoldDownPrev% up} ; Release it.
  134. ; CurrentState = 0
  135. ;}
  136. ;
  137. ;if KeyToHoldDown ; There is a key to press down.
  138. ;{
  139. ; Send, {%KeyToHoldDown% down} ; Press it down.
  140. ; CurrentState = 1
  141. ;}
  142.  
  143. return
  144.  
  145. Joy4::
  146. moveData =
  147. moveData2 =
  148. if CurrentState > 0
  149. {
  150. if CurrentState & 1 > 0
  151. {
  152. moveData = %moveData%{%Move1% down}
  153. moveData2 = %moveData2%{%Move1% up}
  154. Send {%Move1% up}
  155. }
  156. if CurrentState & 2 > 0
  157. {
  158. moveData = %moveData%{%Move2% down}
  159. moveData2 = %moveData2%{%Move2% up}
  160. Send {%Move2% up}
  161. }
  162. sleep 10
  163. }
  164.  
  165. Send {shift}
  166. sleep 10
  167. Send %moveData%{x}%moveData2%
  168.  
  169. if CurrentState > 0
  170. {
  171. if CurrentState & 1 > 0
  172. {
  173. Send {%Move1% down}
  174. }
  175. if CurrentState & 2 > 0
  176. {
  177. Send {%Move2% down}
  178. }
  179. }
  180.  
  181. Joy1:: Send {space}
  182. Joy2:: Send {x}
  183. Joy3:: Send {c}
  184. Joy5:: Send {v}
  185. Joy6:: Send {v}
  186.  
  187.  
  188. Joy10:: ;stick rechts
  189. Send {shift}
  190. sleep 100
  191. Send {up down}{x}{up up}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement