gameinput: support PS5 controllers (DualSense, DualSense Edge) without a remapper #42

Closed
github-bot wants to merge 287 commits from github-bot/gh-42 into main AGit
Owner

@⁠pawcijo on GitHub · 2026-11-26 17:58 UTC · original
pawcijo:feat/dualsense-input → main · +1793 −299 · 21 files · 3 commits · closed without merging

Summary

PS5 controllers are not XInput devices, so unless Steam Input or DS4Windows remaps them, the title never sees them. This PR reads them directly over HID, on both USB and Bluetooth.

  • New crates/victory-hle/src/modules/gameinput/dualsense.rs:
    • A scan thread looks for Sony DualSense (054C:0CE6) and DualSense Edge (054C:0DF2) every 2 s.
    • Each controller gets a reader thread that keeps its latest state. The controller is dropped when a read fails (disconnect).
    • On Bluetooth, the reader requests feature report 0x05 to switch the controller to full 0x31 reports, as Linux hid-playstation does. The short 0x01 Bluetooth report is parsed too.
  • In gameinput.rs, PS5 controllers fill the host slots XInput leaves empty, so the one-pad merge, connect/disconnect callbacks and the scripted keys work as before.
  • Set VICTORY_DUALSENSE=0 to turn this off when a remapper already presents the controller as an Xbox pad. Otherwise, with VICTORY_ONE_PAD=0, it would appear twice. With the default single merged pad, the duplicate does no harm.
  • Adds the Win32_Devices_DeviceAndDriverInstallation and Win32_Devices_HumanInterfaceDevice features to windows-sys.
  • The README documents the support and the button mapping.

Button mapping

PS5 Console pad
Cross / Circle / Square / Triangle A / B / X / Y
Options Menu
Create, touchpad click View
L1 / R1, L2 / R2, L3 / R3 shoulders, triggers, stick clicks
D-pad, sticks D-pad, sticks (Y flipped so up is positive)

The PS button and the mute button are not mapped.

Not included

  • Rumble on PS5 controllers. XInput rumble is unchanged.
  • DualShock 4, which uses a different report layout.

Testing

  • cargo test -p victory-hle --lib gameinput: 13 tests pass, including 3 new ones that parse USB, full Bluetooth and short Bluetooth reports.
  • clippy reports no warnings in the new code.
  • Not yet tried with a physical controller.

🤖 Generated with Claude Code

**@⁠pawcijo** on GitHub · 2026-11-26 17:58 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/42) `pawcijo:feat/dualsense-input` → `main` · +1793 −299 · 21 files · 3 commits · closed without merging ## Summary PS5 controllers are not XInput devices, so unless Steam Input or DS4Windows remaps them, the title never sees them. This PR reads them directly over HID, on both USB and Bluetooth. - New `crates/victory-hle/src/modules/gameinput/dualsense.rs`: - A scan thread looks for Sony DualSense (`054C:0CE6`) and DualSense Edge (`054C:0DF2`) every 2 s. - Each controller gets a reader thread that keeps its latest state. The controller is dropped when a read fails (disconnect). - On Bluetooth, the reader requests feature report `0x05` to switch the controller to full `0x31` reports, as Linux `hid-playstation` does. The short `0x01` Bluetooth report is parsed too. - In `gameinput.rs`, PS5 controllers fill the host slots XInput leaves empty, so the one-pad merge, connect/disconnect callbacks and the scripted keys work as before. - Set `VICTORY_DUALSENSE=0` to turn this off when a remapper already presents the controller as an Xbox pad. Otherwise, with `VICTORY_ONE_PAD=0`, it would appear twice. With the default single merged pad, the duplicate does no harm. - Adds the `Win32_Devices_DeviceAndDriverInstallation` and `Win32_Devices_HumanInterfaceDevice` features to `windows-sys`. - The README documents the support and the button mapping. ## Button mapping | PS5 | Console pad | |-----|-------------| | Cross / Circle / Square / Triangle | A / B / X / Y | | Options | Menu | | Create, touchpad click | View | | L1 / R1, L2 / R2, L3 / R3 | shoulders, triggers, stick clicks | | D-pad, sticks | D-pad, sticks (Y flipped so up is positive) | The PS button and the mute button are not mapped. ## Not included - Rumble on PS5 controllers. XInput rumble is unchanged. - DualShock 4, which uses a different report layout. ## Testing - `cargo test -p victory-hle --lib gameinput`: 13 tests pass, including 3 new ones that parse USB, full Bluetooth and short Bluetooth reports. - clippy reports no warnings in the new code. - Not yet tried with a physical controller. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
PS5 pads are not XInput devices, so without a remapper the title never
saw them. A scan thread finds them over USB and Bluetooth (asking for
the calibration feature report switches Bluetooth to full reports), and
a reader thread per pad keeps its latest state. They take the host slots
XInput leaves empty. VICTORY_DUALSENSE=0 turns this off when a remapper
already shows the pad through XInput. No rumble yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:03:12 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 19:18 UTC · original

