Restore native PS5 DualSense HID fallback in victory-hle #367

Closed
github-bot wants to merge 1 commit from github-bot/gh-367 into a-publier AGit
Owner

@⁠nouveeeeec on GitHub · 2026-11-26 22:35 UTC · original
nouveeeeec:feat/dualsense-hid → a-publier · +530 −10 · 4 files · 1 commits · closed without merging

What this does

Ports the native Windows HID reader for Sony DualSense (0x054c:0x0ce6) and DualSense Edge (0x054c:0x0df2) from the previous branch into the new codebase so PlayStation controllers work out of the box without DS4Windows or Steam Input.

Changes

  • Added crates/victory-hle/src/modules/dualsense.rs and registered it in mod.rs.
  • Enabled Win32_Devices_DeviceAndDriverInstallation and Win32_Devices_HumanInterfaceDevice features for windows-sys in crates/victory-hle/Cargo.toml.
  • Updated Host::pad() in crates/victory-hle/src/modules/gameinput.rs to fall back to dualsense::latest() when XInput slot 0 is empty (feeds cleanly into VICTORY_ONE_PAD).

Testing

  • Built with cargo build --release -p victory.
  • Verified in-game (prologue prison + boat sequence) on Windows 11 with a PS5 DualSense controller.
**@⁠nouveeeeec** on GitHub · 2026-11-26 22:35 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/367) `nouveeeeec:feat/dualsense-hid` → `a-publier` · +530 −10 · 4 files · 1 commits · closed without merging ### What this does Ports the native Windows HID reader for Sony DualSense (`0x054c:0x0ce6`) and DualSense Edge (`0x054c:0x0df2`) from the previous branch into the new codebase so PlayStation controllers work out of the box without DS4Windows or Steam Input. ### Changes - Added `crates/victory-hle/src/modules/dualsense.rs` and registered it in `mod.rs`. - Enabled `Win32_Devices_DeviceAndDriverInstallation` and `Win32_Devices_HumanInterfaceDevice` features for `windows-sys` in `crates/victory-hle/Cargo.toml`. - Updated `Host::pad()` in `crates/victory-hle/src/modules/gameinput.rs` to fall back to `dualsense::latest()` when XInput slot 0 is empty (feeds cleanly into `VICTORY_ONE_PAD`). ### Testing - Built with `cargo build --release -p victory`. - Verified in-game (prologue prison + boat sequence) on Windows 11 with a PS5 DualSense controller.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:58:36 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-27 02:19 UTC · original

A crash this brings back, found by reading the diff at ed96378 (not run):

device_paths() copies each HID path without its terminating NUL (crates/victory-hle/src/modules/dualsense.rs:291, std::slice::from_raw_parts(path, len).to_vec()), and open_pad() passes path.as_ptr() to CreateFileW (:160), which reads up to a NUL, past the end of the copy. #40 and #156 fix this same line in the earlier reader: with no DualSense connected the scan runs every 2 s, and once a copy ends at a heap page the run stops with an access violation (#156 has the stack). Their fix is to push the NUL onto the owned path. The same reader is open upstream as Marvisak/VIctory#150, where this was reported too.

Overlap: #420 also adds a DualSense HID reader (several pads, Bluetooth, rumble, VICTORY_DUALSENSE=0), and it does push the NUL (gameinput/dualsense.rs). The two conflict in crates/victory-hle/src/modules/gameinput.rs, so only one of them can go in as is.

**@⁠upipibi** on GitHub · 2026-11-27 02:19 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/367#issuecomment-7208019194) A crash this brings back, found by reading the diff at `ed96378` (not run): `device_paths()` copies each HID path without its terminating NUL (`crates/victory-hle/src/modules/dualsense.rs:291`, `std::slice::from_raw_parts(path, len).to_vec()`), and `open_pad()` passes `path.as_ptr()` to `CreateFileW` (`:160`), which reads up to a NUL, past the end of the copy. #40 and #156 fix this same line in the earlier reader: with no DualSense connected the scan runs every 2 s, and once a copy ends at a heap page the run stops with an access violation (#156 has the stack). Their fix is to push the NUL onto the owned path. The same reader is open upstream as Marvisak/VIctory#150, where this was reported too. Overlap: #420 also adds a DualSense HID reader (several pads, Bluetooth, rumble, `VICTORY_DUALSENSE=0`), and it does push the NUL (`gameinput/dualsense.rs`). The two conflict in `crates/victory-hle/src/modules/gameinput.rs`, so only one of them can go in as is.
github-bot closed this pull request 2026-11-27 05:36:12 +00:00
Author
Owner

@⁠nouveeeeec on GitHub · 2026-11-27 05:33 UTC · original

A crash this brings back, found by reading the diff at ed96378 (not run):

device_paths() copies each HID path without its terminating NUL (crates/victory-hle/src/modules/dualsense.rs:291, std::slice::from_raw_parts(path, len).to_vec()), and open_pad() passes path.as_ptr() to CreateFileW (:160), which reads up to a NUL, past the end of the copy. #40 and #156 fix this same line in the earlier reader: with no DualSense connected the scan runs every 2 s, and once a copy ends at a heap page the run stops with an access violation (#156 has the stack). Their fix is to push the NUL onto the owned path. The same reader is open upstream as Marvisak/VIctory#150, where this was reported too.

Overlap: #420 also adds a DualSense HID reader (several pads, Bluetooth, rumble, VICTORY_DUALSENSE=0), and it does push the NUL (gameinput/dualsense.rs). The two conflict in crates/victory-hle/src/modules/gameinput.rs, so only one of them can go in as is.

**@⁠nouveeeeec** on GitHub · 2026-11-27 05:33 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/367#issuecomment-7210734386) > A crash this brings back, found by reading the diff at `ed96378` (not run): > > `device_paths()` copies each HID path without its terminating NUL (`crates/victory-hle/src/modules/dualsense.rs:291`, `std::slice::from_raw_parts(path, len).to_vec()`), and `open_pad()` passes `path.as_ptr()` to `CreateFileW` (`:160`), which reads up to a NUL, past the end of the copy. #40 and #156 fix this same line in the earlier reader: with no DualSense connected the scan runs every 2 s, and once a copy ends at a heap page the run stops with an access violation (#156 has the stack). Their fix is to push the NUL onto the owned path. The same reader is open upstream as [Marvisak/VIctory#150](https://github.com/Marvisak/VIctory/pull/150), where this was reported too. > > Overlap: #420 also adds a DualSense HID reader (several pads, Bluetooth, rumble, `VICTORY_DUALSENSE=0`), and it does push the NUL (`gameinput/dualsense.rs`). The two conflict in `crates/victory-hle/src/modules/gameinput.rs`, so only one of them can go in as is.
Author
Owner

@⁠nouveeeeec on GitHub · 2026-11-27 05:33 UTC · original

Thanks for catching the missing NUL terminator and pointing out #420! Since #420 is more complete (multi-pad, rumble, VICTORY_DUALSENSE=0) and already handles the NUL termination properly, I'll close this PR in favor of #420.

**@⁠nouveeeeec** on GitHub · 2026-11-27 05:33 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/367#issuecomment-7210738454) Thanks for catching the missing NUL terminator and pointing out #420! Since #420 is more complete (multi-pad, rumble, `VICTORY_DUALSENSE=0`) and already handles the NUL termination properly, I'll close this PR in favor of #420.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.