mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
Clear the old player index slot when moving to a new one
This commit is contained in:
parent
165ccaa85b
commit
4e0fb110c8
@ -146,6 +146,7 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
|
|||||||
SDL_JoystickID existing_instance = SDL_GetJoystickIDForPlayerIndex(player_index);
|
SDL_JoystickID existing_instance = SDL_GetJoystickIDForPlayerIndex(player_index);
|
||||||
SDL_JoystickDriver *driver;
|
SDL_JoystickDriver *driver;
|
||||||
int device_index;
|
int device_index;
|
||||||
|
int existing_player_index;
|
||||||
|
|
||||||
if (player_index < 0) {
|
if (player_index < 0) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
@ -165,6 +166,12 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id)
|
|||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clear the old player index */
|
||||||
|
existing_player_index = SDL_GetPlayerIndexForJoystickID(instance_id);
|
||||||
|
if (existing_player_index >= 0) {
|
||||||
|
SDL_joystick_players[existing_player_index] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
SDL_joystick_players[player_index] = instance_id;
|
SDL_joystick_players[player_index] = instance_id;
|
||||||
|
|
||||||
/* Update the driver with the new index */
|
/* Update the driver with the new index */
|
||||||
|
Loading…
Reference in New Issue
Block a user