controller: enable the DualSense HIDAPI driver, light bar and adaptive triggers #437
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!437
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/437/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?
@CheesyPoofs346 on GitHub · 2026-09-01 03:05 UTC · original
CheesyPoofs346:feat/dualsense-support→main· +178 −18 · 4 files · 2 commits · merged 2026-09-01 20:53 UTCSummary
PadSetLightBarinstead of accepting and discarding the call.PadSetTriggerEffectby translating a title's request into a DualSense trigger block.Problem
The HIDAPI driver. SDL opens a DualSense through the generic gamepad path unless told otherwise. Logging what SDL reported for a connected pad:
SDL_GameControllerHasLEDandSDL_GameControllerGetNumTouchpadsboth return nothing, soSDL_GameControllerSetLEDcannot work and noSDL_CONTROLLERTOUCHPAD*events are ever delivered — the touchpad handling already in tree has nothing to receive. Setting the PS5 hints beforeSDL_InitSubSystemgives:The light bar.
PadSetLightBarvalidated its arguments and returnedOKwithout touching the pad, so a title signalling state through it (police lights, health, player colour) had no effect. Verified in Grand Theft Auto V, where the light bar now flashes red and blue at a wanted level.Adaptive triggers.
PadSetTriggerEffectlikewise returnedOKand did nothing.SDL_GameControllerSendEffectcannot carry these — SDL's PS5 driver owns its output report and rejects ours withSendEffect failed, device disconnected— so the trigger block is written directly to the pad over HID. USB uses report0x02with the payload at offset 1; Bluetooth uses0x31at offset 2 with a CRC32 over an0xA2header byte plus the report. Only the trigger-effect enable bits are set, leaving the rumble and LED state SDL manages untouched; an earlier version that wrote the whole report degraded vibration.The parameter layout was established by logging what a title actually sends: a trigger mask, a
uint32mode per trigger at offsets 4 and 8, then a four-byte parameter block per trigger at 12 and 16. Modes map to DualSense effect types — 1 feedback to0x01rigid, 2 weapon to0x02pulse, 3 vibration to0x06. Positions (0-9) and strengths (0-8) are scaled to the 0-255 the hardware expects; passing them through unscaled put resistance at 3.5% of the trigger pull and felt permanently engaged.Identical effects are not re-sent, since titles reissue the same request every frame and the pad holds the last one.
Validation
AI assistance
AI assistance was used for this change.
@chatgpt-codex-connector[bot] on GitHub · 2026-09-01 03:08 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
681c2f30ccℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@chatgpt-codex-connector[bot] on GitHub · 2026-09-01 03:08 UTC · original
On
src/libs/controller.cppline 346 (outdated):If a title calls
PadSetTriggerEffectbefore a DualSense is connected,SDL_hid_openfails butm_hid_triedremains true, so every later call returns without retrying even after the controller is hot-plugged. The same retained state leaves a stale handle after disconnect/reconnect; reset and close the HID handle whenever the active controller changes, and allow acquisition to be retried.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-09-01 03:08 UTC · original
On
src/libs/libPad.cppline 140 (outdated):When the mask selects only one trigger, the other local effect remains zero-initialized, but
ControllerTriggerEffectstill emits a report enabling updates for both triggers. Consequently, a left-only update clears an existing right-trigger effect (and vice versa) instead of leaving the unmasked trigger unchanged; retain the previous effect or propagate the mask into report construction.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-09-01 03:08 UTC · original
On
src/libs/controller.cppline 346 (outdated):When multiple Sony controllers are attached, this VID/PID-only open is unrelated to
m_active_id; it can therefore send adaptive-trigger effects to a different physical pad than the one supplying player-one input. This is deterministic when an active Edge is present alongside a standard DualSense because product0x0ce6is always tried first. Resolve the active SDL controller's HID path or serial and open that exact device.Useful? React with 👍 / 👎.
@Copilot on GitHub · 2026-09-01 03:09 UTC · original
On
src/libs/libPad.cppline 124 (outdated):The trigger-effect logging block builds a hex string but never emits it, so the code has no effect and adds unnecessary work/complexity. Either remove the block or actually log the collected bytes (rate-limited as intended).
@Copilot on GitHub · 2026-09-01 03:09 UTC · original
On
src/libs/controller.cppline 381 (outdated):The output-report apply bits are always set to
0x0c(both triggers), which ignores the title-provided trigger mask and can unintentionally clear or overwrite the other trigger when only one side is requested. This likely needs the mask (or per-trigger apply flags) to be plumbed through toSetTriggerEffectso only requested triggers are applied, while still allowing an explicit "off" to clear a trigger.@copilot-pull-request-reviewer[bot] on GitHub · 2026-09-01 03:09 UTC · original · reviewed
Pull request overview
This PR enhances DualSense support in the controller subsystem by ensuring SDL uses the PS5 HIDAPI driver (enabling LED/touchpad capability reporting), wiring
PadSetLightBarto actually drive the controller LED, and implementing adaptive trigger effects by translating title requests into DualSense HID trigger blocks sent directly over HID.Changes:
PadSetLightBartoSDL_GameControllerSetLED.Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
ControllerTriggerEffectentry point for trigger-effect output.💡 Add a
code-reviewagent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.@Copilot on GitHub · 2026-09-01 03:09 UTC · original
On
src/libs/controller.cppline 388 (outdated):SDL_hid_writeerrors are ignored, andm_hid_triedprevents reopening; if the controller disconnects/reconnects, trigger effects may silently stop working for the rest of the session. Capture the return value and on failure close/reset the HID handle so a later call can retry opening.@Copilot on GitHub · 2026-09-01 03:09 UTC · original
On
src/libs/controller.cppline 84 (outdated):m_hidis opened withSDL_hid_openbut never closed, so the process can leak the HID handle across controller shutdown and potentially keep the device busy. Add RAII cleanup (e.g., a destructor) to close the HID device whenGameControlleris destroyed.