feat(pad): complete DualSense adaptive trigger support #10112

Merged
seradavid merged 1 commit from upstream-pr/10112 into main 2026-11-06 04:07:17 +00:00
seradavid commented 2026-10-23 09:55:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by seradavid on 2026-10-23T09:55:31Z.


What

scePadGetTriggerEffectState was a silent stub that zeroed its output. It now reads the controller's own trigger effect and status nibbles from the DualSense input report (0x01 over USB, 0x31 over Bluetooth) through a second HID handle and maps them to the SCE states: feedback no-force/pushing, weapon not/almost/fully pressed, vibration not/is firing.

The same change completes the trigger output path:

  • scePadDisableTriggerEffect is implemented. Disabling sends both trigger blocks off; enabling restores the last requested effects.
  • Only triggers that were actually set get their enable bit and effect block. Before, an untouched trigger was sent as mode 0x00 with its enable bit set.
  • A refused effect is retried on the next update even when no other pad output changed.
  • The cached trigger state is cleared when the controller closes, the status handle closes, the handle cannot be opened, or scePadInit runs, so a disconnect or failed reopen reports zero until a new report arrives.
  • PadTriggerEffect::Build holds the 47-byte report construction, and the trigger encoding and retry are covered by tests.
  • The trigger test includes the public libScePad.hpp instead of redeclaring the exports.

The branch is rebased onto current main (151a2cb6) as one linear commit. The per-port trigger state follows #7881, the special-port handle follows #9878, and the Bluetooth haptics stream from #9154 is kept alongside it: closeController closes both the status and haptics handles, and applyOutput runs the haptics/rumble path before the trigger effect path.

scePadSetTriggerEffectStrength, scePadGetTriggerEffectInternalState and scePadSetTriggerEffectExt still throw because their strength units and payload layouts are unknown. They are recorded in docs/dev/debt/libScePad.md.

Tested

Windows 11 26300, WinLibs GCC 15.2.0, Release, rebased onto 151a2cb6.

  • guest_pad_trigger_effects: all seven trigger modes, native report layout, off mode, per-trigger enable bits, disable/restore, trigger-state mapping, clearing and reinitializing the pad.
  • dualsense_status: USB and Bluetooth input-report parsing, short and unknown reports rejected.
  • dualsense_haptics: report/CRC and 3 kHz buffer.
  • guest_pad, guest_pad_vibration_mode, pad_output_pacing: pass. guest_pad needs TEMP on a writable path in this environment; it fails to create its scripted command file under the default Windows temp directory here.
  • tools/check_conventions.py --base upstream/main: pass.
  • tools/pr_overlap.py --branch feat/pad-adaptive-triggers: only #6337 remains, and only in the Pad debt file; it is not a code dependency.

Hardware, USB DualSense: a weapon effect was accepted by SDL_GameControllerSendEffect, and the controller then reported right effect 2/status 0 in input report 0x01.

