Input: add Windows DualSense / DualSense Edge support #1517

Closed
github-bot wants to merge 1 commit from gh-pr/1517/head into gh-pr/1517/base
Owner

@⁠Asem912 on GitHub · 2026-11-24 18:41 UTC · original
Asem912:feat/dualsense-windows → main · +0 −0 · 0 files · 0 commits · closed without merging

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) with zero new external 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.
    • 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 --workspace --locked (all unit/integration + xtask asset-policy tests pass using synthetic HID report fixtures; physical DualSense / DS5Dongle hardware E2E not yet tested on device)
**@⁠Asem912** on GitHub · 2026-11-24 18:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1517) `Asem912:feat/dualsense-windows` → `main` · +0 −0 · 0 files · 0 commits · closed without merging ## 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) with zero new external 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. - 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 --workspace --locked` (all unit/integration + `xtask` asset-policy tests pass using synthetic HID report fixtures; **physical DualSense / `DS5Dongle` hardware E2E not yet tested on device**)
The console compiler loops over a per-lane descriptor by reading the
first active lane's table offset (v_readfirstlane_b32), narrowing EXEC
to the lanes with the same one (v_cmpx_eq_u32), loading that entry
(s_load_dwordx8) and dropping those lanes (s_andn2_wrexec). Such a load
now goes through the waterfall proof; when it holds, each lane loads its
own entry through a non-uniform handle. Unproven, the offset stays the
first lane's, as before.

Translation census over the title's 26,096 programs: none lost, 108 get
past these loops to a later refusal. The 249 programs behind #736 also
need per-lane size queries in loops without an access.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:34:46 +00:00
github-bot closed this pull request 2026-11-26 04:34:46 +00:00
Author
Owner

@⁠pfhandler on GitHub · 2026-11-24 20:51 UTC · original

Local patches for two issues hit while running GTA VI 1.0.2.1 through VIctory on Linux (GE-Proton 11-14, vkd3d-proton 3.2.0, RTX 4060 Ti 8 GB):

  • VICTORY_NO_HOST_PAD=1 — a connected host pad (e.g. DualShock appearing as XInput pad 0) keeps the keyboard stand-in pad from being enumerated. Hiding the host pad lets VICTORY_KEYS drive the title again.
  • VICTORY_MODE=1920x1080 — the DXGI output mode list is fixed at the console's 3840x2160. Reporting 1920x1080 instead keeps the title's render targets and VRAM use down on smaller hosts (Series S profile + 1080p settled around 3.5 GB VRAM here).

Both are local uncommitted diffs, posted here for reuse. Tested only on the configuration above.

diff --git a/crates/victory-gpu/src/dxgi.rs b/crates/victory-gpu/src/dxgi.rs
index c7f7c45..2535b68 100644
--- a/crates/victory-gpu/src/dxgi.rs
+++ b/crates/victory-gpu/src/dxgi.rs
@@ -219,6 +219,19 @@ struct Mode {
 }
 const _: () = assert!(size_of::<Mode>() == 32);
 
+/// The console's fixed output mode, overridable for hosts smaller than the
+/// console's 4K target: `VICTORY_MODE=1920x1080` reports that instead.
+fn mode_size() -> (u32, u32) {
+    const DEFAULT: (u32, u32) = (3840, 2160);
+    let Some(text) = std::env::var_os("VICTORY_MODE") else {
+        return DEFAULT;
+    };
+    let text = text.to_string_lossy();
+    text.split_once('x')
+        .and_then(|(w, h)| Some((w.trim().parse().ok()?, h.trim().parse().ok()?)))
+        .unwrap_or(DEFAULT)
+}
+
 /// The console's mode list: one 4K mode at 60 Hz (Grand Theft Auto VI looks
 /// for a 120 Hz one to allow 120 Hz frame intervals).
 /// shortcut: fixed mode, not the host display's; report the host's rates if
@@ -242,9 +255,10 @@ extern "system" fn modes(
         return MORE_DATA;
     }
     *count = 1;
