SDL_xinput.h (4083B)
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2014 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_internal.h" 22 23#ifndef _SDL_xinput_h 24#define _SDL_xinput_h 25 26#ifdef HAVE_XINPUT_H 27 28#include "SDL_windows.h" 29#include <xinput.h> 30 31#ifndef XUSER_MAX_COUNT 32#define XUSER_MAX_COUNT 4 33#endif 34#ifndef XUSER_INDEX_ANY 35#define XUSER_INDEX_ANY 0x000000FF 36#endif 37#ifndef XINPUT_CAPS_FFB_SUPPORTED 38#define XINPUT_CAPS_FFB_SUPPORTED 0x0001 39#endif 40 41#ifndef XINPUT_DEVSUBTYPE_UNKNOWN 42#define XINPUT_DEVSUBTYPE_UNKNOWN 0x00 43#endif 44#ifndef XINPUT_DEVSUBTYPE_GAMEPAD 45#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 46#endif 47#ifndef XINPUT_DEVSUBTYPE_WHEEL 48#define XINPUT_DEVSUBTYPE_WHEEL 0x02 49#endif 50#ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK 51#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03 52#endif 53#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK 54#define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04 55#endif 56#ifndef XINPUT_DEVSUBTYPE_DANCE_PAD 57#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05 58#endif 59#ifndef XINPUT_DEVSUBTYPE_GUITAR 60#define XINPUT_DEVSUBTYPE_GUITAR 0x06 61#endif 62#ifndef XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE 63#define XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE 0x07 64#endif 65#ifndef XINPUT_DEVSUBTYPE_DRUM_KIT 66#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08 67#endif 68#ifndef XINPUT_DEVSUBTYPE_GUITAR_BASS 69#define XINPUT_DEVSUBTYPE_GUITAR_BASS 0x0B 70#endif 71#ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD 72#define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13 73#endif 74 75#ifndef XINPUT_GAMEPAD_GUIDE 76#define XINPUT_GAMEPAD_GUIDE 0x0400 77#endif 78 79/* typedef's for XInput structs we use */ 80typedef struct 81{ 82 WORD wButtons; 83 BYTE bLeftTrigger; 84 BYTE bRightTrigger; 85 SHORT sThumbLX; 86 SHORT sThumbLY; 87 SHORT sThumbRX; 88 SHORT sThumbRY; 89 DWORD dwPaddingReserved; 90} XINPUT_GAMEPAD_EX; 91 92typedef struct 93{ 94 DWORD dwPacketNumber; 95 XINPUT_GAMEPAD_EX Gamepad; 96} XINPUT_STATE_EX; 97 98/* Forward decl's for XInput API's we load dynamically and use if available */ 99typedef DWORD (WINAPI *XInputGetState_t) 100 ( 101 DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ 102 XINPUT_STATE_EX* pState /* [out] Receives the current state */ 103 ); 104 105typedef DWORD (WINAPI *XInputSetState_t) 106 ( 107 DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ 108 XINPUT_VIBRATION* pVibration /* [in, out] The vibration information to send to the controller */ 109 ); 110 111typedef DWORD (WINAPI *XInputGetCapabilities_t) 112 ( 113 DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ 114 DWORD dwFlags, /* [in] Input flags that identify the device type */ 115 XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */ 116 ); 117 118extern int WIN_LoadXInputDLL(void); 119extern void WIN_UnloadXInputDLL(void); 120 121extern XInputGetState_t SDL_XInputGetState; 122extern XInputSetState_t SDL_XInputSetState; 123extern XInputGetCapabilities_t SDL_XInputGetCapabilities; 124extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ 125 126#define XINPUTGETSTATE SDL_XInputGetState 127#define XINPUTSETSTATE SDL_XInputSetState 128#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities 129 130#endif /* HAVE_XINPUT_H */ 131 132#endif /* _SDL_xinput_h */ 133 134/* vi: set ts=4 sw=4 expandtab: */