Input: add Windows DualSense / DualSense Edge support #2335

Open
Asem912 wants to merge 1 commit from upstream-pr/2337 into main
Asem912 commented 2026-11-25 11:00:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Asem912 on 2026-11-25T11:00:51Z.


Rebased continuation of #1517 onto current main (940d32f), integrating upstream gameinput changes from #197 (VICTORY_KEYS merging into connected host pads) and #361 (cross-device time-ordered next_reading / previous_reading).

Summary

Adds native Windows HLE support for PlayStation 5 DualSense (0x0CE6) and DualSense Edge (0x0DF2) controllers in gameinput.dll, supporting wired USB, Raspberry Pi Pico 2 W DS5Dongle wireless bridges, and native Bluetooth (0x31 enhanced reports) using existing workspace dependencies.

Highlights

  • Dual-transport Win32 HID backend (victory-hle::modules::gameinput::dualsense):
    • Opens UsagePage 0x01 / Usage 0x05 with FILE_SHARE_READ | FILE_SHARE_WRITE so companion tools and DS5Dongle WebHID configurators are never locked out.
    • Supports USB 0x01/0x02 and Bluetooth 0x31 (auto-reads Feature 0x05 to enter enhanced mode, validates 0xA1/0xA2/0xA3 seeded CRC-32).
    • Monitors sensor_timestamp liveness (1.5 s freeze timeout) so an idle/powered-off wireless pad behind a plugged-in DS5Dongle cleanly falls back to keyboard WASD without stuck buttons, and re-fetches 0x05/0x20 on reconnect.
  • Actuators, triggers, haptics, and indicators:
    • Declares 4 rumble motors (0xF) and translates Xbox trigger rumble scalars into DualSense adaptive trigger Vibration / Hybrid / Off modes with ~100 Hz output rate limiting and immediate zero-stop flushes.
    • Reads Feature 0x20 firmware version and sets COMPATIBLE_VIBRATION2 (valid_flag2 bit 2) for firmware >= 0x0224, leaving audio volume bytes untouched for DS5Dongle v0.8+ volume lock compatibility.
    • Optional 4-channel WASAPI voice-coil synthesis (audio_4ch / hybrid) blending rumble carriers with title-scoped VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK low-pass audio while keeping Ch1/2 silent by default.
    • Implements IGameInputDevice::GetBatteryState (0x28) and IGameInput::RegisterSystemButtonCallback (0x50, short-press PS Guide, PS + Touchpad gyro recenter, ignoring >= 600 ms holds for power-off / multi-device slot switching).
  • 6-axis gyro, arbitration, history & safety:
    • High-frequency 3 MHz IMU integration (PlayerSpace Yaw+Roll, AdsOrTouch default, anti-deadzone floor) onto right stick.
    • Expands reading HISTORY to 512 with analog sub-LSB jitter coalescing to prevent REFERENCE_TOO_OLD on slow frames, while preserving cross-device time-ordered next_reading / previous_reading (#361) and VICTORY_KEYS pad merging (#197).
    • Slot arbitrator suppresses duplicate virtual XInput mirrors (e.g. Steam Input VID_28DE / ViGEm) while preserving mixed genuine Xbox + PS5 pads.
    • Lock-free hardware trigger/rumble reset on focus loss, lifecycle::end_title, Ctrl+C, panic, and victory-loader unhandled exceptions.
  • Configuration (victory-core, victory.example.toml, apps/victory):
    • Adds optional [input] and [input.dualsense] TOML sections and VICTORY_* env overrides.

Verification

  • cargo clippy --workspace --all-targets --locked -- -D warnings (pass)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (pass)
  • cargo test -p victory-hle --features diagnostics --locked -- modules::gameinput modules::lifecycle (32 passed; synthetic HID report fixtures + VICTORY_KEYS / cross-device walk tests)
  • cargo test -p victory-core -p victory -p victory-loader -p victory-pe -p victory-pipeline -p xtask --locked (all passed, including config, crash, and xtask asset-policy checks)
  • Not yet tested: physical DualSense / DS5Dongle hardware E2E on device (and full cargo test --workspace --locked outside sandbox; in the sandboxed run, unrelated victory-gpu descriptor/memory tests failed).
<!-- greyfinch-sync:Marvisak/VIctory:issue:5490033922 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2337). Originally posted by [Asem912](https://github.com/Asem912) on 2026-11-25T11:00:51Z. --- > Rebased continuation of #1517 onto current `main` (`940d32f`), integrating upstream `gameinput` changes from #197 (`VICTORY_KEYS` merging into connected host pads) and #361 (cross-device time-ordered `next_reading` / `previous_reading`). ## Summary Adds native Windows HLE support for PlayStation 5 **DualSense (`0x0CE6`)** and **DualSense Edge (`0x0DF2`)** controllers in `gameinput.dll`, supporting wired USB, Raspberry Pi Pico 2 W `DS5Dongle` wireless bridges, and native Bluetooth (`0x31` enhanced reports) using existing workspace dependencies. ### Highlights - **Dual-transport Win32 HID backend (`victory-hle::modules::gameinput::dualsense`)**: - Opens `UsagePage 0x01 / Usage 0x05` with `FILE_SHARE_READ | FILE_SHARE_WRITE` so companion tools and `DS5Dongle` WebHID configurators are never locked out. - Supports USB `0x01`/`0x02` and Bluetooth `0x31` (auto-reads Feature `0x05` to enter enhanced mode, validates `0xA1`/`0xA2`/`0xA3` seeded CRC-32). - Monitors `sensor_timestamp` liveness (1.5 s freeze timeout) so an idle/powered-off wireless pad behind a plugged-in `DS5Dongle` cleanly falls back to keyboard `WASD` without stuck buttons, and re-fetches `0x05`/`0x20` on reconnect. - **Actuators, triggers, haptics, and indicators**: - Declares 4 rumble motors (`0xF`) and translates Xbox trigger rumble scalars into DualSense adaptive trigger `Vibration` / `Hybrid` / `Off` modes with ~100 Hz output rate limiting and immediate zero-stop flushes. - Reads Feature `0x20` firmware version and sets `COMPATIBLE_VIBRATION2` (`valid_flag2` bit 2) for firmware `>= 0x0224`, leaving audio volume bytes untouched for `DS5Dongle` v0.8+ volume lock compatibility. - Optional 4-channel WASAPI voice-coil synthesis (`audio_4ch` / `hybrid`) blending rumble carriers with title-scoped `VIRTUAL_AUDIO_DEVICE_PROCESS_LOOPBACK` low-pass audio while keeping Ch1/2 silent by default. - Implements `IGameInputDevice::GetBatteryState` (`0x28`) and `IGameInput::RegisterSystemButtonCallback` (`0x50`, short-press PS Guide, `PS + Touchpad` gyro recenter, ignoring `>= 600 ms` holds for power-off / multi-device slot switching). - **6-axis gyro, arbitration, history & safety**: - High-frequency 3 MHz IMU integration (`PlayerSpace` Yaw+Roll, `AdsOrTouch` default, anti-deadzone floor) onto right stick. - Expands reading `HISTORY` to `512` with analog sub-LSB jitter coalescing to prevent `REFERENCE_TOO_OLD` on slow frames, while preserving cross-device time-ordered `next_reading` / `previous_reading` (#361) and `VICTORY_KEYS` pad merging (#197). - Slot arbitrator suppresses duplicate virtual XInput mirrors (e.g. Steam Input `VID_28DE` / ViGEm) while preserving mixed genuine Xbox + PS5 pads. - Lock-free hardware trigger/rumble reset on focus loss, `lifecycle::end_title`, `Ctrl+C`, panic, and `victory-loader` unhandled exceptions. - **Configuration (`victory-core`, `victory.example.toml`, `apps/victory`)**: - Adds optional `[input]` and `[input.dualsense]` TOML sections and `VICTORY_*` env overrides. ## Verification - `cargo clippy --workspace --all-targets --locked -- -D warnings` (pass) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (pass) - `cargo test -p victory-hle --features diagnostics --locked -- modules::gameinput modules::lifecycle` (32 passed; synthetic HID report fixtures + `VICTORY_KEYS` / cross-device walk tests) - `cargo test -p victory-core -p victory -p victory-loader -p victory-pe -p victory-pipeline -p xtask --locked` (all passed, including `config`, `crash`, and `xtask` asset-policy checks) - **Not yet tested**: physical DualSense / `DS5Dongle` hardware E2E on device (and full `cargo test --workspace --locked` outside sandbox; in the sandboxed run, unrelated `victory-gpu` descriptor/memory tests failed).
catminou4 commented 2026-11-25 11:03:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T11:03:10Z.

Review: COMMENTED


Static review only: apps/victory input paths are Windows-only here; not tested on macOS. Big feature (+4157): DualSense/DualSense Edge over wired USB, Pico 2 W DS5Dongle bridge and Bluetooth, with haptics/adaptive triggers/gyro/touchpad/battery, config under [input.dualsense]. Suggest splitting the victory-core parts from the input driver for reviewability; needs Windows hardware validation with an actual DS5.

<!-- greyfinch-sync:Marvisak/VIctory:review:6056393504 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2337#pullrequestreview-6056393504). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T11:03:10Z. **Review:** COMMENTED --- Static review only: apps/victory input paths are Windows-only here; not tested on macOS. Big feature (+4157): DualSense/DualSense Edge over wired USB, Pico 2 W DS5Dongle bridge and Bluetooth, with haptics/adaptive triggers/gyro/touchpad/battery, config under [input.dualsense]. Suggest splitting the victory-core parts from the input driver for reviewability; needs Windows hardware validation with an actual DS5.
Marvisak commented 2026-11-25 16:09:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:23:56Z.


Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main (conflicts in apps/victory/src/main.rs and crates/victory-hle/src/modules/gameinput/mod.rs). It will be reviewed again once it is rebased.

From the earlier needs-work note, still open: dependency changes need the maintainer's decision, evidence for the GameInput behaviour changes, no hardware testing yet, and the PR should be split into smaller changes with shorter docs.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166780049 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2337#issuecomment-7166780049). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:23:56Z. --- <!-- victory-triage v1 head=7e6224ee22f5f6c0d030896b2956ca161ceace33 verdict=needs-rebase at=2026-11-25T22:29:35Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main` (conflicts in `apps/victory/src/main.rs` and `crates/victory-hle/src/modules/gameinput/mod.rs`). It will be reviewed again once it is rebased. From the earlier needs-work note, still open: dependency changes need the maintainer's decision, evidence for the GameInput behaviour changes, no hardware testing yet, and the PR should be split into smaller changes with shorter docs. --- _Generated by [Claude Code](https://claude.ai/code)_
nullexxx commented 2026-11-27 15:44:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by nullexxx on 2026-11-27T15:44:49Z.


Hardware results for this protocol, from a port into TaynanGT/Vice-Tay (Proton on CachyOS, DualSense over USB, firmware 0x0630):

  • Rumble (output report 0x02, compatible vibration 2 since the firmware is ≥ 0x0224): works. The pad shakes with the title's motor levels.
  • Under Wine, WriteFile completes with 47 bytes written for the 48-byte report, since the report ID byte isn't counted. A check that the byte count equals the report length treats every write as failed.
  • Adaptive triggers: could not be tested with this title. Even with all four rumble motors declared (0xF), and with the pad presented as an Xbox Series controller (045E:0B12, family Xbox One), it never sent a nonzero impulse trigger level. The trigger encoder works in unit tests, but its effect on hardware is still unconfirmed.
  • Under Wine the DualSense also shows up as an XInput pad. Trigger-only reports have to leave the motor flag bits clear, or they override Wine's rumble.

Thanks @Asem912 for the protocol work, and aleksesipenko for VIctory-RTX.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7222430986 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2337#issuecomment-7222430986). Originally posted by [nullexxx](https://github.com/nullexxx) on 2026-11-27T15:44:49Z. --- Hardware results for this protocol, from a port into TaynanGT/Vice-Tay (Proton on CachyOS, DualSense over USB, firmware 0x0630): - **Rumble (output report 0x02, compatible vibration 2 since the firmware is ≥ 0x0224): works.** The pad shakes with the title's motor levels. - **Under Wine, `WriteFile` completes with 47 bytes written for the 48-byte report**, since the report ID byte isn't counted. A check that the byte count equals the report length treats every write as failed. - **Adaptive triggers: could not be tested with this title.** Even with all four rumble motors declared (0xF), and with the pad presented as an Xbox Series controller (045E:0B12, family Xbox One), it never sent a nonzero impulse trigger level. The trigger encoder works in unit tests, but its effect on hardware is still unconfirmed. - Under Wine the DualSense also shows up as an XInput pad. Trigger-only reports have to leave the motor flag bits clear, or they override Wine's rumble. Thanks @Asem912 for the protocol work, and aleksesipenko for VIctory-RTX.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2337:upstream-pr/2337'
git switch 'upstream-pr/2337'

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 'upstream-pr/2337'
git switch 'upstream-pr/2337'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2337'
git switch 'upstream-pr/2337'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2337'
git switch 'main'
git merge --squash 'upstream-pr/2337'
git switch 'main'
git merge --ff-only 'upstream-pr/2337'
git switch 'main'
git merge 'upstream-pr/2337'
git push origin 'main'
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
Marvisak/VIctory!2335
No description provided.