[pr-feature][input] DualSense: the PS5 build's adaptive triggers read as its handler reads them, its light bar, and its haptics (DARNER_DS_HAPTICS) #185

Open
ItsYusei99 wants to merge 1 commit from ItsYusei99/Darner:ds-ps5-effects into main
First-time contributor

Contributor role (optional)

  • Fluxer ID: none

What it changes

With DARNER_DS_TRIGGERS=1, R2 was stiff all the time and the title's real trigger effects never reached the pad. Three causes, all in gameinput/playstation.rs:

  1. Wrong targets. Every effect object with a target other than 0 went to R2. The target at +8 is 0/1 for the rumble motors, 2 for L2, 3 for R2 and 4 for the light bar (VIctory-xmem PR 273). So L2 effects, motor rumble and the light bar colour (read as floats) all landed on R2.
  2. Wrong kinds. The kinds were read as DualSense modes with float values. The PS5 handler's kinds are 2 off, 3 feedback, 4 weapon, 5 vibration, 7 per-zone feedback and 8 slope, with byte values from +0x10. The new ps5_trigger.rs decodes and encodes them as xmem PR 273 does.
  3. Effects dropped the next call. The title sends an effect when it changes, not every frame, and capture cleared both triggers on every call without one. An effect now stays until the title sends another one or releases it.

It also adds:

  • Release at connect. A pad keeps the last effect it was sent, so a run that ended or crashed with one set left the trigger stiff in the next. The pad loop now releases both triggers in its first report.
  • The title's light bar. Target 4: kind 1 is an RGB colour, kind 2 the default [0, 0, 64]. Used when DARNER_DS_LIGHTBAR is unset, with DARNER_DS_TRIGGERS=1.
  • Haptics (DARNER_DS_HAPTICS=1, off by default). haptics.rs is xmem PR 273's port: it hooks the mixer's per-group output step and plays the PadHaptics group on channels 3 and 4 of the DualSense's USB audio endpoint through WASAPI. Env names are DARNER_*; DARNER_HAPTICS_GAIN_DB (default 8) and DARNER_HAPTICS_LOG. It needs Win32_UI_Shell_PropertiesSystem in darner-hle's windows features.
  • A log line per new kind and target. Each pair is logged once (adaptive triggers: first effect of this kind for this target), which is how the mapping above was checked in game.
  • README rows for the new switches; DARNER_DS_LIGHTBAR now says what it does when unset.

Credit: the offsets, the effect layout and the haptics player are from VIctory-xmem PR 273 by k-qno1.

How it was tested

  • Tested revision: the branch is this one commit on main dc332e0; cargo test and clippy ran there. The game test ran on bd0de0c with the same files.
  • cargo test --locked -p darner-hle: 497 passed, 0 failed, 15 ignored (the gameinput ones need a pad). New tests: trigger_encodings (from xmem PR 273), title_kinds_decode, and xmem PR 273's three haptics tests.
  • cargo clippy -p darner-hle --all-targets --locked -- -D warnings: clean.
  • Gameplay: RTX 4070, Series S, 1080 to 1440, DLSS Quality, frame generation 2x, ray tracing off, DualSense on USB.
    • The log showed kinds 7, 4 and 2 on targets 2 and 3, kind 0 on targets 0 and 1 and kind 1 on target 4.
    • R2 no longer stiff at start; R2 resistance when firing.
    • Haptics: haptics: playing on the controller's channels 3 and 4 in the log.
  • Coverage gaps: not tested over Bluetooth (haptics are USB only by design), not on a DualShock 4, not on a DualSense Edge. Light bar colours not checked in game. Not run: the workspace-wide gates.

