Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

258 lines
8.4 KiB

  1. /***************************************************************************
  2. * *
  3. * XInput.h -- This module defines XBOX controller APIs *
  4. * and constansts for the Windows platform. *
  5. * *
  6. * Copyright (c) Microsoft Corp. All rights reserved. *
  7. * *
  8. ***************************************************************************/
  9. #ifndef _XINPUT_H_
  10. #define _XINPUT_H_
  11. #include <windef.h>
  12. // Current name of the DLL shipped in the same SDK as this header.
  13. // The name reflects the current version
  14. #define XINPUT_DLL_A "xinput1_3.dll"
  15. #define XINPUT_DLL_W L"xinput1_3.dll"
  16. #ifdef UNICODE
  17. #define XINPUT_DLL XINPUT_DLL_W
  18. #else
  19. #define XINPUT_DLL XINPUT_DLL_A
  20. #endif
  21. //
  22. // Device types available in XINPUT_CAPABILITIES
  23. //
  24. #define XINPUT_DEVTYPE_GAMEPAD 0x01
  25. //
  26. // Device subtypes available in XINPUT_CAPABILITIES
  27. //
  28. #define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
  29. #define XINPUT_DEVSUBTYPE_WHEEL 0x02
  30. #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
  31. #define XINPUT_DEVSUBTYPE_FLIGHT_SICK 0x04
  32. #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
  33. #define XINPUT_DEVSUBTYPE_GUITAR 0x06
  34. #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
  35. //
  36. // Flags for XINPUT_CAPABILITIES
  37. //
  38. #define XINPUT_CAPS_VOICE_SUPPORTED 0x0004
  39. //
  40. // Constants for gamepad buttons
  41. //
  42. #define XINPUT_GAMEPAD_DPAD_UP 0x0001
  43. #define XINPUT_GAMEPAD_DPAD_DOWN 0x0002
  44. #define XINPUT_GAMEPAD_DPAD_LEFT 0x0004
  45. #define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008
  46. #define XINPUT_GAMEPAD_START 0x0010
  47. #define XINPUT_GAMEPAD_BACK 0x0020
  48. #define XINPUT_GAMEPAD_LEFT_THUMB 0x0040
  49. #define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080
  50. #define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100
  51. #define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200
  52. #define XINPUT_GAMEPAD_A 0x1000
  53. #define XINPUT_GAMEPAD_B 0x2000
  54. #define XINPUT_GAMEPAD_X 0x4000
  55. #define XINPUT_GAMEPAD_Y 0x8000
  56. //
  57. // Gamepad thresholds
  58. //
  59. #define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849
  60. #define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
  61. #define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30
  62. //
  63. // Flags to pass to XInputGetCapabilities
  64. //
  65. #define XINPUT_FLAG_GAMEPAD 0x00000001
  66. //
  67. // Devices that support batteries
  68. //
  69. #define BATTERY_DEVTYPE_GAMEPAD 0x00
  70. #define BATTERY_DEVTYPE_HEADSET 0x01
  71. //
  72. // Flags for battery status level
  73. //
  74. #define BATTERY_TYPE_DISCONNECTED 0x00 // This device is not connected
  75. #define BATTERY_TYPE_WIRED 0x01 // Wired device, no battery
  76. #define BATTERY_TYPE_ALKALINE 0x02 // Alkaline battery source
  77. #define BATTERY_TYPE_NIMH 0x03 // Nickel Metal Hydride battery source
  78. #define BATTERY_TYPE_UNKNOWN 0xFF // Cannot determine the battery type
  79. // These are only valid for wireless, connected devices, with known battery types
  80. // The amount of use time remaining depends on the type of device.
  81. #define BATTERY_LEVEL_EMPTY 0x00
  82. #define BATTERY_LEVEL_LOW 0x01
  83. #define BATTERY_LEVEL_MEDIUM 0x02
  84. #define BATTERY_LEVEL_FULL 0x03
  85. // User index definitions
  86. #define XUSER_MAX_COUNT 4
  87. #define XUSER_INDEX_ANY 0x000000FF
  88. //
  89. // Codes returned for the gamepad keystroke
  90. //
  91. #define VK_PAD_A 0x5800
  92. #define VK_PAD_B 0x5801
  93. #define VK_PAD_X 0x5802
  94. #define VK_PAD_Y 0x5803
  95. #define VK_PAD_RSHOULDER 0x5804
  96. #define VK_PAD_LSHOULDER 0x5805
  97. #define VK_PAD_LTRIGGER 0x5806
  98. #define VK_PAD_RTRIGGER 0x5807
  99. #define VK_PAD_DPAD_UP 0x5810
  100. #define VK_PAD_DPAD_DOWN 0x5811
  101. #define VK_PAD_DPAD_LEFT 0x5812
  102. #define VK_PAD_DPAD_RIGHT 0x5813
  103. #define VK_PAD_START 0x5814
  104. #define VK_PAD_BACK 0x5815
  105. #define VK_PAD_LTHUMB_PRESS 0x5816
  106. #define VK_PAD_RTHUMB_PRESS 0x5817
  107. #define VK_PAD_LTHUMB_UP 0x5820
  108. #define VK_PAD_LTHUMB_DOWN 0x5821
  109. #define VK_PAD_LTHUMB_RIGHT 0x5822
  110. #define VK_PAD_LTHUMB_LEFT 0x5823
  111. #define VK_PAD_LTHUMB_UPLEFT 0x5824
  112. #define VK_PAD_LTHUMB_UPRIGHT 0x5825
  113. #define VK_PAD_LTHUMB_DOWNRIGHT 0x5826
  114. #define VK_PAD_LTHUMB_DOWNLEFT 0x5827
  115. #define VK_PAD_RTHUMB_UP 0x5830
  116. #define VK_PAD_RTHUMB_DOWN 0x5831
  117. #define VK_PAD_RTHUMB_RIGHT 0x5832
  118. #define VK_PAD_RTHUMB_LEFT 0x5833
  119. #define VK_PAD_RTHUMB_UPLEFT 0x5834
  120. #define VK_PAD_RTHUMB_UPRIGHT 0x5835
  121. #define VK_PAD_RTHUMB_DOWNRIGHT 0x5836
  122. #define VK_PAD_RTHUMB_DOWNLEFT 0x5837
  123. //
  124. // Flags used in XINPUT_KEYSTROKE
  125. //
  126. #define XINPUT_KEYSTROKE_KEYDOWN 0x0001
  127. #define XINPUT_KEYSTROKE_KEYUP 0x0002
  128. #define XINPUT_KEYSTROKE_REPEAT 0x0004
  129. //
  130. // Structures used by XInput APIs
  131. //
  132. typedef struct _XINPUT_GAMEPAD
  133. {
  134. WORD wButtons;
  135. BYTE bLeftTrigger;
  136. BYTE bRightTrigger;
  137. SHORT sThumbLX;
  138. SHORT sThumbLY;
  139. SHORT sThumbRX;
  140. SHORT sThumbRY;
  141. } XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
  142. typedef struct _XINPUT_STATE
  143. {
  144. DWORD dwPacketNumber;
  145. XINPUT_GAMEPAD Gamepad;
  146. } XINPUT_STATE, *PXINPUT_STATE;
  147. typedef struct _XINPUT_VIBRATION
  148. {
  149. WORD wLeftMotorSpeed;
  150. WORD wRightMotorSpeed;
  151. } XINPUT_VIBRATION, *PXINPUT_VIBRATION;
  152. typedef struct _XINPUT_CAPABILITIES
  153. {
  154. BYTE Type;
  155. BYTE SubType;
  156. WORD Flags;
  157. XINPUT_GAMEPAD Gamepad;
  158. XINPUT_VIBRATION Vibration;
  159. } XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
  160. typedef struct _XINPUT_BATTERY_INFORMATION
  161. {
  162. BYTE BatteryType;
  163. BYTE BatteryLevel;
  164. } XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
  165. typedef struct _XINPUT_KEYSTROKE
  166. {
  167. WORD VirtualKey;
  168. WCHAR Unicode;
  169. WORD Flags;
  170. BYTE UserIndex;
  171. BYTE HidCode;
  172. } XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
  173. //
  174. // XInput APIs
  175. //
  176. #ifdef __cplusplus
  177. extern "C" {
  178. #endif
  179. DWORD WINAPI XInputGetState
  180. (
  181. DWORD dwUserIndex, // [in] Index of the gamer associated with the device
  182. XINPUT_STATE* pState // [out] Receives the current state
  183. );
  184. DWORD WINAPI XInputSetState
  185. (
  186. DWORD dwUserIndex, // [in] Index of the gamer associated with the device
  187. XINPUT_VIBRATION* pVibration // [in, out] The vibration information to send to the controller
  188. );
  189. DWORD WINAPI XInputGetCapabilities
  190. (
  191. DWORD dwUserIndex, // [in] Index of the gamer associated with the device
  192. DWORD dwFlags, // [in] Input flags that identify the device type
  193. XINPUT_CAPABILITIES* pCapabilities // [out] Receives the capabilities
  194. );
  195. void WINAPI XInputEnable
  196. (
  197. BOOL enable // [in] Indicates whether xinput is enabled or disabled.
  198. );
  199. DWORD WINAPI XInputGetDSoundAudioDeviceGuids
  200. (
  201. DWORD dwUserIndex, // [in] Index of the gamer associated with the device
  202. GUID* pDSoundRenderGuid, // [out] DSound device ID for render
  203. GUID* pDSoundCaptureGuid // [out] DSound device ID for capture
  204. );
  205. DWORD WINAPI XInputGetBatteryInformation
  206. (
  207. DWORD dwUserIndex, // [in] Index of the gamer associated with the device
  208. BYTE devType, // [in] Which device on this user index
  209. XINPUT_BATTERY_INFORMATION* pBatteryInformation // [out] Contains the level and types of batteries
  210. );
  211. DWORD WINAPI XInputGetKeystroke
  212. (
  213. DWORD dwUserIndex, // [in] Index of the gamer associated with the device
  214. DWORD dwReserved, // [in] Reserved for future use
  215. PXINPUT_KEYSTROKE pKeystroke // [out] Pointer to an XINPUT_KEYSTROKE structure that receives an input event.
  216. );
  217. #ifdef __cplusplus
  218. }
  219. #endif
  220. #endif //_XINPUT_H_