Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. #SingleInstance force
  2.  
  3. ;autor: Fragoon aka Summoner, LunatiX (Piotr Bugaj)
  4. ;------------Edit to change Joy Number ( 0 = Auto Detect) ---------------
  5. JoyNo = -1
  6. JoyNo2 = 0
  7.  
  8. ;------------------------------------------------------------------------
  9.  
  10. ;--- Constants Depend on USB Adapter, Calibration ---
  11. J1None = 49.609
  12. J1Both = 49.999
  13. J2None = 49.609
  14. J2Both = 49.999
  15.  
  16. ;------------------------------------------------------------------------
  17.  
  18. #Persistent
  19.  
  20. ;Run, StepMania, ,
  21.  
  22. SetFormat, float, 2.3
  23. SetKeyDelay -1
  24.  
  25.  
  26. SetTimer, Detect
  27. SetTimer, WatchKeys, 1
  28. SetTimer, WatchKeys_2, 1
  29. ;SetTimer, GameCheck, 10000
  30.  
  31. Detect: ;---------------------------------------------------------------------------
  32.  
  33. if JoyNo <= -1
  34. {
  35. Loop 4
  36. {
  37. GetKeyState, JoyName, %A_Index%JoyName
  38. if JoyName <>
  39. {
  40. if JoyNo <= -1
  41. {
  42. JoyNo = %A_Index%
  43. ;MsgBox JoyNo %JoyNo%
  44. }
  45. else
  46. {
  47. JoyNo2 = %A_Index%
  48. ;MsgBox JoyNo2 %JoyNo2%
  49. break
  50. }
  51. }
  52.  
  53. }
  54. if JoyNo <= -1
  55. {
  56. MsgBox No joysticks detected
  57. ExitApp
  58. }
  59.  
  60. TrayTip, Joystick Detected, %JoyName% `nJoyNo: %JoyNo% `nJoy2No: %JoyNo2% , 3
  61.  
  62. }
  63.  
  64. SetTimer, Detect, Off
  65.  
  66. return
  67.  
  68. WatchKeys: ;-----------------------------------------------------------------------
  69.  
  70. GetKeyState, joyx, %JoyNo%JoyX
  71. GetKeyState, joyy, %JoyNo%JoyY
  72. ;ToolTip, %JoyNo% `n %joyx% `n %joyy% 'n
  73.  
  74. ;axis x
  75.  
  76. if joyxP != %joyx%
  77. {
  78. if joyx >= 0
  79. {
  80.  
  81.  
  82. if joyx<%J1None%
  83. {
  84. SR =
  85. SL = 1
  86. Send, {Right up}
  87. }
  88.  
  89. if joyx>%J1Both%
  90. {
  91. SR = 1
  92. SL =
  93. Send, {Left up}
  94. }
  95.  
  96. if joyx=%J1Both%
  97. {
  98. SR = 1
  99. SL = 1
  100. }
  101.  
  102. if joyx=%J1None%
  103. {
  104. SR =
  105. SL =
  106. Send, {Right up}
  107. Send, {Left up}
  108. }
  109. }
  110. }
  111.  
  112. ;axis y
  113.  
  114. if joyyP != %joyy%
  115. {
  116.  
  117. if joyy >= 0
  118. {
  119.  
  120. if joyy<%J1None%
  121. {
  122. SD =
  123. SU = 1
  124. Send, {Down up}
  125. }
  126.  
  127. if joyy>%J1Both%
  128. {
  129. SD = 1
  130. SU =
  131. Send, {Up up}
  132. }
  133.  
  134. if joyy=%J1Both%
  135. {
  136. SD = 1
  137. SU = 1
  138. }
  139.  
  140. if joyy=%J1None%
  141. {
  142. SD =
  143. SU =
  144. Send, {Down up}
  145. Send, {Up up}
  146. }
  147. }
  148.  
  149. }
  150.  
  151. joyxP = %joyx%
  152. joyyP = %joyy%
  153.  
  154. if SR
  155. Send, {Right down}
  156. if SL
  157. Send, {Left down}
  158. if SD
  159. Send, {Down down}
  160. if SU
  161. Send, {Up down}
  162.  
  163.  
  164.  
  165. return
  166.  
  167. WatchKeys_2: ;-----------------------------------------------------------------------
  168.  
  169. GetKeyState, joy2x, %JoyNo2%JoyX
  170. GetKeyState, joy2y, %JoyNo2%JoyY
  171. ;ToolTip, %JoyNo2% `n %joy2x% `n %joy2y%
  172.  
  173. ;axis x
  174.  
  175. if joy2xP != %joy2x%
  176. {
  177. if joy2x >= 0
  178. {
  179. if joy2x<%J2None%
  180. {
  181. SR2 =
  182. SL2 = 1
  183. Send, {d up}
  184. }
  185.  
  186. if joy2x>%J2Both%
  187. {
  188. SR2 = 1
  189. SL2 =
  190. Send, {a up}
  191. }
  192.  
  193. if joy2x=%J2Both%
  194. {
  195. SR2 = 1
  196. SL2 = 1
  197. }
  198.  
  199. if joy2x=%J2None%
  200. {
  201. SR2 =
  202. SL2 =
  203. Send, {d up}
  204. Send, {a up}
  205. }
  206. }
  207. }
  208.  
  209. ;axis y
  210.  
  211. if joy2yP != %joy2y%
  212. {
  213.  
  214. if joy2y >= 0
  215. {
  216.  
  217. if joy2y<%J2None%
  218. {
  219. SD2 =
  220. SU2 = 1
  221. Send, {s up}
  222. }
  223.  
  224. if joy2y>%J2Both%
  225. {
  226. SD2 = 1
  227. SU2 =
  228. Send, {w up}
  229. }
  230.  
  231. if joy2y=%J2Both%
  232. {
  233. SD2 = 1
  234. SU2 = 1
  235. }
  236.  
  237. if joy2y=%J2None%
  238. {
  239. SD2 =
  240. SU2 =
  241. Send, {s up}
  242. Send, {w up}
  243. }
  244. }
  245.  
  246. }
  247.  
  248. joy2xP = %joy2x%
  249. joy2yP = %joy2y%
  250.  
  251. if SR2
  252. Send, {d down}
  253. if SL2
  254. Send, {a down}
  255. if SD2
  256. Send, {s down}
  257. if SU2
  258. Send, {w down}
  259.  
  260. return
  261.  
  262. ;GameCheck: ;------------------------------------------------------------------------
  263.  
  264. ;IfWinNotExist, StepMania
  265. ; {
  266. ; IfWinNotExist, ahk_class SDL_app
  267. ; ExitApp
  268. ; }
  269.  
  270. ;return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement