Windows: SDL DirectInput enumeration in sceVideoOutOpen blocks forever on a HID device, so video out never opens #1042

Closed
opened 2026-10-07 03:09:33 +00:00 by frankea · 2 comments
frankea commented 2026-10-07 03:09:33 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-07T03:09:33Z.


On a Windows 11 machine with several vendor HID devices, VideoOutDriver's SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) never returns. The main thread sits in SDL's DirectInput joystick enumeration, in a DeviceIoControl issued by HidD_GetProductString for one of the devices. Every title reaches this call through sceVideoOutOpen, so nothing gets past video-out open on such a machine. The code is on main (0c952fe5) and is not specific to one title.

Environment

  • Windows 11 10.0.26200, AMD Ryzen 7 5800X, NVIDIA RTX 4090 (driver 616.92), MinGW-w64 GCC 15.2.0 r7, bundled SDL2 at 4b69833b.
  • Peripherals present: Corsair keyboard and headset with iCUE virtual HID devices, SteelSeries mouse and headset, an NZXT controller, an ITE RGB controller. No game controller connected.

Reproduction

guest_video_out_wqhd_detection times out at 20 s on every run (CI-equivalent build: -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON). The other 377 tests pass, with 0 skipped. The test does nothing device-related; it fails because sceVideoOutOpen constructs VideoOutDriver.

gdb attached to the hung process, main thread:

#0  ntdll!ZwDeviceIoControlFile
#1  KERNELBASE!DeviceIoControl
#2  KERNEL32!DeviceIoControl
#3  hid!HidD_SetFeature
#4  hid!HidD_GetProductString
#5  dinput8.dll
#6  dinput8!DirectInput8Create
#7  dinput8!DirectInput8Create
#8  dinput8.dll
#9  dinput8.dll
#10 SDL_DINPUT_JoystickDetect   (libSceAgcDriver.prx)
#11 WINDOWS_JoystickDetect
#12 WINDOWS_JoystickInit
#13 SDL_JoystickInit

Only [time] scheduler tick raised to 0.5 ms is printed before the hang.

  • With SDL_DIRECTINPUT_ENABLED=0 in the environment the test passes in 0.13 s.
  • Started with schtasks /IT in the logged-on user's session instead of over SSH, it hangs the same way, so it is not a session-0 effect.
  • Upstream CI does not see it because the runner has no such HID devices.

Notes

SDL's own SDL_DINPUT_JoystickInit guards the DirectInput path with SDL_HINT_DIRECTINPUT_ENABLED and comments: "In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers." Here it does not return at all.

PadInput::openFirstAvailableController already sets SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, and the controllers the project documents (docs/user/INPUT_MAPPING.md) are covered by SDL's XInput, RawInput and HIDAPI backends. Possible directions, none chosen here:

  • Set SDL_HINT_DIRECTINPUT_ENABLED to 0 in VideoOutDriver before SDL_InitSubSystem, so DirectInput-only devices are not detected but video out always opens.
  • Initialise SDL_INIT_GAMECONTROLLER on a separate thread with a timeout and continue without pads if it does not finish.
  • Document SDL_DIRECTINPUT_ENABLED=0 as a workaround in docs/user/INPUT_MAPPING.md.

I can test a change for any of these on this machine.

