Advertisement
dainemudda

DOA6 Controller to Keyboard 1.0.0.ahk

Apr 2nd, 2019
668
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Verison 1.0.0
  2.  
  3. ; In order for this to work you will need to execute Autohotkey as Administrator.
  4. ; You might have to run Dead or Alive in windowed or borderless mode.
  5.  
  6. #Persistent  ; Keep this script running until the user explicitly exits it.
  7. SetTimer, WatchAxis, 50 ; set to 1000 for debug and activate the Tooltip
  8. return
  9.  
  10. WatchAxis:
  11. GetKeyState, JoyX, JoyX  ; Get position of X axis. left stick
  12. GetKeyState, JoyY, JoyY  ; Get position of Y axis. left stick
  13. GetKeyState, JoyR, JoyR  ; Get position of R axis. right stick
  14. GetKeyState, JoyZ, JoyZ  ; Get position of Z axis. right stick
  15.  
  16. KeyToHoldDownPrevX = %KeyToHoldDownX%  ; Prev now holds the key that was down before (if any).
  17. KeyToHoldDownPrevY = %KeyToHoldDownY%
  18. KeyToHoldDownPrevR = %KeyToHoldDownR%  ; Prev now holds the key that was down before (if any).
  19. KeyToHoldDownPrevZ = %KeyToHoldDownZ%
  20.  
  21. KeyToHoldDownX =
  22. KeyToHoldDownY =
  23. KeyToHoldDownR =
  24. KeyToHoldDownZ =
  25. if JoyX > 70
  26.     KeyToHoldDownX = Right
  27. else if JoyX < 30
  28.     KeyToHoldDownX = Left
  29. if JoyY > 70
  30.     KeyToHoldDownY = Down
  31. else if JoyY < 30
  32.     KeyToHoldDownY = Up
  33.  
  34. if JoyR > 70
  35.     KeyToHoldDownR = d
  36. else if JoyR < 30
  37.     KeyToHoldDownR = a
  38. if JoyZ > 70
  39.     KeyToHoldDownZ = s
  40. else if JoyZ < 30
  41.     KeyToHoldDownZ = w
  42.  
  43. ; Tooltip, comment out next line to activate
  44. ; Tooltip, last released: %LastReleased% `nlast pressed %LastPressed% `ncurrent keys: %KeyToHoldDownPrevX% %KeyToHoldDownPrevY%-> %KeyToHoldDownX% %KeyToHoldDownY%
  45.  
  46. if KeyToHoldDownX = %KeyToHoldDownPrevX% and KeyToHoldDownPrevY = %KeyToHoldDownPrevY% and KeyToHoldDownPrevR = %KeyToHoldDownPrevR% and KeyToHoldDownPrevZ = %KeyToHoldDownPrevZ%    ; The correct key is already down (or no key is needed).
  47.     return  ; Do nothing.
  48.  
  49. ; Otherwise, release the previous key and press down the new key:
  50. SetKeyDelay -1  ; Avoid delays between keystrokes.
  51. if (KeyToHoldDownPrevX or KeyToHoldDownPrevY){
  52.     LastReleased = %KeyToHoldDownPrevX% %KeyToHoldDownPrevY%
  53.     ; There is a previous key to release.
  54.     Send, {%KeyToHoldDownPrevX% up}{%KeyToHoldDownPrevY% up}  ; Release it.
  55. }  
  56.    
  57. if (KeyToHoldDownX or KeyToHoldDownY){  
  58.     LastPressed = %KeyToHoldDownX% %KeyToHoldDownY%
  59.     ; There is a key to press down.
  60.     Send, {%KeyToHoldDownX% down}{%KeyToHoldDownY% down}  ; Press it down.
  61. }
  62.  
  63. if (KeyToHoldDownPrevR or KeyToHoldDownPrevZ){
  64.     LastReleased = %KeyToHoldDownPrevR% %KeyToHoldDownPrevZ%
  65.     ; There is a previous key to release.
  66.     Send, {%KeyToHoldDownPrevR% up}{%KeyToHoldDownPrevZ% up}  ; Release it.
  67. }  
  68.    
  69. if (KeyToHoldDownR or KeyToHoldDownZ){  
  70.     LastPressed = %KeyToHoldDownR% %KeyToHoldDownZ%
  71.     ; There is a key to press down.
  72.     Send, {%KeyToHoldDownR% down}{%KeyToHoldDownZ% down}  ; Press it down.
  73. }
  74.  
  75.  
  76. return
  77.  
  78.  
  79.  
  80. Joy1::
  81. Send {j down}  
  82. KeyWait Joy1  ; Wait for the user to release the joystick button.
  83. Send {j up}  
  84. return
  85.  
  86. Joy2::
  87. Send {k down}  
  88. KeyWait Joy2  ; Wait for the user to release the joystick button.
  89. Send {k up}  
  90. return
  91.  
  92. Joy3::
  93. Send {m down}  
  94. KeyWait Joy3  ; Wait for the user to release the joystick button.
  95. Send {m up}  
  96. return
  97.  
  98. Joy4::
  99. Send {l down}  
  100. KeyWait Joy4  ; Wait for the user to release the joystick button.
  101. Send {l up}  
  102. return
  103.  
  104. Joy5::
  105. Send {u down}  
  106. KeyWait Joy5  ; Wait for the user to release the joystick button.
  107. Send {u up}  
  108. return
  109.  
  110. Joy6::
  111. Send {n down}  
  112. KeyWait Joy6  ; Wait for the user to release the joystick button.
  113. Send {n up}  
  114. return
  115.  
  116. Joy7::
  117. Send {i down}  
  118. KeyWait Joy7  ; Wait for the user to release the joystick button.
  119. Send {i up}  
  120. return
  121.  
  122. Joy8::
  123. Send {o down}  
  124. KeyWait Joy8  ; Wait for the user to release the joystick button.
  125. Send {o up}  
  126. return
  127.  
  128. Joy9::
  129. Send {Space down}  
  130. KeyWait Joy9  ; Wait for the user to release the joystick button.
  131. Send {Space up}  
  132. return
  133.  
  134. Joy10::
  135. Send {Enter down}  
  136. KeyWait Joy10  ; Wait for the user to release the joystick button.
  137. Send {Enter up}  
  138. return
  139.  
  140. Joy11::
  141. Send {E down}  
  142. KeyWait Joy11  ; Wait for the user to release the joystick button.
  143. Send {E up}  
  144. return
  145.  
  146. Joy12::
  147. Send {Z down}  
  148. KeyWait Joy12  ; Wait for the user to release the joystick button.
  149. Send {Z up}  
  150. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement