Platformer in OpenGL
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

239 行
7.8 KiB

5 年前
  1. /*
  2. * The Wine project - Xinput Joystick Library
  3. * Copyright 2008 Andrew Fenn
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  18. */
  19. #ifndef __WINE_XINPUT_H
  20. #define __WINE_XINPUT_H
  21. #include <windef.h>
  22. /*
  23. * Bitmasks for the joysticks buttons, determines what has
  24. * been pressed on the joystick, these need to be mapped
  25. * to whatever device you're using instead of an xbox 360
  26. * joystick
  27. */
  28. #define XINPUT_GAMEPAD_DPAD_UP 0x0001
  29. #define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
  30. #define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
  31. #define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
  32. #define XINPUT_GAMEPAD_START 0x0010
  33. #define XINPUT_GAMEPAD_BACK 0x0020
  34. #define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
  35. #define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
  36. #define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
  37. #define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
  38. #define XINPUT_GAMEPAD_A 0x1000
  39. #define XINPUT_GAMEPAD_B 0x2000
  40. #define XINPUT_GAMEPAD_X 0x4000
  41. #define XINPUT_GAMEPAD_Y 0x8000
  42. /*
  43. * Defines the flags used to determine if the user is pushing
  44. * down on a button, not holding a button, etc
  45. */
  46. #define XINPUT_KEYSTROKE_KEYDOWN 0x0001
  47. #define XINPUT_KEYSTROKE_KEYUP 0x0002
  48. #define XINPUT_KEYSTROKE_REPEAT 0x0004
  49. /*
  50. * Defines the codes which are returned by XInputGetKeystroke
  51. */
  52. #define VK_PAD_A 0x5800
  53. #define VK_PAD_B 0x5801
  54. #define VK_PAD_X 0x5802
  55. #define VK_PAD_Y 0x5803
  56. #define VK_PAD_RSHOULDER 0x5804
  57. #define VK_PAD_LSHOULDER 0x5805
  58. #define VK_PAD_LTRIGGER 0x5806
  59. #define VK_PAD_RTRIGGER 0x5807
  60. #define VK_PAD_DPAD_UP 0x5810
  61. #define VK_PAD_DPAD_DOWN 0x5811
  62. #define VK_PAD_DPAD_LEFT 0x5812
  63. #define VK_PAD_DPAD_RIGHT 0x5813
  64. #define VK_PAD_START 0x5814
  65. #define VK_PAD_BACK 0x5815
  66. #define VK_PAD_LTHUMB_PRESS 0x5816
  67. #define VK_PAD_RTHUMB_PRESS 0x5817
  68. #define VK_PAD_LTHUMB_UP 0x5820
  69. #define VK_PAD_LTHUMB_DOWN 0x5821
  70. #define VK_PAD_LTHUMB_RIGHT 0x5822
  71. #define VK_PAD_LTHUMB_LEFT 0x5823
  72. #define VK_PAD_LTHUMB_UPLEFT 0x5824
  73. #define VK_PAD_LTHUMB_UPRIGHT 0x5825
  74. #define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
  75. #define VK_PAD_LTHUMB_DOWNLEFT 0x5827
  76. #define VK_PAD_RTHUMB_UP 0x5830
  77. #define VK_PAD_RTHUMB_DOWN 0x5831
  78. #define VK_PAD_RTHUMB_RIGHT 0x5832
  79. #define VK_PAD_RTHUMB_LEFT 0x5833
  80. #define VK_PAD_RTHUMB_UPLEFT 0x5834
  81. #define VK_PAD_RTHUMB_UPRIGHT 0x5835
  82. #define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
  83. #define VK_PAD_RTHUMB_DOWNLEFT 0x5837
  84. /*
  85. * Deadzones are for analogue joystick controls on the joypad
  86. * which determine when input should be assumed to be in the
  87. * middle of the pad. This is a threshold to stop a joypad
  88. * controlling the game when the player isn't touching the
  89. * controls.
  90. */
  91. #define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
  92. #define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
  93. #define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
  94. /*
  95. * Defines what type of abilities the type of joystick has
  96. * DEVTYPE_GAMEPAD is available for all joysticks, however
  97. * there may be more specific identifiers for other joysticks
  98. * which are being used.
  99. */
  100. #define XINPUT_DEVTYPE_GAMEPAD 0x01
  101. #define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
  102. #define XINPUT_DEVSUBTYPE_WHEEL 0x02
  103. #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
  104. #define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
  105. #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
  106. #define XINPUT_DEVSUBTYPE_GUITAR 0x06
  107. #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
  108. /*
  109. * These are used with the XInputGetCapabilities function to
  110. * determine the abilities to the joystick which has been
  111. * plugged in.
  112. */
  113. #define XINPUT_CAPS_VOICE_SUPPORTED 0x0004
  114. #define XINPUT_FLAG_GAMEPAD 0x00000001
  115. /*
  116. * Defines the status of the battery if one is used in the
  117. * attached joystick. The first two define if the joystick
  118. * supports a battery. Disconnected means that the joystick
  119. * isn't connected. Wired shows that the joystick is a wired
  120. * joystick.
  121. */
  122. #define BATTERY_DEVTYPE_GAMEPAD 0x00
  123. #define BATTERY_DEVTYPE_HEADSET 0x01
  124. #define BATTERY_TYPE_DISCONNECTED 0x00
  125. #define BATTERY_TYPE_WIRED 0x01
  126. #define BATTERY_TYPE_ALKALINE 0x02
  127. #define BATTERY_TYPE_NIMH 0x03
  128. #define BATTERY_TYPE_UNKNOWN 0xFF
  129. #define BATTERY_LEVEL_EMPTY 0x00
  130. #define BATTERY_LEVEL_LOW 0x01
  131. #define BATTERY_LEVEL_MEDIUM 0x02
  132. #define BATTERY_LEVEL_FULL 0x03
  133. /*
  134. * How many joysticks can be used with this library. Games that
  135. * use the xinput library will not go over this number.
  136. */
  137. #define XUSER_MAX_COUNT 4
  138. #define XUSER_INDEX_ANY 0x000000FF
  139. /*
  140. * Defines the structure of an xbox 360 joystick.
  141. */
  142. typedef struct _XINPUT_GAMEPAD {
  143. WORD wButtons;
  144. BYTE bLeftTrigger;
  145. BYTE bRightTrigger;
  146. SHORT sThumbLX;
  147. SHORT sThumbLY;
  148. SHORT sThumbRX;
  149. SHORT sThumbRY;
  150. } XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
  151. typedef struct _XINPUT_STATE {
  152. DWORD dwPacketNumber;
  153. XINPUT_GAMEPAD Gamepad;
  154. } XINPUT_STATE, *PXINPUT_STATE;
  155. /*
  156. * Defines the structure of how much vibration is set on both the
  157. * right and left motors in a joystick. If you're not using a 360
  158. * joystick you will have to map these to your device.
  159. */
  160. typedef struct _XINPUT_VIBRATION {
  161. WORD wLeftMotorSpeed;
  162. WORD wRightMotorSpeed;
  163. } XINPUT_VIBRATION, *PXINPUT_VIBRATION;
  164. /*
  165. * Defines the structure for what kind of abilities the joystick has
  166. * such abilities are things such as if the joystick has the ability
  167. * to send and receive audio, if the joystick is in fact a driving
  168. * wheel or perhaps if the joystick is some kind of dance pad or
  169. * guitar.
  170. */
  171. typedef struct _XINPUT_CAPABILITIES {
  172. BYTE Type;
  173. BYTE SubType;
  174. WORD Flags;
  175. XINPUT_GAMEPAD Gamepad;
  176. XINPUT_VIBRATION Vibration;
  177. } XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
  178. /*
  179. * Defines the structure for a joystick input event which is
  180. * retrieved using the function XInputGetKeystroke
  181. */
  182. typedef struct _XINPUT_KEYSTROKE {
  183. WORD VirtualKey;
  184. WCHAR Unicode;
  185. WORD Flags;
  186. BYTE UserIndex;
  187. BYTE HidCode;
  188. } XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
  189. typedef struct _XINPUT_BATTERY_INFORMATION
  190. {
  191. BYTE BatteryType;
  192. BYTE BatteryLevel;
  193. } XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
  194. #ifdef __cplusplus
  195. extern "C" {
  196. #endif
  197. void WINAPI XInputEnable(WINBOOL);
  198. DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*);
  199. DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*);
  200. DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
  201. DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
  202. DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
  203. DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
  204. #ifdef __cplusplus
  205. }
  206. #endif
  207. #endif /* __WINE_XINPUT_H */