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