Android: prevent removing joystick if SDL hasn't been initialized yet

This commit is contained in:
Sylvain
2026-06-09 06:36:07 +02:00
committed by Sam Lantinga
parent 3f80c0b82a
commit 9986c89da0

View File

@@ -497,6 +497,12 @@ void Android_RemoveJoystick(int device_id)
SDL_joylist_item *item = SDL_joylist;
SDL_joylist_item *prev = NULL;
// Java might notify us about joysticks being removed before joysticks have
// been initialized.
if (!SDL_JoysticksInitialized()) {
return;
}
SDL_LockJoysticks();
// Don't call JoystickByDeviceId here or there'll be an infinite loop!