+    let (width, height) = mode_size();
     let mode = Mode {
-        width: 3840,
-        height: 2160,
+        width,
+        height,
         refresh: [60, 1],
         format: 0,
         scanlines: 1, // progressive
diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs
index a411bd0..da8d66c 100644
--- a/crates/victory-hle/src/modules/gameinput.rs
+++ b/crates/victory-hle/src/modules/gameinput.rs
@@ -1134,6 +1134,11 @@ mod host {
 
     impl Source for Host {
         fn pad(&mut self, slot: usize) -> Option<PadState> {
+            // The keyboard stand-in pad only exists while no host pad is
+            // connected; this hides a host pad the title mis-handles.
+            if std::env::var_os("VICTORY_NO_HOST_PAD").is_some() {
+                return None;
+            }
             if self.empty_until[slot].is_some_and(|until| Instant::now() < until) {
                 return None;
             }
**@⁠pfhandler** on GitHub · 2026-11-24 20:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1517#issuecomment-7144159583) Local patches for two issues hit while running GTA VI 1.0.2.1 through VIctory on Linux (GE-Proton 11-14, vkd3d-proton 3.2.0, RTX 4060 Ti 8 GB): - `VICTORY_NO_HOST_PAD=1` — a connected host pad (e.g. DualShock appearing as XInput pad 0) keeps the keyboard stand-in pad from being enumerated. Hiding the host pad lets `VICTORY_KEYS` drive the title again. - `VICTORY_MODE=1920x1080` — the DXGI output mode list is fixed at the console's 3840x2160. Reporting 1920x1080 instead keeps the title's render targets and VRAM use down on smaller hosts (Series S profile + 1080p settled around 3.5 GB VRAM here). Both are local uncommitted diffs, posted here for reuse. Tested only on the configuration above. ```diff diff --git a/crates/victory-gpu/src/dxgi.rs b/crates/victory-gpu/src/dxgi.rs index c7f7c45..2535b68 100644 --- a/crates/victory-gpu/src/dxgi.rs +++ b/crates/victory-gpu/src/dxgi.rs @@ -219,6 +219,19 @@ struct Mode { } const _: () = assert!(size_of::<Mode>() == 32); +/// The console's fixed output mode, overridable for hosts smaller than the +/// console's 4K target: `VICTORY_MODE=1920x1080` reports that instead. +fn mode_size() -> (u32, u32) { + const DEFAULT: (u32, u32) = (3840, 2160); + let Some(text) = std::env::var_os("VICTORY_MODE") else { + return DEFAULT; + }; + let text = text.to_string_lossy(); + text.split_once('x') + .and_then(|(w, h)| Some((w.trim().parse().ok()?, h.trim().parse().ok()?))) + .unwrap_or(DEFAULT) +} + /// The console's mode list: one 4K mode at 60 Hz (Grand Theft Auto VI looks /// for a 120 Hz one to allow 120 Hz frame intervals). /// shortcut: fixed mode, not the host display's; report the host's rates if @@ -242,9 +255,10 @@ extern "system" fn modes( return MORE_DATA; } *count = 1; + let (width, height) = mode_size(); let mode = Mode { - width: 3840, - height: 2160, + width, + height, refresh: [60, 1], format: 0, scanlines: 1, // progressive diff --git a/crates/victory-hle/src/modules/gameinput.rs b/crates/victory-hle/src/modules/gameinput.rs index a411bd0..da8d66c 100644 --- a/crates/victory-hle/src/modules/gameinput.rs +++ b/crates/victory-hle/src/modules/gameinput.rs @@ -1134,6 +1134,11 @@ mod host { impl Source for Host { fn pad(&mut self, slot: usize) -> Option<PadState> { + // The keyboard stand-in pad only exists while no host pad is + // connected; this hides a host pad the title mis-handles. + if std::env::var_os("VICTORY_NO_HOST_PAD").is_some() { + return None; + } if self.empty_until[slot].is_some_and(|until| Instant::now() < until) { return None; } ```
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:30 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: README.md, crates/victory-core/src/config.rs, crates/victory-hle/Cargo.toml, crates/victory-hle/src/modules/gameinput/mod.rs, crates/victory-hle/src/modules/lifecycle.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1517#issuecomment-7149617749) <!-- victory-triage v1 head=c72555dbdc846d64ea6e3aae7c4f5cd3603f4632 verdict=needs-rebase at=2026-11-25T01:30:08Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `README.md`, `crates/victory-core/src/config.rs`, `crates/victory-hle/Cargo.toml`, `crates/victory-hle/src/modules/gameinput/mod.rs`, `crates/victory-hle/src/modules/lifecycle.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1517
No description provided.