The report parser has coverage for USB and Bluetooth. Before enabling this by default, could you check reconnecting over both transports and running alongside an XInput remapper? The same physical controller can be exposed through both paths, so please check whether it occupies two slots and document when to use VICTORY_DUALSENSE=0.

**@⁠TaynanGT** on GitHub · 2026-11-26 19:18 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/42#issuecomment-7201446437) The report parser has coverage for USB and Bluetooth. Before enabling this by default, could you check reconnecting over both transports and running alongside an XInput remapper? The same physical controller can be exposed through both paths, so please check whether it occupies two slots and document when to use `VICTORY_DUALSENSE=0`.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 20:01 UTC · original

I added XInput priority and stable HID slots in 27e97585. With the setting unset, a direct DualSense works when XInput is empty and a remapped pad is read through XInput once. VICTORY_DUALSENSE=1 allows a separate Xbox pad and a direct DualSense to coexist. The synthetic tests cover source selection and a surviving pad retaining its slot. For the hardware test, please try USB and Bluetooth, reconnect one of two pads, and verify a remapped button fires a single action.

**@⁠TaynanGT** on GitHub · 2026-11-26 20:01 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/42#issuecomment-7202206166) I added XInput priority and stable HID slots in `27e97585`. With the setting unset, a direct DualSense works when XInput is empty and a remapped pad is read through XInput once. `VICTORY_DUALSENSE=1` allows a separate Xbox pad and a direct DualSense to coexist. The synthetic tests cover source selection and a surviving pad retaining its slot. For the hardware test, please try USB and Bluetooth, reconnect one of two pads, and verify a remapped button fires a single action.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 20:04 UTC · original

Thanks for putting together the direct HID support, @⁠pawcijo. I ran cargo test --locked -p victory-hle --lib gameinput -- --test-threads=1 on Windows at 27e97585. All 15 tests passed, including USB and both Bluetooth report types, XInput priority and the slot-retention test. Windows did not show a connected DualSense here, so USB/Bluetooth reconnect and remapper behavior still need a physical-pad check.

**@⁠TaynanGT** on GitHub · 2026-11-26 20:04 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/42#issuecomment-7202263683) Thanks for putting together the direct HID support, @⁠pawcijo. I ran `cargo test --locked -p victory-hle --lib gameinput -- --test-threads=1` on Windows at `27e97585`. All 15 tests passed, including USB and both Bluetooth report types, XInput priority and the slot-retention test. Windows did not show a connected DualSense here, so USB/Bluetooth reconnect and remapper behavior still need a physical-pad check.
Checked on hardware with two DualSenses, over USB and Bluetooth.

A pad turned off or out of range over Bluetooth can stay listed by
Windows, and a blocking read then waits for ever with its last buttons
held. Reads are now overlapped: after 500 ms without a report the pad's
state is dropped and it is asked for a feature report; a pad that does
not answer is closed, and the scan opens it again when it is back.

A pad on USB and Bluetooth at once is one pad: its address from the
pairing report (0x09) is the same on both, so the second path is not
opened, and it is remembered so it is not reopened every scan. When the
open path goes away (Bluetooth dropped with the cable in), the other one
takes over.

Built on the XInput-first modes and stable slots: those are unchanged.
The README lists which VICTORY_DUALSENSE value fits which setup. An
ignored test, probe_host_pads, prints what each host slot holds while
pads are plugged in and out.

Also carries the in-progress runtime changes made alongside (dstorage,
xmem, lifecycle, xgamesave and others).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠pawcijo on GitHub · 2026-11-26 20:21 UTC · original

Thanks for the review. I tested reconnects on both transports and with two pads, on real hardware: two DualSenses, Windows 11, no remapper. Everything ran on the branch head ab9927e, which is built on your 27e9758.

Results:

  • Bluetooth off and on: the slot clears within about 0.5 s, with no buttons left held. The pad comes back in the same slot.
  • USB unplugged and plugged back in: the slot clears straight away, and the pad comes back in the same slot.
  • Two pads, the one in slot 0 leaves: the other pad stays in slot 1. The returning pad gets slot 0 back.
  • One pad on USB and Bluetooth at once: it takes one slot. Both paths report the same Bluetooth address (feature report 0x09), so the second path isn't opened.
  • Bluetooth dropped with the cable still in: USB takes over in the same slot within about a second.

