mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-24 20:18:29 +00:00
Send gamepad and joystick removed events when quitting
This helps applications do proper cleanup when reinitializing gamepads, e.g. to reset controller mappings
This commit is contained in:
@@ -1501,12 +1501,20 @@ void SDL_CloseJoystick(SDL_Joystick *joystick)
|
||||
void SDL_QuitJoysticks(void)
|
||||
{
|
||||
int i;
|
||||
SDL_JoystickID *joysticks;
|
||||
|
||||
SDL_LockJoysticks();
|
||||
|
||||
SDL_joysticks_quitting = SDL_TRUE;
|
||||
|
||||
/* Stop the event polling */
|
||||
joysticks = SDL_GetJoysticks(NULL);
|
||||
if (joysticks) {
|
||||
for (i = 0; joysticks[i]; ++i) {
|
||||
SDL_PrivateJoystickRemoved(joysticks[i]);
|
||||
}
|
||||
SDL_free(joysticks);
|
||||
}
|
||||
|
||||
while (SDL_joysticks) {
|
||||
SDL_joysticks->ref_count = 1;
|
||||
SDL_CloseJoystick(SDL_joysticks);
|
||||
|
Reference in New Issue
Block a user