From 87e916dd214866af9cfd67eb4618918bc8b0f1b4 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 24 Jun 2023 15:38:38 -0700
Subject: [PATCH] SDL_FindFreePlayerIndex() will always return the next
available player index
Fixes https://github.com/libsdl-org/SDL/issues/7868
---
src/joystick/SDL_joystick.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 463569ae1292..59bb9f83ef7d 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -218,10 +218,10 @@ static int SDL_FindFreePlayerIndex(void)
for (player_index = 0; player_index < SDL_joystick_player_count; ++player_index) {
if (SDL_joystick_players[player_index] == 0) {
- return player_index;
+ break;
}
}
- return -1;
+ return player_index;
}
static int SDL_GetPlayerIndexForJoystickID(SDL_JoystickID instance_id)