What ab9927e adds on top of your commit:

  • Overlapped reads: a Bluetooth pad that's turned off can stay listed by Windows, so a blocking read would wait forever with its last buttons held. After 500 ms without a report, the pad's state is dropped and the pad is asked for a feature report. A pad that doesn't answer is closed and picked up again by the next scan.
  • Duplicate check: a pad on both transports is read once, matched by its address. The second path is remembered, so it isn't reopened on every scan, and it takes over when the open path goes away.
  • Your parts are unchanged: the XInput-first modes and slots().
  • README: a table of which VICTORY_DUALSENSE value fits which setup.
  • Hardware probe: an ignored test, probe_host_pads, prints what each host slot holds while pads are plugged in and out:
    cargo test -p victory-hle --lib probe_host_pads -- --ignored --nocapture

Not tested: running alongside DS4Windows or DualSenseX, because this machine has no ViGEm or HidHide. With the default mode, any XInput pad switches input to XInput only, so a remapped pad shouldn't be read twice. That conclusion comes from the code, not a test.

**@⁠pawcijo** on GitHub · 2026-11-26 20:21 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/42#issuecomment-7202586264) Thanks for the review. I tested reconnects on both transports and with two pads, on real hardware: two DualSenses, Windows 11, no remapper. Everything ran on the branch head `ab9927e`, which is built on your `27e9758`. **Results:** - **Bluetooth off and on:** the slot clears within about 0.5 s, with no buttons left held. The pad comes back in the same slot. - **USB unplugged and plugged back in:** the slot clears straight away, and the pad comes back in the same slot. - **Two pads, the one in slot 0 leaves:** the other pad stays in slot 1. The returning pad gets slot 0 back. - **One pad on USB and Bluetooth at once:** it takes one slot. Both paths report the same Bluetooth address (feature report 0x09), so the second path isn't opened. - **Bluetooth dropped with the cable still in:** USB takes over in the same slot within about a second. **What `ab9927e` adds on top of your commit:** - **Overlapped reads:** a Bluetooth pad that's turned off can stay listed by Windows, so a blocking read would wait forever with its last buttons held. After 500 ms without a report, the pad's state is dropped and the pad is asked for a feature report. A pad that doesn't answer is closed and picked up again by the next scan. - **Duplicate check:** a pad on both transports is read once, matched by its address. The second path is remembered, so it isn't reopened on every scan, and it takes over when the open path goes away. - **Your parts are unchanged:** the XInput-first modes and `slots()`. - **README:** a table of which `VICTORY_DUALSENSE` value fits which setup. - **Hardware probe:** an ignored test, `probe_host_pads`, prints what each host slot holds while pads are plugged in and out: `cargo test -p victory-hle --lib probe_host_pads -- --ignored --nocapture` **Not tested:** running alongside DS4Windows or DualSenseX, because this machine has no ViGEm or HidHide. With the default mode, any XInput pad switches input to XInput only, so a remapped pad shouldn't be read twice. That conclusion comes from the code, not a test.
github-bot closed this pull request 2026-11-27 00:42:16 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 21:26 UTC · original

Thanks for testing both transports, two pads, and the USB takeover on real hardware. The prospective merge against current main also changes DStorage, XAsync, and several other HLE modules. I’ll prepare an input-only integration on current main so the tested reconnect fixes can be reviewed and checked on that base.

**@⁠TaynanGT** on GitHub · 2026-11-26 21:26 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/42#issuecomment-7203722952) Thanks for testing both transports, two pads, and the USB takeover on real hardware. The prospective merge against current `main` also changes DStorage, XAsync, and several other HLE modules. I’ll prepare an input-only integration on current `main` so the tested reconnect fixes can be reviewed and checked on that base.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 21:29 UTC · original

The input-only integration is in #68, with your authorship preserved. It includes a small follow-up that sizes the calibration and pairing buffers from HIDP_CAPS.FeatureReportByteLength. Windows CI is running there. Your hardware results at ab9927e are linked in the new PR.

**@⁠TaynanGT** on GitHub · 2026-11-26 21:29 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/42#issuecomment-7203784547) The input-only integration is in #68, with your authorship preserved. It includes a small follow-up that sizes the calibration and pairing buffers from `HIDP_CAPS.FeatureReportByteLength`. Windows CI is running there. Your hardware results at `ab9927e` are linked in the new PR.
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-26 21:37 UTC · original

The input changes are now on main through #68, with your authorship preserved. Windows CI passed on the input-only integration. If you get a chance to retest the final report-buffer sizing on your pads, please share the results in #68.

**@⁠TaynanGT** on GitHub · 2026-11-26 21:37 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/42#issuecomment-7203906063) The input changes are now on main through #68, with your authorship preserved. Windows CI passed on the input-only integration. If you get a chance to retest the final report-buffer sizing on your pads, please share the results in #68.
github-bot referenced this pull request from a commit 2026-11-30 15:24:02 +00:00

Pull request closed

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