Create a global event lock for hardware that generates events

This prevents ABBA deadlocks caused by taking a hardware resource lock then delivering events at the same time another thread is taking a hardware resource lock from an event watch callback.

Fixes https://github.com/libsdl-org/SDL/issues/15709
This commit is contained in:
Sam Lantinga
2026-06-02 15:29:06 -07:00
parent 75270a4264
commit f9d49358d2
18 changed files with 99 additions and 172 deletions

View File

@@ -117,7 +117,7 @@ static int SDL_HIDAPI_numdrivers = 0;
static SDL_AtomicInt SDL_HIDAPI_updating_devices;
static bool SDL_HIDAPI_hints_changed = false;
static Uint32 SDL_HIDAPI_change_count = 0;
static SDL_HIDAPI_Device *SDL_HIDAPI_devices SDL_GUARDED_BY(SDL_joystick_lock);
static SDL_HIDAPI_Device *SDL_HIDAPI_devices SDL_GUARDED_BY(SDL_event_lock);
static int SDL_HIDAPI_numjoysticks = 0;
static bool SDL_HIDAPI_combine_joycons = true;
static bool initialized = false;