SDL_xinput.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "../../SDL_internal.h"
  19. #ifndef SDL_xinput_h_
  20. #define SDL_xinput_h_
  21. #ifdef HAVE_XINPUT_H
  22. #include "SDL_windows.h"
  23. #include <xinput.h>
  24. #ifndef XUSER_MAX_COUNT
  25. #define XUSER_MAX_COUNT 4
  26. #endif
  27. #ifndef XUSER_INDEX_ANY
  28. #define XUSER_INDEX_ANY 0x000000FF
  29. #endif
  30. #ifndef XINPUT_CAPS_FFB_SUPPORTED
  31. #define XINPUT_CAPS_FFB_SUPPORTED 0x0001
  32. #endif
  33. #ifndef XINPUT_DEVSUBTYPE_UNKNOWN
  34. #define XINPUT_DEVSUBTYPE_UNKNOWN 0x00
  35. #endif
  36. #ifndef XINPUT_DEVSUBTYPE_GAMEPAD
  37. #define XINPUT_DEVSUBTYPE_GAMEPAD 0x01
  38. #endif
  39. #ifndef XINPUT_DEVSUBTYPE_WHEEL
  40. #define XINPUT_DEVSUBTYPE_WHEEL 0x02
  41. #endif
  42. #ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK
  43. #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
  44. #endif
  45. #ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
  46. #define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04
  47. #endif
  48. #ifndef XINPUT_DEVSUBTYPE_DANCE_PAD
  49. #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
  50. #endif
  51. #ifndef XINPUT_DEVSUBTYPE_GUITAR
  52. #define XINPUT_DEVSUBTYPE_GUITAR 0x06
  53. #endif
  54. #ifndef XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE
  55. #define XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE 0x07
  56. #endif
  57. #ifndef XINPUT_DEVSUBTYPE_DRUM_KIT
  58. #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
  59. #endif
  60. #ifndef XINPUT_DEVSUBTYPE_GUITAR_BASS
  61. #define XINPUT_DEVSUBTYPE_GUITAR_BASS 0x0B
  62. #endif
  63. #ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD
  64. #define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
  65. #endif
  66. #ifndef XINPUT_GAMEPAD_GUIDE
  67. #define XINPUT_GAMEPAD_GUIDE 0x0400
  68. #endif
  69. #ifndef BATTERY_DEVTYPE_GAMEPAD
  70. #define BATTERY_DEVTYPE_GAMEPAD 0x00
  71. #endif
  72. #ifndef BATTERY_TYPE_WIRED
  73. #define BATTERY_TYPE_WIRED 0x01
  74. #endif
  75. #ifndef BATTERY_TYPE_UNKNOWN
  76. #define BATTERY_TYPE_UNKNOWN 0xFF
  77. #endif
  78. #ifndef BATTERY_LEVEL_EMPTY
  79. #define BATTERY_LEVEL_EMPTY 0x00
  80. #endif
  81. #ifndef BATTERY_LEVEL_LOW
  82. #define BATTERY_LEVEL_LOW 0x01
  83. #endif
  84. #ifndef BATTERY_LEVEL_MEDIUM
  85. #define BATTERY_LEVEL_MEDIUM 0x02
  86. #endif
  87. #ifndef BATTERY_LEVEL_FULL
  88. #define BATTERY_LEVEL_FULL 0x03
  89. #endif
  90. /* typedef's for XInput structs we use */
  91. #ifndef HAVE_XINPUT_GAMEPAD_EX
  92. typedef struct
  93. {
  94. WORD wButtons;
  95. BYTE bLeftTrigger;
  96. BYTE bRightTrigger;
  97. SHORT sThumbLX;
  98. SHORT sThumbLY;
  99. SHORT sThumbRX;
  100. SHORT sThumbRY;
  101. DWORD dwPaddingReserved;
  102. } XINPUT_GAMEPAD_EX;
  103. #endif
  104. #ifndef HAVE_XINPUT_STATE_EX
  105. typedef struct
  106. {
  107. DWORD dwPacketNumber;
  108. XINPUT_GAMEPAD_EX Gamepad;
  109. } XINPUT_STATE_EX;
  110. #endif
  111. typedef struct
  112. {
  113. BYTE BatteryType;
  114. BYTE BatteryLevel;
  115. } XINPUT_BATTERY_INFORMATION_EX;
  116. /* Forward decl's for XInput API's we load dynamically and use if available */
  117. typedef DWORD (WINAPI *XInputGetState_t)
  118. (
  119. DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
  120. XINPUT_STATE_EX* pState /* [out] Receives the current state */
  121. );
  122. typedef DWORD (WINAPI *XInputSetState_t)
  123. (
  124. DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
  125. XINPUT_VIBRATION* pVibration /* [in, out] The vibration information to send to the controller */
  126. );
  127. typedef DWORD (WINAPI *XInputGetCapabilities_t)
  128. (
  129. DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
  130. DWORD dwFlags, /* [in] Input flags that identify the device type */
  131. XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */
  132. );
  133. typedef DWORD (WINAPI *XInputGetBatteryInformation_t)
  134. (
  135. DWORD dwUserIndex,
  136. BYTE devType,
  137. XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation
  138. );
  139. extern int WIN_LoadXInputDLL(void);
  140. extern void WIN_UnloadXInputDLL(void);
  141. extern XInputGetState_t SDL_XInputGetState;
  142. extern XInputSetState_t SDL_XInputSetState;
  143. extern XInputGetCapabilities_t SDL_XInputGetCapabilities;
  144. extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation;
  145. extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
  146. #define XINPUTGETSTATE SDL_XInputGetState
  147. #define XINPUTSETSTATE SDL_XInputSetState
  148. #define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities
  149. #define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation
  150. #endif /* HAVE_XINPUT_H */
  151. #endif /* SDL_xinput_h_ */
  152. /* vi: set ts=4 sw=4 expandtab: */