Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.21 KB | None | 0 0
  1. #Persistent
  2. #include xinput.ahk
  3.  
  4. SetKeyDelay 100
  5.  
  6. LT_Key = Null
  7. RT_Key = Null
  8.  
  9. LastRT := LastLT :=
  10.  
  11. XInput_Init()
  12. Loop {
  13. Loop, 4 {
  14. if State := XInput_GetState(A_Index-1) {
  15. LT := State.bLeftTrigger
  16. RT := State.bRightTrigger
  17. if (LT != LastLT) {
  18. Send % "{" . LT_Key . (LT ? " Down}" : " Up}")
  19. LastLT := LT
  20. }
  21. if (RT != LastRT) {
  22. Send % "{" . RT_Key . (RT ? " Down}" : " Up}")
  23. LastRT := RT
  24. }
  25. }
  26. }
  27. Sleep, 100
  28. }
  29.  
  30. Joy1:: ; Button "A"
  31. if (LT >= 1 and RT >= 1) ; Both triggers are held
  32. 1VAR = b
  33. if (LT < 1 and RT < 1) ; No triggers are held
  34. 1VAR = Enter
  35. if (LT >= 1 and RT < 1) ; Left trigger is held
  36. 1VAR = null
  37. if (LT < 1 and RT > 1) ; Right trigger is held
  38. 1VAR = null
  39. Send {%1VAR% down}
  40. SetTimer, WaitForButtonUpA, 30
  41. return
  42.  
  43. WaitForButtonUpA:
  44. if not GetKeyState("Joy1")
  45. {
  46. Send {%1VAR% up}
  47. SetTimer, WaitForButtonUpA, off
  48. return
  49. }
  50. Send {%1VAR% down}
  51. return
  52.  
  53. Joy2:: ; Button "B"
  54. if (LT >= 1 and RT >= 1) ; Both triggers are held
  55. 2VAR = f
  56. if (LT < 1 and RT < 1) ; No triggers are held
  57. 2VAR = Esc
  58. if (LT >= 1 and RT < 1) ; Left trigger is held
  59. 2VAR = null
  60. if (LT < 1 and RT > 1) ; Right trigger is held
  61. 2VAR = null
  62. Send {%2VAR% down}
  63. SetTimer, WaitForButtonUpB, 30
  64. return
  65.  
  66. WaitForButtonUpB:
  67. if not GetKeyState("Joy2")
  68. {
  69. Send {%2VAR% up}
  70. SetTimer, WaitForButtonUpB, off
  71. return
  72. }
  73. Send {%2VAR% down}
  74. return
  75.  
  76. Joy3:: ; Button "X"
  77. if (LT >= 1 and RT >= 1) ; Both triggers are held
  78. {
  79. Send {LShift down}{d down}{LShift up}
  80. SetTimer, WaitForButtonUpXd, 30
  81. return
  82.  
  83. WaitForButtonUpXd:
  84. if not GetKeyState("Joy3")
  85. {
  86. Send {d up}
  87. SetTimer, WaitForButtonUpXd, off
  88. return
  89. }
  90. Send {LShift down}{d down}{LShift up}
  91. return
  92. }
  93. if (LT < 1 and RT < 1) ; No triggers are held
  94. 3VAR = Space
  95. if (LT >= 1 and RT < 1) ; Left trigger is held
  96. 3VAR = null
  97. if (LT < 1 and RT > 1) ; Right trigger is held
  98. 3VAR = null
  99. Send {%3VAR% down}
  100. SetTimer, WaitForButtonUpX, 30
  101. return
  102.  
  103. WaitForButtonUpX:
  104. if not GetKeyState("Joy3")
  105. {
  106. Send {%3VAR% up}
  107. SetTimer, WaitForButtonUpX, off
  108. return
  109. }
  110. Send {%3VAR% down}
  111. return
  112.  
  113. Joy4:: ; Button "Y"
  114. if (LT >= 1 and RT >= 1) ; Both triggers are held
  115. 4VAR = v
  116. if (LT < 1 and RT < 1) ; No triggers are held
  117. 4VAR = NumpadMult
  118. if (LT >= 1 and RT < 1) ; Left trigger is held
  119. 4VAR = null
  120. if (LT < 1 and RT > 1) ; Right trigger is held
  121. 4VAR = l
  122. Send {%4VAR% down}
  123. SetTimer, WaitForButtonUpY, 30
  124. return
  125.  
  126. WaitForButtonUpY:
  127. if not GetKeyState("Joy4")
  128. {
  129. Send {%4VAR% up}
  130. SetTimer, WaitForButtonUpY, off
  131. return
  132. }
  133. Send {%4VAR% down}
  134. return
  135.  
  136. Joy5:: ; Button "LB"
  137. if (LT >= 1 and RT >= 1) ; Both triggers are held
  138. {
  139. Send {LShift down}{w down}{LShift up}
  140. SetTimer, WaitForButtonUpYw, 30
  141. return
  142.  
  143. WaitForButtonUpYw:
  144. if not GetKeyState("Joy5")
  145. {
  146. Send {w up}
  147. SetTimer, WaitForButtonUpYw, off
  148. return
  149. }
  150. Send {LShift down}{w down}{LShift up}
  151. return
  152. }
  153. if (LT < 1 and RT < 1) ; No triggers are held
  154. 5VAR = NumpadHome
  155. if (LT >= 1 and RT < 1) ; Left trigger is held
  156. 5VAR = null
  157. if (LT < 1 and RT > 1) ; Right trigger is held
  158. 5VAR = null
  159. Send {%5VAR% down}
  160. SetTimer, WaitForButtonUpLB, 30
  161. return
  162.  
  163. WaitForButtonUpLB:
  164. if not GetKeyState("Joy5")
  165. {
  166. Send {%5VAR% up}
  167. SetTimer, WaitForButtonUpLB, off
  168. return
  169. }
  170. Send {%5VAR% down}
  171. return
  172.  
  173. Joy6:: ; Button "RB"
  174. if (LT >= 1 and RT >= 1) ; Both triggers are held
  175. 6VAR = a
  176. if (LT < 1 and RT < 1) ; No triggers are held
  177. 6VAR = NumpadPgUp
  178. if (LT >= 1 and RT < 1) ; Left trigger is held
  179. 6VAR = null
  180. if (LT < 1 and RT > 1) ; Right trigger is held
  181. 6VAR = null
  182. Send {%6VAR% down}
  183. SetTimer, WaitForButtonUpRB, 30
  184. return
  185.  
  186. WaitForButtonUpRB:
  187. if not GetKeyState("Joy6")
  188. {
  189. Send {%6VAR% up}
  190. SetTimer, WaitForButtonUpRB, off
  191. return
  192. }
  193. Send {%6VAR% down}
  194. return
  195.  
  196. Joy7:: ; Button "BACK"
  197. if (LT >= 1 and RT >= 1) ; Both triggers are held
  198. 7VAR = null
  199. if (LT < 1 and RT < 1) ; No triggers are held
  200. 7VAR = /
  201. if (LT >= 1 and RT < 1) ; Left trigger is held
  202. 7VAR = null
  203. if (LT < 1 and RT > 1) ; Right trigger is held
  204. 7VAR = null
  205. Send {%7VAR% down}
  206. SetTimer, WaitForButtonUpBACK, 30
  207. return
  208.  
  209. WaitForButtonUpBACK:
  210. if not GetKeyState("Joy7")
  211. {
  212. Send {%7VAR% up}
  213. SetTimer, WaitForButtonUpBACK, off
  214. return
  215. }
  216. Send {%7VAR% down}
  217. return
  218.  
  219. Joy8:: ; Button "START"
  220. if (LT >= 1 and RT >= 1) ; Both triggers are held
  221. 8VAR = ?
  222. if (LT < 1 and RT < 1) ; No triggers are held
  223. 8VAR = j
  224. if (LT >= 1 and RT < 1) ; Left trigger is held
  225. 8VAR = null
  226. if (LT < 1 and RT > 1) ; Right trigger is held
  227. 8VAR = null
  228. Send {%8VAR% down}
  229. SetTimer, WaitForButtonUpSTART, 30
  230. return
  231.  
  232. WaitForButtonUpSTART:
  233. if not GetKeyState("Joy8")
  234. {
  235. Send {%8VAR% up}
  236. SetTimer, WaitForButtonUpSTART, off
  237. return
  238. }
  239. Send {%8VAR% down}
  240. return
  241.  
  242. Joy9:: ; Button "Left Joystick push"
  243. if (LT >= 1 and RT >= 1) ; Both triggers are held
  244. 9VAR = null
  245. if (LT < 1 and RT < 1) ; No triggers are held
  246. 9VAR = NumpadClear
  247. if (LT >= 1 and RT < 1) ; Left trigger is held
  248. 9VAR = null
  249. if (LT < 1 and RT > 1) ; Right trigger is held
  250. 9VAR = null
  251. Send {%9VAR% down}
  252. SetTimer, WaitForButtonUpLJP, 30
  253. return
  254.  
  255. WaitForButtonUpLJP:
  256. if not GetKeyState("Joy9")
  257. {
  258. Send {%9VAR% up}
  259. SetTimer, WaitForButtonUpLJP, off
  260. return
  261. }
  262. Send {%9VAR% down}
  263. return
  264.  
  265. Joy10:: ; Button "Right Joystick push"
  266. if (LT >= 1 and RT >= 1) ; Both triggers are held
  267. 10VAR = null
  268. if (LT < 1 and RT < 1) ; No triggers are held
  269. 10VAR = NumpadIns
  270. if (LT >= 1 and RT < 1) ; Left trigger is held
  271. 10VAR = null
  272. if (LT < 1 and RT > 1) ; Right trigger is held
  273. 10VAR = null
  274. Send {%10VAR% down}
  275. SetTimer, WaitForButtonUpRJP, 30
  276. return
  277.  
  278. WaitForButtonUpRJP:
  279. if not GetKeyState("Joy10")
  280. {
  281. Send {%10VAR% up}
  282. SetTimer, WaitForButtonUpRJP, off
  283. return
  284. }
  285. Send {%10VAR% down}
  286. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement