zenilib: zenilib/jni/external/sdl/src/joystick/windows/SDL_dxjoystick_c.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_dxjoystick_c.h
Go to the documentation of this file.
1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22
23 #ifndef SDL_JOYSTICK_DINPUT_H
24
25 /* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de
26 * A. Formiga's WINMM driver.
27 *
28 * Hats and sliders are completely untested; the app I'm writing this for mostly
29 * doesn't use them and I don't own any joysticks with them.
30 *
31 * We don't bother to use event notification here. It doesn't seem to work
32 * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
33 * let it return 0 events. */
34
35 #include "../../core/windows/SDL_windows.h"
36
37 #define DIRECTINPUT_VERSION 0x0800 /* Need version 7 for force feedback. Need version 8 so IDirectInput8_EnumDevices doesn't leak like a sieve... */
38 #include <dinput.h>
39 #define COBJMACROS
40 #include <wbemcli.h>
41 #include <oleauto.h>
42 #include <xinput.h>
43 #include <devguid.h>
44 #include <dbt.h>
45 #include <xinput.h>
46
47 #ifndef XUSER_MAX_COUNT
48 #define XUSER_MAX_COUNT 4
49 #endif
50 #ifndef XUSER_INDEX_ANY
51 #define XUSER_INDEX_ANY 0x000000FF
52 #endif
53 #ifndef XINPUT_CAPS_FFB_SUPPORTED
54 #define XINPUT_CAPS_FFB_SUPPORTED 0x0001
55 #endif
56
57
58 /* typedef's for XInput structs we use */
59 typedef struct
60 {
61 WORD wButtons;
62 BYTE bLeftTrigger;
63 BYTE bRightTrigger;
64 SHORT sThumbLX;
65 SHORT sThumbLY;
66 SHORT sThumbRX;
67 SHORT sThumbRY;
68 DWORD dwPaddingReserved;
69 } XINPUT_GAMEPAD_EX;
70
71 typedef struct
72 {
73 DWORD dwPacketNumber;
74 XINPUT_GAMEPAD_EX Gamepad;
75 } XINPUT_STATE_EX;
76
77 /* Forward decl's for XInput API's we load dynamically and use if available */
78 typedef DWORD (WINAPI *XInputGetState_t)
79 (
80 DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
81 XINPUT_STATE_EX* pState /* [out] Receives the current state */
82 );
83
84 typedef DWORD (WINAPI *XInputSetState_t)
85 (
86 DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
87 XINPUT_VIBRATION* pVibration /* [in, out] The vibration information to send to the controller */
88 );
89
90 typedef DWORD (WINAPI *XInputGetCapabilities_t)
91 (
92 DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
93 DWORD dwFlags, /* [in] Input flags that identify the device type */
94 XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */
95 );
96
97 extern int WIN_LoadXInputDLL(void);
98 extern void WIN_UnloadXInputDLL(void);
99
100 extern XInputGetState_t SDL_XInputGetState;
101 extern XInputSetState_t SDL_XInputSetState;
102 extern XInputGetCapabilities_t SDL_XInputGetCapabilities;
103 extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */
104
105 #define XINPUTGETSTATE SDL_XInputGetState
106 #define XINPUTSETSTATE SDL_XInputSetState
107 #define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities
108 #define INVALID_XINPUT_USERID XUSER_INDEX_ANY
109 #define SDL_XINPUT_MAX_DEVICES XUSER_MAX_COUNT
110
111 #define MAX_INPUTS 256 /* each joystick can have up to 256 inputs */
112
113
114 /* local types */
115 typedef enum Type
116 { BUTTON, AXIS, HAT } Type;
117
118 typedef struct input_t
119 {
120 /* DirectInput offset for this input type: */
121 DWORD ofs;
122
123 /* Button, axis or hat: */
124 Type type;
125
126 /* SDL input offset: */
127 Uint8 num;
128 } input_t;
129
130 /* The private structure used to keep track of a joystick */
131 struct joystick_hwdata
132 {
133 LPDIRECTINPUTDEVICE8 InputDevice;
134 DIDEVCAPS Capabilities;
135 int buffered;
136 SDL_JoystickGUID guid;
137
138 input_t Inputs[MAX_INPUTS];
139 int NumInputs;
140 int NumSliders;
141 Uint8 removed;
142 Uint8 send_remove_event;
143 Uint8 bXInputDevice; /* 1 if this device supports using the xinput API rather than DirectInput */
144 Uint8 bXInputHaptic; /* Supports force feedback via XInput. */
145 Uint8 userid; /* XInput userid index for this joystick */
146 Uint8 currentXInputSlot; /* the current position to write to in XInputState below, used so we can compare old and new values */
147 XINPUT_STATE_EX XInputState[2];
148 };
149
150 #endif /* SDL_JOYSTICK_DINPUT_H */
joystick_hwdata::Inputs
input_t Inputs[MAX_INPUTS]
Definition: SDL_dxjoystick_c.h:138
XINPUT_STATE_EX::Gamepad
XINPUT_GAMEPAD_EX Gamepad
Definition: SDL_dxjoystick_c.h:74
input_t
struct input_t input_t
joystick_hwdata::currentXInputSlot
Uint8 currentXInputSlot
Definition: SDL_dxjoystick_c.h:146
joystick_hwdata::guid
SDL_JoystickGUID guid
Definition: SDL_sysjoystick_c.h:82
joystick_hwdata::InputDevice
LPDIRECTINPUTDEVICE8 InputDevice
Definition: SDL_dxjoystick_c.h:133
XINPUT_STATE_EX::dwPacketNumber
DWORD dwPacketNumber
Definition: SDL_dxjoystick_c.h:73
joystick_hwdata::removed
Uint8 removed
Definition: SDL_dxjoystick_c.h:141
BUTTON
Definition: SDL_dxjoystick_c.h:116
joystick_hwdata::NumInputs
int NumInputs
Definition: SDL_dxjoystick_c.h:139
AXIS
Definition: SDL_dxjoystick_c.h:116
joystick_hwdata::buffered
int buffered
Definition: SDL_dxjoystick_c.h:135
XINPUT_STATE_EX
Definition: SDL_dxjoystick_c.h:71
joystick_hwdata::userid
Uint8 userid
Definition: SDL_dxjoystick_c.h:145
Type
Type
Definition: SDL_dxjoystick_c.h:115
XINPUT_GAMEPAD_EX::bLeftTrigger
BYTE bLeftTrigger
Definition: SDL_dxjoystick_c.h:62
SDL_XInputSetState
XInputSetState_t SDL_XInputSetState
joystick_hwdata::send_remove_event
Uint8 send_remove_event
Definition: SDL_dxjoystick_c.h:142
XINPUT_GAMEPAD_EX::sThumbRX
SHORT sThumbRX
Definition: SDL_dxjoystick_c.h:66
XINPUT_GAMEPAD_EX::sThumbLY
SHORT sThumbLY
Definition: SDL_dxjoystick_c.h:65
SDL_config.h
input_t::ofs
DWORD ofs
Definition: SDL_dxjoystick_c.h:121
joystick_hwdata
Definition: SDL_sysjoystick_c.h:58
joystick_hwdata::Capabilities
DIDEVCAPS Capabilities
Definition: SDL_dxjoystick_c.h:134
XINPUT_GAMEPAD_EX::dwPaddingReserved
DWORD dwPaddingReserved
Definition: SDL_dxjoystick_c.h:68
pCapabilities
DWORD XINPUT_CAPABILITIES * pCapabilities
Definition: SDL_dxjoystick_c.h:93
input_t::type
Type type
Definition: SDL_dxjoystick_c.h:124
input_t::num
Uint8 num
Definition: SDL_dxjoystick_c.h:127
WIN_UnloadXInputDLL
void WIN_UnloadXInputDLL(void)
MAX_INPUTS
#define MAX_INPUTS
Definition: SDL_dxjoystick_c.h:111
joystick_hwdata::bXInputDevice
Uint8 bXInputDevice
Definition: SDL_dxjoystick_c.h:143
dwFlags
DWORD dwFlags
Definition: SDL_dxjoystick_c.h:93
XINPUT_GAMEPAD_EX::wButtons
WORD wButtons
Definition: SDL_dxjoystick_c.h:61
SDL_XInputVersion
DWORD SDL_XInputVersion
XINPUT_GAMEPAD_EX::sThumbRY
SHORT sThumbRY
Definition: SDL_dxjoystick_c.h:67
pVibration
XINPUT_VIBRATION * pVibration
Definition: SDL_dxjoystick_c.h:88
joystick_hwdata::bXInputHaptic
Uint8 bXInputHaptic
Definition: SDL_dxjoystick_c.h:144
joystick_hwdata::NumSliders
int NumSliders
Definition: SDL_dxjoystick_c.h:140
WIN_LoadXInputDLL
int WIN_LoadXInputDLL(void)
SDL_XInputGetCapabilities
XInputGetCapabilities_t SDL_XInputGetCapabilities
Uint8
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:129
DWORD
typedef DWORD(WINAPI *XInputGetState_t)(DWORD dwUserIndex
SDL_JoystickGUID
Definition: SDL_joystick.h:68
HAT
Definition: SDL_dxjoystick_c.h:116
SDL_XInputGetState
XInputGetState_t SDL_XInputGetState
joystick_hwdata::XInputState
XINPUT_STATE_EX XInputState[2]
Definition: SDL_dxjoystick_c.h:147
XINPUT_GAMEPAD_EX
Definition: SDL_dxjoystick_c.h:59
input_t
Definition: SDL_dxjoystick_c.h:118
XINPUT_GAMEPAD_EX::sThumbLX
SHORT sThumbLX
Definition: SDL_dxjoystick_c.h:64
XINPUT_GAMEPAD_EX::bRightTrigger
BYTE bRightTrigger
Definition: SDL_dxjoystick_c.h:63