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