Backed out minor optimization that prevented correlation_id from being set
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 3554d75..2d10f2c 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -365,10 +365,6 @@ 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)) {
@@ -381,7 +377,10 @@ 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. */
- return (match_count == 1) ? SDL_TRUE : SDL_FALSE;
+ if (match_count == 1 && state->any_data) {
+ return SDL_TRUE;
+ }
+ return SDL_FALSE;
}
#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */
@@ -581,10 +580,6 @@ 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];
@@ -598,7 +593,10 @@ 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. */
- return (match_count == 1) ? SDL_TRUE : SDL_FALSE;
+ if (match_count == 1 && state->any_data) {
+ return SDL_TRUE;
+ }
+ return SDL_FALSE;
}
static void