mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-06 18:06:26 +00:00
Use XINPUT_STATE instead of XINPUT_STATE_EX (thanks Andrew!)
XINPUT_STATE_EX isn't actually a thing, we can just use the normal XINPUT_STATE
Fixes https://github.com/libsdl-org/SDL/issues/2797
(cherry picked from commit e8f4045d0b
)
This commit is contained in:
@@ -1806,16 +1806,6 @@ elseif(WINDOWS)
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <xinput.h>
|
#include <xinput.h>
|
||||||
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_H)
|
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_H)
|
||||||
check_c_source_compiles("
|
|
||||||
#include <windows.h>
|
|
||||||
#include <xinput.h>
|
|
||||||
XINPUT_GAMEPAD_EX x1;
|
|
||||||
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_GAMEPAD_EX)
|
|
||||||
check_c_source_compiles("
|
|
||||||
#include <windows.h>
|
|
||||||
#include <xinput.h>
|
|
||||||
XINPUT_STATE_EX s1;
|
|
||||||
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_STATE_EX)
|
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
#include <windows.gaming.input.h>
|
#include <windows.gaming.input.h>
|
||||||
|
@@ -242,9 +242,6 @@
|
|||||||
#cmakedefine HAVE_ROAPI_H @HAVE_ROAPI_H@
|
#cmakedefine HAVE_ROAPI_H @HAVE_ROAPI_H@
|
||||||
#cmakedefine HAVE_SHELLSCALINGAPI_H @HAVE_SHELLSCALINGAPI_H@
|
#cmakedefine HAVE_SHELLSCALINGAPI_H @HAVE_SHELLSCALINGAPI_H@
|
||||||
|
|
||||||
#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@
|
|
||||||
#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@
|
|
||||||
|
|
||||||
#cmakedefine USE_POSIX_SPAWN @USE_POSIX_SPAWN@
|
#cmakedefine USE_POSIX_SPAWN @USE_POSIX_SPAWN@
|
||||||
|
|
||||||
/* SDL internal assertion support */
|
/* SDL internal assertion support */
|
||||||
|
@@ -163,28 +163,8 @@ extern "C" {
|
|||||||
|
|
||||||
/* typedef's for XInput structs we use */
|
/* typedef's for XInput structs we use */
|
||||||
|
|
||||||
#ifndef HAVE_XINPUT_GAMEPAD_EX
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
WORD wButtons;
|
|
||||||
BYTE bLeftTrigger;
|
|
||||||
BYTE bRightTrigger;
|
|
||||||
SHORT sThumbLX;
|
|
||||||
SHORT sThumbLY;
|
|
||||||
SHORT sThumbRX;
|
|
||||||
SHORT sThumbRY;
|
|
||||||
DWORD dwPaddingReserved;
|
|
||||||
} XINPUT_GAMEPAD_EX;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_XINPUT_STATE_EX
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
DWORD dwPacketNumber;
|
|
||||||
XINPUT_GAMEPAD_EX Gamepad;
|
|
||||||
} XINPUT_STATE_EX;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
/* This is the same as XINPUT_BATTERY_INFORMATION, but always defined instead of just if WIN32_WINNT >= _WIN32_WINNT_WIN8 */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
BYTE BatteryType;
|
BYTE BatteryType;
|
||||||
@@ -204,6 +184,12 @@ typedef struct
|
|||||||
SHORT sThumbRY;
|
SHORT sThumbRY;
|
||||||
} XINPUT_GAMEPAD;
|
} XINPUT_GAMEPAD;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
DWORD dwPacketNumber;
|
||||||
|
XINPUT_GAMEPAD Gamepad;
|
||||||
|
} XINPUT_STATE;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
WORD wLeftMotorSpeed;
|
WORD wLeftMotorSpeed;
|
||||||
@@ -224,7 +210,7 @@ typedef struct
|
|||||||
/* Forward decl's for XInput API's we load dynamically and use if available */
|
/* Forward decl's for XInput API's we load dynamically and use if available */
|
||||||
typedef DWORD(WINAPI *XInputGetState_t)(
|
typedef DWORD(WINAPI *XInputGetState_t)(
|
||||||
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
|
DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */
|
||||||
XINPUT_STATE_EX *pState /* [out] Receives the current state */
|
XINPUT_STATE *pState /* [out] Receives the current state */
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef DWORD(WINAPI *XInputSetState_t)(
|
typedef DWORD(WINAPI *XInputSetState_t)(
|
||||||
|
@@ -316,7 +316,7 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state
|
|||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
XINPUT_STATE_EX state;
|
XINPUT_STATE state;
|
||||||
XINPUT_BATTERY_INFORMATION_EX battery;
|
XINPUT_BATTERY_INFORMATION_EX battery;
|
||||||
SDL_bool connected; /* Currently has an active XInput device */
|
SDL_bool connected; /* Currently has an active XInput device */
|
||||||
SDL_bool used; /* Is currently mapped to an SDL device */
|
SDL_bool used; /* Is currently mapped to an SDL device */
|
||||||
|
@@ -421,7 +421,7 @@ static void UpdateXInputJoystickBatteryInformation(SDL_Joystick *joystick, XINPU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
|
static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
|
||||||
{
|
{
|
||||||
static WORD s_XInputButtons[] = {
|
static WORD s_XInputButtons[] = {
|
||||||
XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, XINPUT_GAMEPAD_DPAD_LEFT, XINPUT_GAMEPAD_DPAD_RIGHT,
|
XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, XINPUT_GAMEPAD_DPAD_LEFT, XINPUT_GAMEPAD_DPAD_RIGHT,
|
||||||
@@ -448,7 +448,7 @@ static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE_E
|
|||||||
UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation);
|
UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
|
static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
|
||||||
{
|
{
|
||||||
static WORD s_XInputButtons[] = {
|
static WORD s_XInputButtons[] = {
|
||||||
XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y,
|
XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y,
|
||||||
@@ -513,7 +513,7 @@ Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick)
|
|||||||
void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick)
|
void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick)
|
||||||
{
|
{
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
XINPUT_STATE_EX XInputState;
|
XINPUT_STATE XInputState;
|
||||||
XINPUT_BATTERY_INFORMATION_EX XBatteryInformation;
|
XINPUT_BATTERY_INFORMATION_EX XBatteryInformation;
|
||||||
|
|
||||||
if (!XINPUTGETSTATE) {
|
if (!XINPUTGETSTATE) {
|
||||||
|
Reference in New Issue
Block a user