Commit 870e567
committed
Move SDL joystick scanning off the main thread
Setting SDL_HINT_JOYSTICK_THREAD=1 before SDL_InitSubSystem(SDL_INIT_JOYSTICK)
tells SDL2 to run joystick polling and HID device-detection on a dedicated
background thread, rather than processing them inline inside SDL_PollEvent
on the main thread.
Without this hint, every WM_DEVICECHANGE broadcast (which Windows sends when
*any* HID device wakes, sleeps, or pulses the USB bus) causes SDL to walk
every HID device class via SetupAPI / cfgmgr32 from inside SDL_PollEvent,
stalling the frame loop for multiple seconds on machines with many HID
peripherals - especially wireless Logitech mice and keyboards that
periodically pulse the bus. Diagnosed via ProcMon stack capture on one
affected user's machine, with the slow frame's call chain ending in
SDL2.dll -> SETUPAPI.dll -> cfgmgr32.dll -> kernel registry queries against
HKLM\System\CurrentControlSet\Enum\HID\*.
With the hint enabled, that work happens on SDL's own thread and the main
thread just dequeues already-collected events.1 parent f831251 commit 870e567
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1036 | 1036 | | |
1037 | 1037 | | |
1038 | 1038 | | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
1039 | 1046 | | |
1040 | 1047 | | |
1041 | 1048 | | |
| |||
0 commit comments