diff options
Diffstat (limited to '3rdparty/SDL2/src/core/windows')
-rw-r--r-- | 3rdparty/SDL2/src/core/windows/SDL_directx.h | 111 | ||||
-rw-r--r-- | 3rdparty/SDL2/src/core/windows/SDL_windows.c | 207 | ||||
-rw-r--r-- | 3rdparty/SDL2/src/core/windows/SDL_windows.h | 67 | ||||
-rw-r--r-- | 3rdparty/SDL2/src/core/windows/SDL_xinput.c | 139 | ||||
-rw-r--r-- | 3rdparty/SDL2/src/core/windows/SDL_xinput.h | 172 |
5 files changed, 0 insertions, 696 deletions
diff --git a/3rdparty/SDL2/src/core/windows/SDL_directx.h b/3rdparty/SDL2/src/core/windows/SDL_directx.h deleted file mode 100644 index 0533f61edab..00000000000 --- a/3rdparty/SDL2/src/core/windows/SDL_directx.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifndef _SDL_directx_h -#define _SDL_directx_h - -/* Include all of the DirectX 8.0 headers and adds any necessary tweaks */ - -#include "SDL_windows.h" -#include <mmsystem.h> -#ifndef WIN32 -#define WIN32 -#endif -#undef WINNT - -/* Far pointers don't exist in 32-bit code */ -#ifndef FAR -#define FAR -#endif - -/* Error codes not yet included in Win32 API header files */ -#ifndef MAKE_HRESULT -#define MAKE_HRESULT(sev,fac,code) \ - ((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code)))) -#endif - -#ifndef S_OK -#define S_OK (HRESULT)0x00000000L -#endif - -#ifndef SUCCEEDED -#define SUCCEEDED(x) ((HRESULT)(x) >= 0) -#endif -#ifndef FAILED -#define FAILED(x) ((HRESULT)(x)<0) -#endif - -#ifndef E_FAIL -#define E_FAIL (HRESULT)0x80000008L -#endif -#ifndef E_NOINTERFACE -#define E_NOINTERFACE (HRESULT)0x80004002L -#endif -#ifndef E_OUTOFMEMORY -#define E_OUTOFMEMORY (HRESULT)0x8007000EL -#endif -#ifndef E_INVALIDARG -#define E_INVALIDARG (HRESULT)0x80070057L -#endif -#ifndef E_NOTIMPL -#define E_NOTIMPL (HRESULT)0x80004001L -#endif -#ifndef REGDB_E_CLASSNOTREG -#define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L -#endif - -/* Severity codes */ -#ifndef SEVERITY_ERROR -#define SEVERITY_ERROR 1 -#endif - -/* Error facility codes */ -#ifndef FACILITY_WIN32 -#define FACILITY_WIN32 7 -#endif - -#ifndef FIELD_OFFSET -#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field)) -#endif - -/* DirectX headers (if it isn't included, I haven't tested it yet) - */ -/* We need these defines to mark what version of DirectX API we use */ -#define DIRECTDRAW_VERSION 0x0700 -#define DIRECTSOUND_VERSION 0x0800 -#define DIRECTINPUT_VERSION 0x0800 /* Need version 7 for force feedback. Need version 8 so IDirectInput8_EnumDevices doesn't leak like a sieve... */ - -#ifdef HAVE_DDRAW_H -#include <ddraw.h> -#endif -#ifdef HAVE_DSOUND_H -#include <dsound.h> -#endif -#ifdef HAVE_DINPUT_H -#include <dinput.h> -#else -typedef struct { int unused; } DIDEVICEINSTANCE; -#endif - -#endif /* _SDL_directx_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/src/core/windows/SDL_windows.c b/3rdparty/SDL2/src/core/windows/SDL_windows.c deleted file mode 100644 index 6433fe26f3c..00000000000 --- a/3rdparty/SDL2/src/core/windows/SDL_windows.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#if defined(__WIN32__) || defined(__WINRT__) - -#include "SDL_windows.h" -#include "SDL_error.h" -#include "SDL_assert.h" - -#include <objbase.h> /* for CoInitialize/CoUninitialize (Win32 only) */ - -#ifndef _WIN32_WINNT_VISTA -#define _WIN32_WINNT_VISTA 0x0600 -#endif - - -/* Sets an error message based on GetLastError() */ -int -WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) -{ - TCHAR buffer[1024]; - char *message; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0, - buffer, SDL_arraysize(buffer), NULL); - message = WIN_StringToUTF8(buffer); - SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message); - SDL_free(message); - return -1; -} - -/* Sets an error message based on GetLastError() */ -int -WIN_SetError(const char *prefix) -{ - return WIN_SetErrorFromHRESULT(prefix, GetLastError()); -} - -HRESULT -WIN_CoInitialize(void) -{ - /* SDL handles any threading model, so initialize with the default, which - is compatible with OLE and if that doesn't work, try multi-threaded mode. - - If you need multi-threaded mode, call CoInitializeEx() before SDL_Init() - */ -#ifdef __WINRT__ - /* DLudwig: On WinRT, it is assumed that COM was initialized in main(). - CoInitializeEx is available (not CoInitialize though), however - on WinRT, main() is typically declared with the [MTAThread] - attribute, which, AFAIK, should initialize COM. - */ - return S_OK; -#else - HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - if (hr == RPC_E_CHANGED_MODE) { - hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); - } - - /* S_FALSE means success, but someone else already initialized. */ - /* You still need to call CoUninitialize in this case! */ - if (hr == S_FALSE) { - return S_OK; - } - - return hr; -#endif -} - -void -WIN_CoUninitialize(void) -{ -#ifndef __WINRT__ - CoUninitialize(); -#endif -} - -#ifndef __WINRT__ -static BOOL -IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) -{ - OSVERSIONINFOEXW osvi; - DWORDLONG const dwlConditionMask = VerSetConditionMask( - VerSetConditionMask( - VerSetConditionMask( - 0, VER_MAJORVERSION, VER_GREATER_EQUAL ), - VER_MINORVERSION, VER_GREATER_EQUAL ), - VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL ); - - SDL_zero(osvi); - osvi.dwOSVersionInfoSize = sizeof(osvi); - osvi.dwMajorVersion = wMajorVersion; - osvi.dwMinorVersion = wMinorVersion; - osvi.wServicePackMajor = wServicePackMajor; - - return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; -} -#endif - -BOOL WIN_IsWindowsVistaOrGreater() -{ -#ifdef __WINRT__ - return TRUE; -#else - return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0); -#endif -} - -/* -WAVExxxCAPS gives you 31 bytes for the device name, and just truncates if it's -longer. However, since WinXP, you can use the WAVExxxCAPS2 structure, which -will give you a name GUID. The full name is in the Windows Registry under -that GUID, located here: HKLM\System\CurrentControlSet\Control\MediaCategories - -Note that drivers can report GUID_NULL for the name GUID, in which case, -Windows makes a best effort to fill in those 31 bytes in the usual place. -This info summarized from MSDN: - -http://web.archive.org/web/20131027093034/http://msdn.microsoft.com/en-us/library/windows/hardware/ff536382(v=vs.85).aspx - -Always look this up in the registry if possible, because the strings are -different! At least on Win10, I see "Yeti Stereo Microphone" in the -Registry, and a unhelpful "Microphone(Yeti Stereo Microph" in winmm. Sigh. - -(Also, DirectSound shouldn't be limited to 32 chars, but its device enum -has the same problem.) -*/ -char * -WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) -{ -#if __WINRT__ - return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP, go with what we've got. */ -#else - static const GUID nullguid = { 0 }; - const unsigned char *ptr; - char keystr[128]; - WCHAR *strw = NULL; - SDL_bool rc; - HKEY hkey; - DWORD len = 0; - char *retval = NULL; - - if (SDL_memcmp(guid, &nullguid, sizeof (*guid)) == 0) { - return WIN_StringToUTF8(name); /* No GUID, go with what we've got. */ - } - - ptr = (const unsigned char *) guid; - SDL_snprintf(keystr, sizeof (keystr), - "System\\CurrentControlSet\\Control\\MediaCategories\\{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}", - ptr[3], ptr[2], ptr[1], ptr[0], ptr[5], ptr[4], ptr[7], ptr[6], - ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]); - - strw = WIN_UTF8ToString(keystr); - rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS); - SDL_free(strw); - if (!rc) { - return WIN_StringToUTF8(name); /* oh well. */ - } - - rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, NULL, &len) == ERROR_SUCCESS); - if (!rc) { - RegCloseKey(hkey); - return WIN_StringToUTF8(name); /* oh well. */ - } - - strw = (WCHAR *) SDL_malloc(len + sizeof (WCHAR)); - if (!strw) { - RegCloseKey(hkey); - return WIN_StringToUTF8(name); /* oh well. */ - } - - rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, (LPBYTE) strw, &len) == ERROR_SUCCESS); - RegCloseKey(hkey); - if (!rc) { - SDL_free(strw); - return WIN_StringToUTF8(name); /* oh well. */ - } - - strw[len / 2] = 0; /* make sure it's null-terminated. */ - - retval = WIN_StringToUTF8(strw); - SDL_free(strw); - return retval ? retval : WIN_StringToUTF8(name); -#endif /* if __WINRT__ / else */ -} - -#endif /* __WIN32__ || __WINRT__ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/src/core/windows/SDL_windows.h b/3rdparty/SDL2/src/core/windows/SDL_windows.h deleted file mode 100644 index 0f67e4be5e7..00000000000 --- a/3rdparty/SDL2/src/core/windows/SDL_windows.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* This is an include file for windows.h with the SDL build settings */ - -#ifndef _INCLUDED_WINDOWS_H -#define _INCLUDED_WINDOWS_H - -#if defined(__WIN32__) -#define WIN32_LEAN_AND_MEAN -#define STRICT -#ifndef UNICODE -#define UNICODE 1 -#endif -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ -#endif - -#include <windows.h> - -/* Routines to convert from UTF8 to native Windows text */ -#if UNICODE -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) -#else -/* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) -#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) -#endif - -/* Sets an error message based on a given HRESULT */ -extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); - -/* Sets an error message based on GetLastError(). Always return -1. */ -extern int WIN_SetError(const char *prefix); - -/* Wrap up the oddities of CoInitialize() into a common function. */ -extern HRESULT WIN_CoInitialize(void); -extern void WIN_CoUninitialize(void); - -/* Returns SDL_TRUE if we're running on Windows Vista and newer */ -extern BOOL WIN_IsWindowsVistaOrGreater(); - -/* You need to SDL_free() the result of this call. */ -extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid); - -#endif /* _INCLUDED_WINDOWS_H */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/src/core/windows/SDL_xinput.c b/3rdparty/SDL2/src/core/windows/SDL_xinput.c deleted file mode 100644 index 355cd83436d..00000000000 --- a/3rdparty/SDL2/src/core/windows/SDL_xinput.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#include "SDL_assert.h" -#include "SDL_xinput.h" - - -#ifdef HAVE_XINPUT_H - -XInputGetState_t SDL_XInputGetState = NULL; -XInputSetState_t SDL_XInputSetState = NULL; -XInputGetCapabilities_t SDL_XInputGetCapabilities = NULL; -XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation = NULL; -DWORD SDL_XInputVersion = 0; - -static HANDLE s_pXInputDLL = 0; -static int s_XInputDLLRefCount = 0; - - -#ifdef __WINRT__ - -int -WIN_LoadXInputDLL(void) -{ - /* Getting handles to system dlls (via LoadLibrary and its variants) is not - * supported on WinRT, thus, pointers to XInput's functions can't be - * retrieved via GetProcAddress. - * - * When on WinRT, assume that XInput is already loaded, and directly map - * its XInput.h-declared functions to the SDL_XInput* set of function - * pointers. - * - * Side-note: XInputGetStateEx is not available for use in WinRT. - * This seems to mean that support for the guide button is not available - * in WinRT, unfortunately. - */ - SDL_XInputGetState = (XInputGetState_t)XInputGetState; - SDL_XInputSetState = (XInputSetState_t)XInputSetState; - SDL_XInputGetCapabilities = (XInputGetCapabilities_t)XInputGetCapabilities; - SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)XInputGetBatteryInformation; - - /* XInput 1.4 ships with Windows 8 and 8.1: */ - SDL_XInputVersion = (1 << 16) | 4; - - return 0; -} - -void -WIN_UnloadXInputDLL(void) -{ -} - -#else /* !__WINRT__ */ - -int -WIN_LoadXInputDLL(void) -{ - DWORD version = 0; - - if (s_pXInputDLL) { - SDL_assert(s_XInputDLLRefCount > 0); - s_XInputDLLRefCount++; - return 0; /* already loaded */ - } - - version = (1 << 16) | 4; - s_pXInputDLL = LoadLibrary(L"XInput1_4.dll"); /* 1.4 Ships with Windows 8. */ - if (!s_pXInputDLL) { - version = (1 << 16) | 3; - s_pXInputDLL = LoadLibrary(L"XInput1_3.dll"); /* 1.3 can be installed as a redistributable component. */ - } - if (!s_pXInputDLL) { - s_pXInputDLL = LoadLibrary(L"bin\\XInput1_3.dll"); - } - if (!s_pXInputDLL) { - /* "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.) */ - s_pXInputDLL = LoadLibrary(L"XInput9_1_0.dll"); - } - if (!s_pXInputDLL) { - return -1; - } - - SDL_assert(s_XInputDLLRefCount == 0); - SDL_XInputVersion = version; - s_XInputDLLRefCount = 1; - - /* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */ - SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, (LPCSTR)100); - if (!SDL_XInputGetState) { - SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetState"); - } - SDL_XInputSetState = (XInputSetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputSetState"); - SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetCapabilities"); - SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress( (HMODULE)s_pXInputDLL, "XInputGetBatteryInformation" ); - if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) { - WIN_UnloadXInputDLL(); - return -1; - } - - return 0; -} - -void -WIN_UnloadXInputDLL(void) -{ - if (s_pXInputDLL) { - SDL_assert(s_XInputDLLRefCount > 0); - if (--s_XInputDLLRefCount == 0) { - FreeLibrary(s_pXInputDLL); - s_pXInputDLL = NULL; - } - } else { - SDL_assert(s_XInputDLLRefCount == 0); - } -} - -#endif /* __WINRT__ */ -#endif /* HAVE_XINPUT_H */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/3rdparty/SDL2/src/core/windows/SDL_xinput.h b/3rdparty/SDL2/src/core/windows/SDL_xinput.h deleted file mode 100644 index 67f8fdc1f8f..00000000000 --- a/3rdparty/SDL2/src/core/windows/SDL_xinput.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifndef _SDL_xinput_h -#define _SDL_xinput_h - -#ifdef HAVE_XINPUT_H - -#include "SDL_windows.h" -#include <xinput.h> - -#ifndef XUSER_MAX_COUNT -#define XUSER_MAX_COUNT 4 -#endif -#ifndef XUSER_INDEX_ANY -#define XUSER_INDEX_ANY 0x000000FF -#endif -#ifndef XINPUT_CAPS_FFB_SUPPORTED -#define XINPUT_CAPS_FFB_SUPPORTED 0x0001 -#endif - -#ifndef XINPUT_DEVSUBTYPE_UNKNOWN -#define XINPUT_DEVSUBTYPE_UNKNOWN 0x00 -#endif -#ifndef XINPUT_DEVSUBTYPE_GAMEPAD -#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 -#endif -#ifndef XINPUT_DEVSUBTYPE_WHEEL -#define XINPUT_DEVSUBTYPE_WHEEL 0x02 -#endif -#ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK -#define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03 -#endif -#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK -#define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04 -#endif -#ifndef XINPUT_DEVSUBTYPE_DANCE_PAD -#define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05 -#endif -#ifndef XINPUT_DEVSUBTYPE_GUITAR -#define XINPUT_DEVSUBTYPE_GUITAR 0x06 -#endif -#ifndef XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE -#define XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE 0x07 -#endif -#ifndef XINPUT_DEVSUBTYPE_DRUM_KIT -#define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08 -#endif -#ifndef XINPUT_DEVSUBTYPE_GUITAR_BASS -#define XINPUT_DEVSUBTYPE_GUITAR_BASS 0x0B -#endif -#ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD -#define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13 -#endif - -#ifndef XINPUT_GAMEPAD_GUIDE -#define XINPUT_GAMEPAD_GUIDE 0x0400 -#endif - -#ifndef BATTERY_DEVTYPE_GAMEPAD -#define BATTERY_DEVTYPE_GAMEPAD 0x00 -#endif -#ifndef BATTERY_TYPE_WIRED -#define BATTERY_TYPE_WIRED 0x01 -#endif - -#ifndef BATTERY_TYPE_UNKNOWN -#define BATTERY_TYPE_UNKNOWN 0xFF -#endif -#ifndef BATTERY_LEVEL_EMPTY -#define BATTERY_LEVEL_EMPTY 0x00 -#endif -#ifndef BATTERY_LEVEL_LOW -#define BATTERY_LEVEL_LOW 0x01 -#endif -#ifndef BATTERY_LEVEL_MEDIUM -#define BATTERY_LEVEL_MEDIUM 0x02 -#endif -#ifndef BATTERY_LEVEL_FULL -#define BATTERY_LEVEL_FULL 0x03 -#endif - -/* typedef's for XInput structs we use */ -typedef struct -{ - WORD wButtons; - BYTE bLeftTrigger; - BYTE bRightTrigger; - SHORT sThumbLX; - SHORT sThumbLY; - SHORT sThumbRX; - SHORT sThumbRY; - DWORD dwPaddingReserved; -} XINPUT_GAMEPAD_EX; - -typedef struct -{ - DWORD dwPacketNumber; - XINPUT_GAMEPAD_EX Gamepad; -} XINPUT_STATE_EX; - -typedef struct -{ - BYTE BatteryType; - BYTE BatteryLevel; -} XINPUT_BATTERY_INFORMATION_EX; - -/* Forward decl's for XInput API's we load dynamically and use if available */ -typedef DWORD (WINAPI *XInputGetState_t) - ( - DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ - XINPUT_STATE_EX* pState /* [out] Receives the current state */ - ); - -typedef DWORD (WINAPI *XInputSetState_t) - ( - DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ - XINPUT_VIBRATION* pVibration /* [in, out] The vibration information to send to the controller */ - ); - -typedef DWORD (WINAPI *XInputGetCapabilities_t) - ( - DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ - DWORD dwFlags, /* [in] Input flags that identify the device type */ - XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */ - ); - -typedef DWORD (WINAPI *XInputGetBatteryInformation_t) - ( - DWORD dwUserIndex, - BYTE devType, - XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation - ); - -extern int WIN_LoadXInputDLL(void); -extern void WIN_UnloadXInputDLL(void); - -extern XInputGetState_t SDL_XInputGetState; -extern XInputSetState_t SDL_XInputSetState; -extern XInputGetCapabilities_t SDL_XInputGetCapabilities; -extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation; -extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ - -#define XINPUTGETSTATE SDL_XInputGetState -#define XINPUTSETSTATE SDL_XInputSetState -#define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities -#define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation - -#endif /* HAVE_XINPUT_H */ - -#endif /* _SDL_xinput_h */ - -/* vi: set ts=4 sw=4 expandtab: */ |