mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-19 01:38:12 +00:00
Free the joystick player index when the joystick is removed
This commit is contained in:
@@ -947,6 +947,7 @@ static void UpdateEventsForDeviceRemoval()
|
||||
void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
|
||||
{
|
||||
SDL_Joystick *joystick;
|
||||
int player_index;
|
||||
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
SDL_Event event;
|
||||
@@ -969,6 +970,13 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_LockJoysticks();
|
||||
player_index = SDL_GetPlayerIndexForJoystickID(device_instance);
|
||||
if (player_index >= 0) {
|
||||
SDL_joystick_players[player_index] = -1;
|
||||
}
|
||||
SDL_UnlockJoysticks();
|
||||
}
|
||||
|
||||
int
|
||||
|
@@ -245,9 +245,6 @@ HIDAPI_DriverXbox360W_UpdateDevice(SDL_HIDAPI_Device *device)
|
||||
|
||||
HIDAPI_JoystickConnected(device, &joystickID);
|
||||
|
||||
/* Set the controller LED */
|
||||
SetSlotLED(device->dev, joystickID);
|
||||
|
||||
} else if (device->num_joysticks > 0) {
|
||||
HIDAPI_JoystickDisconnected(device, device->joysticks[0]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user