Skip to content

Commit d52ba4e

Browse files
authored
Merge pull request scp-fs2open#7491 from Goober5000/fix/freezespace
Move SDL joystick scanning off the main thread
2 parents 434d4fb + 870e567 commit d52ba4e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

code/io/joy-sdl.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,13 @@ namespace joystick
10361036

10371037
mprintf(("Initializing Joystick...\n"));
10381038

1039+
// Run joystick polling and HID device-detection on a dedicated SDL thread
1040+
// instead of the main thread. Without this, WM_DEVICECHANGE broadcasts
1041+
// (caused by wireless HID peripherals waking/sleeping on the USB bus)
1042+
// trigger SDL to re-walk every HID device class via SetupAPI / cfgmgr32
1043+
// from inside SDL_PollEvent, stalling the frame loop for multiple seconds.
1044+
SDL_SetHint(SDL_HINT_JOYSTICK_THREAD, "1");
1045+
10391046
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0)
10401047
{
10411048
mprintf((" Could not initialize joystick: %s\n", SDL_GetError()));

0 commit comments

Comments
 (0)