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