Advertisement
Guest User

Xbox controller to Undertale buttons

a guest
Apr 11th, 2019
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #SingleInstance
  2. #Persistent
  3.  
  4. ;;;;;;;;;;;;;;;;;;;;
  5. ;;; SET UP HERE! ;;;
  6.  
  7.  
  8. ; This is the sensitivity of the joystick.
  9. ; Must be between 0 (no input detected) and 49 (unbelievably sensitive)
  10. Sensitivity = 25
  11.  
  12. ;;;              ;;;
  13. ;;;;;;;;;;;;;;;;;;;;
  14.  
  15.  
  16.  
  17. InverseSensitivity := 100 - Sensitivity
  18.  
  19. wasHoldingRight = 0
  20. wasHoldingLeft  = 0
  21. wasHoldingUp    = 0
  22. wasHoldingDown  = 0
  23.  
  24. wasHoldingZ = 0
  25. wasHoldingX = 0
  26. wasHoldingC = 0
  27.  
  28.  
  29.  
  30. SetTimer, Update, 10
  31. return
  32.  
  33.  
  34.  
  35. Update:
  36. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  37. ; Detect joystick input for each direction ;
  38. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  39.  
  40. GetKeyState, joyx, JoyX
  41. GetKeyState, joyy, JoyY
  42. GetKeyState, joypov, JoyPOV
  43.  
  44. ; Tooltip, Left: %wasHoldingLeft%`nRight: %wasHoldingRight%`nDown: %wasHoldingDown%`nUp: %wasHoldingUp%
  45.  
  46. ; Left
  47. if (joyx < Sensitivity and wasHoldingLeft == 0) then {
  48.     wasHoldingLeft = 1
  49.     Send, {Left down}
  50. } else if (joyx >= Sensitivity and wasHoldingLeft == 1) then {
  51.     wasHoldingLeft = 0
  52.     Send, {Left up}
  53. }
  54.  
  55. ; Right
  56. if (joyx > InverseSensitivity and wasHoldingRight == 0) then {
  57.     wasHoldingRight = 1
  58.     Send, {Right down}
  59. } else if (joyx <= InverseSensitivity and wasHoldingRight == 1) then {
  60.     wasHoldingRight = 0
  61.     Send, {Right up}
  62. }
  63.  
  64. ; Up
  65. if (joyy < Sensitivity and wasHoldingUp == 0) then {
  66.     wasHoldingUp = 1
  67.     Send, {Up down}
  68. } else if (joyy >= Sensitivity and wasHoldingUp == 1) then {
  69.     wasHoldingUp = 0
  70.     Send, {Up up}
  71. }
  72.  
  73. ; Down
  74. if (joyy > InverseSensitivity and wasHoldingDown == 0) then {
  75.     wasHoldingDown = 1
  76.     Send, {Down down}
  77. } else if (joyy <= InverseSensitivity and wasHoldingDown == 1) then {
  78.     wasHoldingDown = 0
  79.     Send, {Down up}
  80. }
  81.  
  82.  
  83.  
  84. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  85. ; Detect 3 Joystick buttons ;
  86. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  87.  
  88. GetKeyState, z, Joy1
  89. GetKeyState, x, Joy2
  90. GetKeyState, c, Joy3
  91.  
  92. ; Z
  93. if (z == "D" and wasHoldingZ == 0) then {
  94.     wasHoldingZ = 1
  95.     Send, {z down}
  96. } else if (z == "U" and wasHoldingZ == 1) then {
  97.     wasHoldingZ = 0
  98.     Send, {z up}
  99. }
  100.  
  101. ; X
  102. if (x == "D" and wasHoldingX == 0) then {
  103.     wasHoldingX = 1
  104.     Send, {x down}
  105. } else if (x == "U" and wasHoldingX == 1) then {
  106.     wasHoldingX = 0
  107.     Send, {x up}
  108. }
  109.  
  110. ; C
  111. if (c == "D" and wasHoldingC == 0) then {
  112.     wasHoldingC = 1
  113.     Send, {c down}
  114. } else if (c == "U" and wasHoldingC == 1) then {
  115.     wasHoldingC = 0
  116.     Send, {c up}
  117. }
  118.  
  119. return
  120.  
  121.  
  122.  
  123. ; Joy7::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement