PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/AutoHotkey.docset/Contents/Resources/Documents/scripts/JoystickTest.htm

https://gitlab.com/ahkscript/Autohotkey.docset
HTML | 104 lines | 97 code | 7 blank | 0 comment | 0 complexity | 1eada67ed960b25678e4e8de5a2a5ff1 MD5 | raw file
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Joystick Test Script</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <link href="../static/theme.css" rel="stylesheet" type="text/css" />
  8. <script src="../static/content.js" type="text/javascript"></script>
  9. </head>
  10. <body>
  11. <h1>Joystick Test Script</h1>
  12. <p>This script helps determine the button numbers and other attributes
  13. of your joystick. It might also reveal if your joystick is in need
  14. of calibration; that is, whether the range of motion of each of its
  15. axes is from 0 to 100 percent as it should be. If calibration is
  16. needed, use the operating system's control panel or the software
  17. that came with your joystick.
  18. </p>
  19. <p><a href="JoystickTest.ahk">Download This Script</a> &nbsp;| &nbsp;<a href="index.htm">Other Sample Scripts</a> &nbsp;| &nbsp;<a href="../AutoHotkey.htm">Home</a></p>
  20. <pre class="NoIndent"><em>; July 6, 2005: Added auto-detection of joystick number.
  21. ; May 8, 2005 : Fixed: JoyAxes is no longer queried as a means of
  22. ; detecting whether the joystick is connected. Some joysticks are
  23. ; gamepads and don't have even a single axis.</em>
  24. <em>; If you want to unconditionally use a specific joystick number, change
  25. ; the following value from 0 to the number of the joystick (1-16).
  26. ; A value of 0 causes the joystick number to be auto-detected:</em>
  27. JoystickNumber = 0
  28. <em>; END OF CONFIG SECTION. Do not make changes below this point unless
  29. ; you wish to alter the basic functionality of the script.</em>
  30. <em>; Auto-detect the joystick number if called for:</em>
  31. if JoystickNumber &lt;= 0
  32. {
  33. Loop 16 <em>; Query each joystick number to find out which ones exist.</em>
  34. {
  35. GetKeyState, JoyName, %A_Index%JoyName
  36. if JoyName &lt;&gt;
  37. {
  38. JoystickNumber = %A_Index%
  39. break
  40. }
  41. }
  42. if JoystickNumber &lt;= 0
  43. {
  44. MsgBox The system does not appear to have any joysticks.
  45. ExitApp
  46. }
  47. }
  48. #SingleInstance
  49. SetFormat, float, 03 <em>; Omit decimal point from axis position percentages.</em>
  50. GetKeyState, joy_buttons, %JoystickNumber%JoyButtons
  51. GetKeyState, joy_name, %JoystickNumber%JoyName
  52. GetKeyState, joy_info, %JoystickNumber%JoyInfo
  53. Loop
  54. {
  55. buttons_down =
  56. Loop, %joy_buttons%
  57. {
  58. GetKeyState, joy%a_index%, %JoystickNumber%joy%a_index%
  59. if joy%a_index% = D
  60. buttons_down = %buttons_down%%a_space%%a_index%
  61. }
  62. GetKeyState, joyx, %JoystickNumber%JoyX
  63. axis_info = X%joyx%
  64. GetKeyState, joyy, %JoystickNumber%JoyY
  65. axis_info = %axis_info%%a_space%%a_space%Y%joyy%
  66. IfInString, joy_info, Z
  67. {
  68. GetKeyState, joyz, %JoystickNumber%JoyZ
  69. axis_info = %axis_info%%a_space%%a_space%Z%joyz%
  70. }
  71. IfInString, joy_info, R
  72. {
  73. GetKeyState, joyr, %JoystickNumber%JoyR
  74. axis_info = %axis_info%%a_space%%a_space%R%joyr%
  75. }
  76. IfInString, joy_info, U
  77. {
  78. GetKeyState, joyu, %JoystickNumber%JoyU
  79. axis_info = %axis_info%%a_space%%a_space%U%joyu%
  80. }
  81. IfInString, joy_info, V
  82. {
  83. GetKeyState, joyv, %JoystickNumber%JoyV
  84. axis_info = %axis_info%%a_space%%a_space%V%joyv%
  85. }
  86. IfInString, joy_info, P
  87. {
  88. GetKeyState, joyp, %JoystickNumber%JoyPOV
  89. axis_info = %axis_info%%a_space%%a_space%POV%joyp%
  90. }
  91. ToolTip, %joy_name% (#%JoystickNumber%):`n%axis_info%`nButtons Down: %buttons_down%`n`n(right-click the tray icon to exit)
  92. Sleep, 100
  93. }
  94. return
  95. </pre>
  96. </body>
  97. </html>