Checklist

  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none found (closed #24 added PlayStation button prompts).
## Contributor role (optional) - Fluxer ID: none ## What it changes With `DARNER_DS_TRIGGERS=1`, R2 was stiff all the time and the title's real trigger effects never reached the pad. Three causes, all in `gameinput/playstation.rs`: 1. **Wrong targets.** Every effect object with a target other than 0 went to R2. The target at +8 is 0/1 for the rumble motors, 2 for L2, 3 for R2 and 4 for the light bar ([VIctory-xmem PR 273](https://github.com/lobomfz/VIctory-xmem/pull/273)). So L2 effects, motor rumble and the light bar colour (read as floats) all landed on R2. 2. **Wrong kinds.** The kinds were read as DualSense modes with float values. The PS5 handler's kinds are 2 off, 3 feedback, 4 weapon, 5 vibration, 7 per-zone feedback and 8 slope, with byte values from +0x10. The new `ps5_trigger.rs` decodes and encodes them as xmem PR 273 does. 3. **Effects dropped the next call.** The title sends an effect when it changes, not every frame, and `capture` cleared both triggers on every call without one. An effect now stays until the title sends another one or releases it. It also adds: - **Release at connect.** A pad keeps the last effect it was sent, so a run that ended or crashed with one set left the trigger stiff in the next. The pad loop now releases both triggers in its first report. - **The title's light bar.** Target 4: kind 1 is an RGB colour, kind 2 the default `[0, 0, 64]`. Used when `DARNER_DS_LIGHTBAR` is unset, with `DARNER_DS_TRIGGERS=1`. - **Haptics (`DARNER_DS_HAPTICS=1`, off by default).** `haptics.rs` is xmem PR 273's port: it hooks the mixer's per-group output step and plays the `PadHaptics` group on channels 3 and 4 of the DualSense's USB audio endpoint through WASAPI. Env names are `DARNER_*`; `DARNER_HAPTICS_GAIN_DB` (default 8) and `DARNER_HAPTICS_LOG`. It needs `Win32_UI_Shell_PropertiesSystem` in `darner-hle`'s `windows` features. - **A log line per new kind and target.** Each pair is logged once (`adaptive triggers: first effect of this kind for this target`), which is how the mapping above was checked in game. - README rows for the new switches; `DARNER_DS_LIGHTBAR` now says what it does when unset. Credit: the offsets, the effect layout and the haptics player are from [VIctory-xmem PR 273](https://github.com/lobomfz/VIctory-xmem/pull/273) by k-qno1. ## How it was tested - Tested revision: the branch is this one commit on `main` `dc332e0`; `cargo test` and `clippy` ran there. The game test ran on `bd0de0c` with the same files. - `cargo test --locked -p darner-hle`: 497 passed, 0 failed, 15 ignored (the gameinput ones need a pad). New tests: `trigger_encodings` (from xmem PR 273), `title_kinds_decode`, and xmem PR 273's three haptics tests. - `cargo clippy -p darner-hle --all-targets --locked -- -D warnings`: clean. - Gameplay: RTX 4070, Series S, 1080 to 1440, DLSS Quality, frame generation 2x, ray tracing off, DualSense on USB. - The log showed kinds 7, 4 and 2 on targets 2 and 3, kind 0 on targets 0 and 1 and kind 1 on target 4. - R2 no longer stiff at start; R2 resistance when firing. - Haptics: `haptics: playing on the controller's channels 3 and 4` in the log. - Coverage gaps: not tested over Bluetooth (haptics are USB only by design), not on a DualShock 4, not on a DualSense Edge. Light bar colours not checked in game. Not run: the workspace-wide gates. ## Checklist - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none found (closed #24 added PlayStation button prompts).
The title's pad effect objects carry their target at +8 (0/1 the motors,
2 L2, 3 R2, 4 the light bar) and their kind from the table's second entry;
every target but 0 went to R2, and the kinds were read as DualSense modes
with float values, so R2 stayed stiff and the real effects never reached the
pad. Kinds and values are now the PS5 handler's (ps5_trigger.rs), an effect
stays until the title changes or releases it, and both triggers are released
when a pad connects. Target 4 drives the light bar when DARNER_DS_LIGHTBAR is
unset. DARNER_DS_HAPTICS=1 plays the PadHaptics submix on the DualSense's
actuators (USB). Offsets, layout and the haptics player from
lobomfz/VIctory-xmem#273.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'ds-ps5-effects:ItsYusei99-ds-ps5-effects'
git switch 'ItsYusei99-ds-ps5-effects'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'ItsYusei99-ds-ps5-effects'
git switch 'ItsYusei99-ds-ps5-effects'
git rebase 'main'
git switch 'main'
git merge --ff-only 'ItsYusei99-ds-ps5-effects'
git switch 'ItsYusei99-ds-ps5-effects'
git rebase 'main'
git switch 'main'
git merge --no-ff 'ItsYusei99-ds-ps5-effects'
git switch 'main'
git merge --squash 'ItsYusei99-ds-ps5-effects'
git switch 'main'
git merge --ff-only 'ItsYusei99-ds-ps5-effects'
git switch 'main'
git merge 'ItsYusei99-ds-ps5-effects'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!185
No description provided.