From a7dede7e366d0b2653c99b371afc67727f7a3928 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 27 Nov 2020 10:44:51 -0800 Subject: [PATCH] Re-enable axis correlation for raw input controllers, for twin stick shooters that don't need face buttons --- src/joystick/windows/SDL_rawinputjoystick.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 9d63487a3..8dd47c0d2 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -63,6 +63,7 @@ typedef struct WindowsGamingInputGamepadState WindowsGamingInputGamepadState; #if defined(SDL_JOYSTICK_RAWINPUT_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT_WGI) #define SDL_JOYSTICK_RAWINPUT_MATCHING +#define SDL_JOYSTICK_RAWINPUT_MATCH_AXES #endif /*#define DEBUG_RAWINPUT*/ @@ -364,6 +365,10 @@ RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, *slot_idx = 0; + if (!state->any_data) { + return SDL_FALSE; + } + match_count = 0; for (user_index = 0; user_index < XUSER_MAX_COUNT; ++user_index) { if (!xinput_state[user_index].used && RAWINPUT_XInputSlotMatches(state, user_index)) { @@ -376,10 +381,7 @@ RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id, /* Only return a match if we match exactly one, and we have some non-zero data (buttons or axes) that matched. Note that we're still invalidating *other* potential correlations if we have more than one match or we have no data. */ - if (match_count == 1 && state->any_data) { - return SDL_TRUE; - } - return SDL_FALSE; + return (match_count == 1) ? SDL_TRUE : SDL_FALSE; } #endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ @@ -579,6 +581,10 @@ RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *state, Uint8 *corr { int match_count; + if (!state->any_data) { + return SDL_FALSE; + } + match_count = 0; for (int user_index = 0; user_index < wgi_state.per_gamepad_count; ++user_index) { WindowsGamingInputGamepadState *gamepad_state = wgi_state.per_gamepad[user_index]; @@ -592,10 +598,7 @@ RAWINPUT_GuessWindowsGamingInputSlot(const WindowsMatchState *state, Uint8 *corr /* Only return a match if we match exactly one, and we have some non-zero data (buttons or axes) that matched. Note that we're still invalidating *other* potential correlations if we have more than one match or we have no data. */ - if (match_count == 1 && state->any_data) { - return SDL_TRUE; - } - return SDL_FALSE; + return (match_count == 1) ? SDL_TRUE : SDL_FALSE; } static void