controller: give the DualShock 4 the DualSense pad path and release p… #453
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!453
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/453/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@MehmetCambaz on GitHub · 2026-09-02 14:52 UTC · original
MehmetCambaz:fix/ds4-bluetooth-and-pad-release→main· +50 −8 · 5 files · 1 commits · merged 2026-09-03 22:10 UTCFixes #441.
What was wrong
Two problems that only appear together, on a real Bluetooth DualShock 4.
1. The DS4 was never given SDL's extended report mode. Rumble, the light bar, touch pad
coordinates and the motion sensors are only reported by a PlayStation pad in the mode SDL calls
"enhanced".
window.cppasked for it for the DualSense (SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE)and never for the DualShock 4. Over USB this is masked, because
HIDAPI_DriverPS4_InitDeviceenables enhanced mode unconditionally for a Sony vendor id. Over Bluetooth the pad stays in the
simple report mode, so a DS4 silently lost all four features —
scePadSetVibrationandscePadSetLightBarreturned success and did nothing.2. Host pads were never released at exit. The emulator ends via
std::quick_exit(0), whichruns
at_quick_exithandlers only, so theSubsystemsdestructor and every lifecycle shutdownare skipped. The controller lifecycle declared no
emergency_shutdown, soSDL_GameControllerClose()andSDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER)never ran. SDL sendsthe stop-rumble command from
SDL_JoystickClose(), so a pad vibrating when the window closeskeeps vibrating, with no process left alive to stop it — only powering the pad off ends it. SDL
also never restores the light bar, and enhanced mode is (in SDL's own comment) "a one-way trip",
so the bar stays lit at the last colour sent.
The second problem is what #441 describes. The first is why it was invisible over Bluetooth: with
effects never enabled, there was nothing left running to notice.
The fix
SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLEalongside the existing PS5 hint.emergency_shutdownon the controller lifecycle and release host pads there: stop themotors, put the light bar out, allow SDL's rumble thread a bounded window to drain the queued
reports, then close the pads.
Hardware validation
DualShock 4 v2 (
054C:09CC) over Bluetooth, Windows 11, Tetris Forever. The window was closedwith a real
WM_CLOSEevery time, which is theSDL_QUIT->quick_exitpath under test.Light bar after the emulator exits:
{0x00,0x00,0x40}, left litRumble, driven through
GameController::SetVibration:Capabilities, read from SDL rather than judged by eye:
SDL_GameControllerHasLEDSDL_GameControllerHasRumbleSDL_GameControllerSetLEDNo regression in what already worked: all four face buttons, D-pad, L1/R1, L3/R3, Options, PS,
touch pad click, both sticks at full range, and L2/R2 analog 0..32767 were verified before and
after by the existing
KYTY_DBG_INPUTtrace.Tests
New
tests/SubsystemsTests.cpp(ctest -R subsystems) covers the mechanism the fix relies on:emergency shutdown must run exactly the lifecycles that declare a handler, in reverse
initialization order, must not run them twice, and the controller lifecycle must be one of them.
It fails to compile against the unfixed tree, with the static assertion naming the reason.
ctestgoes from 34/36 to 35/37 on Windows. The two failures(
shader_recompiler_compute,texture_cache_image_overlap, both0xc0000409) are pre-existingon
fc91fd2and unrelated.Limitations
PadDatahas the orientation, acceleration and angularvelocity fields and
scePadSetMotionSensorStatereturns OK, but there is no SDL sensor plumbingat all, so the guest still receives zeros. Enhanced mode is a precondition for fixing that, not
a fix for it.
scePadResetLightBarremains a stub that returns OK without touching the pad.direct observation of the physical pad; no test title was found that calls
scePadSetVibration, so the guest-initiated path was exercised throughGameController::SetVibrationdirectly rather than by a game.reasoning about the driver source, not by measurement — I have neither to hand.
AI use
This change was produced with AI assistance (Claude). The investigation, the SDL driver analysis,
the patch and the test were AI-generated; I reviewed the diff, ran the build and
ctestmyself,and performed all of the physical DualShock 4 testing above by hand.