input: DualSense and DualShock 4 support (HID input, adaptive triggers, light bar, haptics) #44
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/44"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ReTerryDavis/ReVIctory. Originally posted by sperm on 2026-12-04T11:58:12Z.
Right now only XInput pads reach the title. A DualSense or DualShock 4 does nothing
unless Steam Input or DS4Windows makes it look like an Xbox pad, and even then the PS5
build's trigger, light bar and haptics effects are lost.
This ports the PlayStation controller support from
VIctory xmem (Linux/Wine) to this fork,
which runs natively on Windows. It also fixes what Windows does differently over
Bluetooth.
What is changed
Input, always on. Pads XInput does not list are read over the HID API and fill
the XInput slots that are empty. These are the DualSense, DualSense Edge, DualShock 4
and any other HID gamepad. They work over USB and Bluetooth, and the Sony pads get
rumble.
IG_in the path) are skipped.VICTORY_PAD_BUTTONSsets a button order for generic pads.VICTORY_RUMBLE_GAINandVICTORY_DUALSENSE_RUMBLE=0tune the motors.gameinput/hid.rs(from xmem, with the Bluetooth rumble fix below) and asmall change to
gameinput.rs.PS5 effects, opt-in:
VICTORY_DUALSENSE=1/-DualSense. These are what thetitle's PS5 build does with the pad:
acts on rumble only; the PS5 build's trigger and light bar effects are decoded from
that list and sent to the pad (
pad_effects.rs,dualsense.rs).title's trigger producer (
vehicle_notch.rs).PadHapticssubmix is played on the controller'sactuators (channels 3/4 of its USB audio endpoint) through WASAPI (
haptics.rs).Haptics need USB: over Bluetooth, Windows has no audio endpoint for the pad.
(
ps5_rumble.rs).VICTORY_DUALSHOCK=1/-DualShockshows the light bar colours on a DualShock 4.What Windows needed that Linux did not
xmem writes output reports to Linux's
/dev/hidrawNthrough Wine'sZ:drive. Heredualsense.rsfinds the pad with SetupAPI/HidD_*, opens it shared, and writes withWriteFile. Three differences came up:device declares. A Bluetooth DualSense declares 547 bytes (its longest report),
but the pad reads a 78-byte report with its CRC at byte 74.
the declared length.
sony_rumbleput the CRC at the end of the declaredlength: byte 543 of 547 on Windows. The pad dropped every rumble report. It now
goes at byte 74, for the DualSense and DualShock 4 alike.
"lightbar setup: light out" (valid_flag2 bit 1, lightbar_setup 0x02). Linux's
hid-playstationsends that when the pad connects; Windows sends nothing, so ourcolours were ignored. The output thread now sends it once per connection, then the
current colour (the default blue until the title names one).
The trigger encodings and their tests are xmem's and are unchanged.
Other changes.
tls::nearbecomespub(crate)(the notch hook uses it).windows-sysinvictory-loaderandvictory-hle.windowsinvictory-loader.apps/victory/src/run.rsnext to the otherapply_askedcalls.
-DualSense/-DualShockswitches are added toscripts/play.ps1.Safety. Every hook checks the title's code before patching. On a build it doesn't
recognise, it logs a warning (
not hooked … another build?) and stays off. WithoutVICTORY_DUALSENSE/VICTORY_DUALSHOCK, nothing is patched; only the HID inputreader is new.
Using the launcher. The launcher passes only its own settings to the game and
drops
VICTORY_*variables set in the shell. PutVICTORY_DUALSENSE=1in thelauncher's extra settings.
Tested
cargo test -p victory-loader: the new modules' 13 tests pass. They include reportsizing at the lengths Windows declares (USB 48/64, Bluetooth 547), the light bar
release report, and a padded DualShock 4 Bluetooth report.
cargo test -p victory-hle -- gameinput: 21 pass, including rumble at 547 bytes forboth pads. The 1 hardware test is ignored.
cargo clippy -p victory-loader -p victory-hle -p victory --all-targets: nowarnings.
cargo xtask policy: ok.cargo build --locked --release -p victory: ok.pad-effect handler, the rumble emitter, the haptics mixer step and the notch call.
VICTORY_DUALSENSE: pad works, no effectsCredits
Ported from VIctory xmem, at 0fd7614:
delacor/VIctory a9553ae72 (author marquezini).
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.