Hardware, Bluetooth DualSense: the controller enumerated with interface_number -1; the second handle read 78-byte report 0x31, parsed the same status fields, and non-blocking reads worked. A weapon effect was accepted and the controller reported right effect 2/status 0. A real title was not tested.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (libScePad and pad input; no rendering path changed)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4980993617 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10112). Originally posted by [seradavid](https://github.com/seradavid) on 2026-10-23T09:55:31Z. --- ### What `scePadGetTriggerEffectState` was a silent stub that zeroed its output. It now reads the controller's own trigger effect and status nibbles from the DualSense input report (`0x01` over USB, `0x31` over Bluetooth) through a second HID handle and maps them to the SCE states: feedback no-force/pushing, weapon not/almost/fully pressed, vibration not/is firing. The same change completes the trigger output path: - `scePadDisableTriggerEffect` is implemented. Disabling sends both trigger blocks off; enabling restores the last requested effects. - Only triggers that were actually set get their enable bit and effect block. Before, an untouched trigger was sent as mode `0x00` with its enable bit set. - A refused effect is retried on the next update even when no other pad output changed. - The cached trigger state is cleared when the controller closes, the status handle closes, the handle cannot be opened, or `scePadInit` runs, so a disconnect or failed reopen reports zero until a new report arrives. - `PadTriggerEffect::Build` holds the 47-byte report construction, and the trigger encoding and retry are covered by tests. - The trigger test includes the public `libScePad.hpp` instead of redeclaring the exports. The branch is rebased onto current `main` (`151a2cb6`) as one linear commit. The per-port trigger state follows #7881, the special-port handle follows #9878, and the Bluetooth haptics stream from #9154 is kept alongside it: `closeController` closes both the status and haptics handles, and `applyOutput` runs the haptics/rumble path before the trigger effect path. `scePadSetTriggerEffectStrength`, `scePadGetTriggerEffectInternalState` and `scePadSetTriggerEffectExt` still throw because their strength units and payload layouts are unknown. They are recorded in `docs/dev/debt/libScePad.md`. ### Tested Windows 11 26300, WinLibs GCC 15.2.0, Release, rebased onto `151a2cb6`. - `guest_pad_trigger_effects`: all seven trigger modes, native report layout, off mode, per-trigger enable bits, disable/restore, trigger-state mapping, clearing and reinitializing the pad. - `dualsense_status`: USB and Bluetooth input-report parsing, short and unknown reports rejected. - `dualsense_haptics`: report/CRC and 3 kHz buffer. - `guest_pad`, `guest_pad_vibration_mode`, `pad_output_pacing`: pass. `guest_pad` needs `TEMP` on a writable path in this environment; it fails to create its scripted command file under the default Windows temp directory here. - `tools/check_conventions.py --base upstream/main`: pass. - `tools/pr_overlap.py --branch feat/pad-adaptive-triggers`: only #6337 remains, and only in the Pad debt file; it is not a code dependency. Hardware, USB DualSense: a weapon effect was accepted by `SDL_GameControllerSendEffect`, and the controller then reported right effect 2/status 0 in input report `0x01`. Hardware, Bluetooth DualSense: the controller enumerated with `interface_number` -1; the second handle read 78-byte report `0x31`, parsed the same status fields, and non-blocking reads worked. A weapon effect was accepted and the controller reported right effect 2/status 0. A real title was not tested. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a (libScePad and pad input; no rendering path changed) - [x] AI-assisted: yes
MarcZX10 commented 2026-10-23 10:22:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T10:22:11Z.

Review: CHANGES_REQUESTED


I reviewed exact head 2981977a3d9de02210730b8ef7deba096dedd681. The report parser itself passes a local standalone GCC check (-std=c++20 -Wall -Wextra -Werror); exact-head diff-check and conventions pass. The reported Windows controller tests and USB/Bluetooth hardware checks are useful. I found a state-lifecycle issue in addition to the need to refresh this branch against current main:

liveTriggerStatusValid and the cached effect/status nibbles are never invalidated. PadInput::closeController() closes statusHid but does not clear the published trigger state, and Pad::Initialize() does not clear it either. On disconnect/reconnect, scePadGetTriggerEffectState can therefore return the previous controller’s state before a new status report arrives; if opening the new HID handle fails, the stale state can persist indefinitely despite the debt text saying a host without a readable second handle reports state 0. Please clear/publish an invalid or zero state when the status handle/controller is closed (and define the behavior for failed open), with a regression for disconnect or failed reopen.

Also, check_main_sync.py reports this head 681 commits behind current upstream/main. Although the textual merge is clean, current main has substantial changes in the same Pad and VideoOut files. Please rebase onto current main, recheck overlaps with the still-open #9154/#7881/#9878, and rerun the focused tests on the resulting tree before approval. I could not configure the full local tests because SDL2 development files are missing; no broad runtime test was run here.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5626939603 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10112#pullrequestreview-5626939603). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T10:22:11Z. **Review:** CHANGES_REQUESTED --- I reviewed exact head 2981977a3d9de02210730b8ef7deba096dedd681. The report parser itself passes a local standalone GCC check (`-std=c++20 -Wall -Wextra -Werror`); exact-head diff-check and conventions pass. The reported Windows controller tests and USB/Bluetooth hardware checks are useful. I found a state-lifecycle issue in addition to the need to refresh this branch against current main: `liveTriggerStatusValid` and the cached effect/status nibbles are never invalidated. `PadInput::closeController()` closes `statusHid` but does not clear the published trigger state, and `Pad::Initialize()` does not clear it either. On disconnect/reconnect, `scePadGetTriggerEffectState` can therefore return the previous controller’s state before a new status report arrives; if opening the new HID handle fails, the stale state can persist indefinitely despite the debt text saying a host without a readable second handle reports state 0. Please clear/publish an invalid or zero state when the status handle/controller is closed (and define the behavior for failed open), with a regression for disconnect or failed reopen. Also, `check_main_sync.py` reports this head 681 commits behind current `upstream/main`. Although the textual merge is clean, current main has substantial changes in the same Pad and VideoOut files. Please rebase onto current main, recheck overlaps with the still-open #9154/#7881/#9878, and rerun the focused tests on the resulting tree before approval. I could not configure the full local tests because SDL2 development files are missing; no broad runtime test was run here.
MarcZX10 commented 2026-10-23 10:35:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T10:35:55Z.

Review: CHANGES_REQUESTED


I re-reviewed the new exact head 30456cda18. The stale trigger-state issue I reported is fixed: closeController() calls closeStatus() and clears the cached state, openStatus() clears it before the controller/path/HID-open checks, and Pad::Initialize() resets it under the state mutex. The new test exercises publish → map → clear → publish again → reinitialize, and the author reports the trigger and DualSense parser tests pass on Windows. Exact-head conventions pass; git diff --check passes; sync is 2 ahead/17 behind current main with a clean merge.

The remaining blocker is merge coordination. Pairwise merges of this head conflict with #9154 in the VideoOut test registration and PadInput files, with #7881 in Pad state/exports and PadInput, with #9878 in Export.cpp, and with #6337 in the Pad debt file. These are the exact paths the overlap check identifies; several concern the same state or handle code, so please agree an order with those authors, declare Depends on where appropriate, then rebase/resolve and rerun the focused pad tests. The repository's overlap rule requires this coordination before approval. I did not run the full updated guest-pad tests locally; this environment's full CMake configure is blocked by the missing SDL2 submodule and XRandR development support.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5627072472 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10112#pullrequestreview-5627072472). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T10:35:55Z. **Review:** CHANGES_REQUESTED --- I re-reviewed the new exact head `30456cda18`. The stale trigger-state issue I reported is fixed: `closeController()` calls `closeStatus()` and clears the cached state, `openStatus()` clears it before the controller/path/HID-open checks, and `Pad::Initialize()` resets it under the state mutex. The new test exercises publish → map → clear → publish again → reinitialize, and the author reports the trigger and DualSense parser tests pass on Windows. Exact-head conventions pass; `git diff --check` passes; sync is 2 ahead/17 behind current main with a clean merge. The remaining blocker is merge coordination. Pairwise merges of this head conflict with #9154 in the VideoOut test registration and `PadInput` files, with #7881 in Pad state/exports and `PadInput`, with #9878 in `Export.cpp`, and with #6337 in the Pad debt file. These are the exact paths the overlap check identifies; several concern the same state or handle code, so please agree an order with those authors, declare `Depends on` where appropriate, then rebase/resolve and rerun the focused pad tests. The repository's overlap rule requires this coordination before approval. I did not run the full updated guest-pad tests locally; this environment's full CMake configure is blocked by the missing SDL2 submodule and XRandR development support.
jotitadev commented 2026-10-27 01:21:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-27T01:21:02Z.

Review: COMMENTED


Linux run of the current head, since the tested sections cover Windows only.

Machine: Linux x86_64, i7-8700 (6 cores / 12 threads, AVX2), Ubuntu 26.04, GCC 15.2, Release, BUILD_TESTING=ON. Head 013a5a196 merged onto main e2d457be3 (clean).

  • Build ok. guest_pad_trigger_effects, dualsense_status, guest_pad, guest_pad_vibration_mode, pad_output_pacing and the other pad tests pass (14 of 14), plus patched_libraries. guest_pad passes with the default TEMP here. The two new tests pass 20 of 20 repeated runs.
  • Restoring main's libScePad/Export.cpp and keeping the test aborts guest_pad_trigger_effects with scePadDisableTriggerEffect not implemented.
  • Two mutations in PadState.cpp are also caught: not storing triggerDisabled in SetTriggerEffectsDisabled fails with "the disabled state reaches the output", and mapping effect 2 / status 2 to 0 instead of 5 fails with "pushing and fully pressed statuses are mapped".
  • In the patched libScePad.prx, scePadDisableTriggerEffect is exported as OjTEJo7cfRE and scePadGetTriggerEffectState as znaWI0gpuo8.

Not tested: a DualSense over hidraw on Linux.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661167845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10112#pullrequestreview-5661167845). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-27T01:21:02Z. **Review:** COMMENTED --- Linux run of the current head, since the tested sections cover Windows only. Machine: Linux x86_64, i7-8700 (6 cores / 12 threads, AVX2), Ubuntu 26.04, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `013a5a196` merged onto `main` `e2d457be3` (clean). - Build ok. `guest_pad_trigger_effects`, `dualsense_status`, `guest_pad`, `guest_pad_vibration_mode`, `pad_output_pacing` and the other pad tests pass (14 of 14), plus `patched_libraries`. `guest_pad` passes with the default `TEMP` here. The two new tests pass 20 of 20 repeated runs. - Restoring `main`'s `libScePad/Export.cpp` and keeping the test aborts `guest_pad_trigger_effects` with `scePadDisableTriggerEffect not implemented`. - Two mutations in `PadState.cpp` are also caught: not storing `triggerDisabled` in `SetTriggerEffectsDisabled` fails with "the disabled state reaches the output", and mapping effect 2 / status 2 to 0 instead of 5 fails with "pushing and fully pressed statuses are mapped". - In the patched `libScePad.prx`, `scePadDisableTriggerEffect` is exported as `OjTEJo7cfRE` and `scePadGetTriggerEffectState` as `znaWI0gpuo8`. Not tested: a DualSense over hidraw on Linux. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-29 06:09:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T06:09:58Z.

Review: DISMISSED


Re-checked — changes requested

What I checked

  • Reviewed exact head 257b3377dd0708bd97fa0ff3efb9a0a06d7bfed8 against fetched main 2960e9a6e7.
  • The stale trigger-state concern is resolved: status is cleared on close, before failed/reopened status-handle attempts, and during initialization; the added tests cover clear and republish.
  • The current-main merge preview is clean, and main has not changed the files this PR touches since its reported base 319621ba2e. Exact-head hosted Windows, input-mapper, conventions, labels, and report checks pass.

Test evidence

The author reports the trigger, DualSense status, pad, vibration-mode, and output-pacing tests passing on this head. The hardware report covers USB and Bluetooth DualSense parsing and effect acceptance; no retail title was tested. I did not run Windows hardware tests locally.

Blocking repository coordination

Open #9154 still conflicts with this PR in VideoOut CMake registration, PadInput files, and the VideoOut debt file. Open #6337 still conflicts in the Pad debt file. The pairwise merge previews confirm these conflicts, and neither PR records an agreed landing order with this one. Please coordinate with both authors and declare the confirmed order in the affected checklists. This is the remaining blocker; the earlier state-lifecycle and current-file refresh findings are resolved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5693567395 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10112#pullrequestreview-5693567395). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T06:09:58Z. **Review:** DISMISSED --- # Re-checked — changes requested ## What I checked - Reviewed exact head `257b3377dd0708bd97fa0ff3efb9a0a06d7bfed8` against fetched `main` `2960e9a6e7`. - The stale trigger-state concern is resolved: status is cleared on close, before failed/reopened status-handle attempts, and during initialization; the added tests cover clear and republish. - The current-main merge preview is clean, and `main` has not changed the files this PR touches since its reported base `319621ba2e`. Exact-head hosted Windows, input-mapper, conventions, labels, and report checks pass. ## Test evidence The author reports the trigger, DualSense status, pad, vibration-mode, and output-pacing tests passing on this head. The hardware report covers USB and Bluetooth DualSense parsing and effect acceptance; no retail title was tested. I did not run Windows hardware tests locally. ## Blocking repository coordination Open #9154 still conflicts with this PR in VideoOut CMake registration, `PadInput` files, and the VideoOut debt file. Open #6337 still conflicts in the Pad debt file. The pairwise merge previews confirm these conflicts, and neither PR records an agreed landing order with this one. Please coordinate with both authors and declare the confirmed order in the affected checklists. This is the remaining blocker; the earlier state-lifecycle and current-file refresh findings are resolved.
Sign in to join this conversation.
No reviewers
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!10112
No description provided.