Investigated with AI assistance (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5738739877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1042). Originally posted by [frankea](https://github.com/frankea) on 2026-10-07T03:09:33Z. --- On a Windows 11 machine with several vendor HID devices, `VideoOutDriver`'s `SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER)` never returns. The main thread sits in SDL's DirectInput joystick enumeration, in a `DeviceIoControl` issued by `HidD_GetProductString` for one of the devices. Every title reaches this call through `sceVideoOutOpen`, so nothing gets past video-out open on such a machine. The code is on `main` (`0c952fe5`) and is not specific to one title. ### Environment - Windows 11 10.0.26200, AMD Ryzen 7 5800X, NVIDIA RTX 4090 (driver 616.92), MinGW-w64 GCC 15.2.0 r7, bundled SDL2 at `4b69833b`. - Peripherals present: Corsair keyboard and headset with iCUE virtual HID devices, SteelSeries mouse and headset, an NZXT controller, an ITE RGB controller. No game controller connected. ### Reproduction `guest_video_out_wqhd_detection` times out at 20 s on every run (CI-equivalent build: `-G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON`). The other 377 tests pass, with 0 skipped. The test does nothing device-related; it fails because `sceVideoOutOpen` constructs `VideoOutDriver`. gdb attached to the hung process, main thread: ``` #0 ntdll!ZwDeviceIoControlFile #1 KERNELBASE!DeviceIoControl #2 KERNEL32!DeviceIoControl #3 hid!HidD_SetFeature #4 hid!HidD_GetProductString #5 dinput8.dll #6 dinput8!DirectInput8Create #7 dinput8!DirectInput8Create #8 dinput8.dll #9 dinput8.dll #10 SDL_DINPUT_JoystickDetect (libSceAgcDriver.prx) #11 WINDOWS_JoystickDetect #12 WINDOWS_JoystickInit #13 SDL_JoystickInit ``` Only `[time] scheduler tick raised to 0.5 ms` is printed before the hang. - With `SDL_DIRECTINPUT_ENABLED=0` in the environment the test passes in 0.13 s. - Started with `schtasks /IT` in the logged-on user's session instead of over SSH, it hangs the same way, so it is not a session-0 effect. - Upstream CI does not see it because the runner has no such HID devices. ### Notes SDL's own `SDL_DINPUT_JoystickInit` guards the DirectInput path with `SDL_HINT_DIRECTINPUT_ENABLED` and comments: "In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers." Here it does not return at all. `PadInput::openFirstAvailableController` already sets `SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE`, and the controllers the project documents (`docs/user/INPUT_MAPPING.md`) are covered by SDL's XInput, RawInput and HIDAPI backends. Possible directions, none chosen here: - Set `SDL_HINT_DIRECTINPUT_ENABLED` to `0` in `VideoOutDriver` before `SDL_InitSubSystem`, so DirectInput-only devices are not detected but video out always opens. - Initialise `SDL_INIT_GAMECONTROLLER` on a separate thread with a timeout and continue without pads if it does not finish. - Document `SDL_DIRECTINPUT_ENABLED=0` as a workaround in `docs/user/INPUT_MAPPING.md`. I can test a change for any of these on this machine. Investigated with AI assistance (Claude Code).
MarcZX10 commented 2026-10-09 08:54:57 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T08:54:57Z.


Your issue report offered to test a change. PR #1050 is now the sole open PR for this fix; the other overlapping PR was closed. A Windows test on a machine with many HID devices passed but did not reproduce the hang, so confirmation on the original reproducing setup is still needed. Could you test #1050 with the default environment (without SDL_DIRECTINPUT_ENABLED=0) and report whether sceVideoOutOpen returns? That would answer the remaining question before merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077708314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1042#issuecomment-6077708314). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T08:54:57Z. --- Your issue report offered to test a change. PR #1050 is now the sole open PR for this fix; the other overlapping PR was closed. A Windows test on a machine with many HID devices passed but did not reproduce the hang, so confirmation on the original reproducing setup is still needed. Could you test #1050 with the default environment (without `SDL_DIRECTINPUT_ENABLED=0`) and report whether `sceVideoOutOpen` returns? That would answer the remaining question before merge.
frankea commented 2026-10-10 03:52:33 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-10T03:52:33Z.


Confirmed on the reproducing machine: #1050 with the default environment makes sceVideoOutOpen return and guest_video_out_wqhd_detection pass, both over SSH and in the desktop session, while the unpatched build still hangs the same day. Details: https://github.com/boykopovar/AnyPS5/pull/1050#issuecomment-6093486267

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093486423 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/1042#issuecomment-6093486423). Originally posted by [frankea](https://github.com/frankea) on 2026-10-10T03:52:33Z. --- Confirmed on the reproducing machine: #1050 with the default environment makes `sceVideoOutOpen` return and `guest_video_out_wqhd_detection` pass, both over SSH and in the desktop session, while the unpatched build still hangs the same day. Details: https://github.com/boykopovar/AnyPS5/pull/1050#issuecomment-6093486267
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#1042
No description provided.