GameInput: a wired DualSense takes the title's rumble #715

Open
github-bot wants to merge 4 commits from github-bot/gh-715 into main AGit
Owner

@⁠MrCheese5 on GitHub · 2026-11-24 04:01 UTC · original
MrCheese5:ds-c-rumble → main · +833 −5 · 8 files · 4 commits · open

Stacked on #552, #709 and #710; only the top commit belongs here.

When a DualSense over USB is the gamepad (no XInput controller answers), the title's low and high rumble from SetRumbleState now reaches the DualSense's two motors as compatible vibration in output report 0x02. Before this change the rumble went to an XInput controller that was not there. A writer thread sends the report only when it changes, on a write handle of its own, so the title's thread never waits on HID.

The reader from #552 becomes overlapped and also waits on a stop event. At process exit, the NtTerminateProcess hook calls playstation::shutdown(), which cancels the pending read and sends the motors to zero, because a DualSense keeps rumbling at the last level it got until it is switched off. Two seconds without a report count as a disconnect, because a controller that leaves Bluetooth range can leave a read pending without an error.

Sending a report also sets the light bar and player LEDs to the report's defaults (dim blue, the middle player LED). A DualShock 4 still only reads.

What is in it

  • crates/xcl/src/hle/playstation.rs: overlapped reads with a stop event, the writer thread, rumble() and shutdown(), and a test that the report carries the levels and is sent only on change
  • crates/xcl/src/hle/gameinput.rs: set_rumble_state goes to the DualSense when no XInput pad is connected
  • crates/xcl/src/eh.rs: shutdown() at process exit
  • README.md: a wired DualSense rumbles

Tested

  • RTX 4090 (driver 621.14), i9-14900K, Windows 11 26200, Rust stable-x86_64-pc-windows-msvc, debug tests, release smoke runs
  • cargo test -p xcl --lib playstation: 3 passed
  • cargo test --workspace -- --test-threads=1: 699 passed, 0 failed, 41 ignored; SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64)
  • Single-threaded on purpose: with --test-threads=4, GPU tests on this machine hang or lose the device tonight on main too (bdab194 and 91f9a5e; bdab194 had passed with 4 threads earlier the same night, and the driver logs GPU errors). Single-threaded, main 91f9a5e passes (cargo test -p xcl --lib -- --test-threads=1: 647 passed, 0 failed).
  • On a USB DualSense (054c:0ce6), through a test harness that was not committed: the controller was found and read, and both output reports (motors 153/76, then 0/0) were taken (WriteFile succeeded). After shutdown() the read loop ended.

Regression run
Both runs use a fresh data root of their own. The title is not driven by a controller during the run, so this shows that nothing else changes, not the new path.

xcl-smoke v1
commit: 91f9a5e9f03156ea82dc55a18f7704862da7a5db
gpu: NVIDIA GeForce RTX 4090
title: Xbox
seconds: 60
exit: 0x0
frames shown: 811 (PresentX 811)
presents per 2 s (last 3): 37 34 36
device removals: 0
crashes: 0
peak commit: 15536 MB
xcl-smoke v1
commit: e014fbcb63d1647c5d1bd884b070591fcdf39ccf
gpu: NVIDIA GeForce RTX 4090
title: Xbox
seconds: 60
exit: 0x0
frames shown: 818 (PresentX 818)
presents per 2 s (last 3): 36 35 35
device removals: 0
crashes: 0
peak commit: 15534 MB

Not tested

  • Rumble felt in a title: the retail title's menus do not rumble during the smoke run, and nobody held the controller.
  • DualSense over Bluetooth (#552 does not read it) and DualShock 4 rumble (not part of this PR).
  • Whether a controller out of Bluetooth range really leaves a read pending: the 2 s timeout covers that case, but it was not reproduced here.
  • AMD and other NVIDIA GPUs (the change has no GPU code).

AI use

  • Claude Code with Claude Opus 5.5: wrote the code, the tests and this description; the hardware checks above are runs on the machine named under Tested.

🤖 Generated with Claude Code

**@⁠MrCheese5** on GitHub · 2026-11-24 04:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/715) `MrCheese5:ds-c-rumble` → `main` · +833 −5 · 8 files · 4 commits · open Stacked on #552, #709 and #710; only the top commit belongs here. When a DualSense over USB is the gamepad (no XInput controller answers), the title's low and high rumble from `SetRumbleState` now reaches the DualSense's two motors as compatible vibration in output report 0x02. Before this change the rumble went to an XInput controller that was not there. A writer thread sends the report only when it changes, on a write handle of its own, so the title's thread never waits on HID. The reader from #552 becomes overlapped and also waits on a stop event. At process exit, the `NtTerminateProcess` hook calls `playstation::shutdown()`, which cancels the pending read and sends the motors to zero, because a DualSense keeps rumbling at the last level it got until it is switched off. Two seconds without a report count as a disconnect, because a controller that leaves Bluetooth range can leave a read pending without an error. Sending a report also sets the light bar and player LEDs to the report's defaults (dim blue, the middle player LED). A DualShock 4 still only reads. **What is in it** - `crates/xcl/src/hle/playstation.rs`: overlapped reads with a stop event, the writer thread, `rumble()` and `shutdown()`, and a test that the report carries the levels and is sent only on change - `crates/xcl/src/hle/gameinput.rs`: `set_rumble_state` goes to the DualSense when no XInput pad is connected - `crates/xcl/src/eh.rs`: `shutdown()` at process exit - `README.md`: a wired DualSense rumbles **Tested** - RTX 4090 (driver 621.14), i9-14900K, Windows 11 26200, Rust stable-x86_64-pc-windows-msvc, debug tests, release smoke runs - `cargo test -p xcl --lib playstation`: 3 passed - `cargo test --workspace -- --test-threads=1`: 699 passed, 0 failed, 41 ignored; SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64), `gpu_wave32_program_in_wave64_hardware` (no wave64) - Single-threaded on purpose: with `--test-threads=4`, GPU tests on this machine hang or lose the device tonight on `main` too (bdab194 and 91f9a5e; bdab194 had passed with 4 threads earlier the same night, and the driver logs GPU errors). Single-threaded, `main` 91f9a5e passes (`cargo test -p xcl --lib -- --test-threads=1`: 647 passed, 0 failed). - On a USB DualSense (054c:0ce6), through a test harness that was not committed: the controller was found and read, and both output reports (motors 153/76, then 0/0) were taken (`WriteFile` succeeded). After `shutdown()` the read loop ended. **Regression run** Both runs use a fresh data root of their own. The title is not driven by a controller during the run, so this shows that nothing else changes, not the new path. ``` xcl-smoke v1 commit: 91f9a5e9f03156ea82dc55a18f7704862da7a5db gpu: NVIDIA GeForce RTX 4090 title: Xbox seconds: 60 exit: 0x0 frames shown: 811 (PresentX 811) presents per 2 s (last 3): 37 34 36 device removals: 0 crashes: 0 peak commit: 15536 MB ``` ``` xcl-smoke v1 commit: e014fbcb63d1647c5d1bd884b070591fcdf39ccf gpu: NVIDIA GeForce RTX 4090 title: Xbox seconds: 60 exit: 0x0 frames shown: 818 (PresentX 818) presents per 2 s (last 3): 36 35 35 device removals: 0 crashes: 0 peak commit: 15534 MB ``` **Not tested** - Rumble felt in a title: the retail title's menus do not rumble during the smoke run, and nobody held the controller. - DualSense over Bluetooth (#552 does not read it) and DualShock 4 rumble (not part of this PR). - Whether a controller out of Bluetooth range really leaves a read pending: the 2 s timeout covers that case, but it was not reproduced here. - AMD and other NVIDIA GPUs (the change has no GPU code). **AI use** - Claude Code with Claude Opus 5.5: wrote the code, the tests and this description; the hardware checks above are runs on the machine named under **Tested**. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Windows gives PlayStation controllers to XInput only through extra
software (Steam Input, DS4Windows), so a player with one had no gamepad.
They are now read as HID devices (input report 0x01) on a thread of
their own, and used when no XInput controller answers: buttons, sticks
and triggers; no rumble or light bar. DualShock 4 over USB or Bluetooth
(the same first bytes), DualSense over USB. XCL_PLAYSTATION_PAD=0 turns
it off.
A pure builder for the DualSense's USB output report 0x02: compatible
rumble (or the actuators left to audio haptics), the two adaptive trigger
effect blocks (0x05 off, 0x21 feedback, 0x25 weapon, 0x26 vibration over
10 zones of travel), light bar, player and mute LEDs, the light bar setup
and the motor power attenuation. Byte offsets follow Linux's
hid-playstation output report layout; both tests check the bytes.

Nothing calls it yet: the PlayStation controller reader (#552) only reads.
The following changes use it for rumble and the triggers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Over USB the DualSense is also a 4-channel audio output whose channels 3
and 4 drive its two voice-coil actuators. dualsense_haptics finds that
output by name with WASAPI and plays, on a thread of its own, a 100 Hz
tone for the title's big motor (mostly left) and a 230 Hz tone for the
small one (mostly right). The amplitudes glide over 10 ms so level
changes do not click, and the speaker channels stay silent. start()
refuses an output with fewer than 4 channels, so the caller can keep
compatible rumble.

Nothing starts it yet. The windows crate gets three features for the
property store (no new crates). The tests check the synthesiser: only
the actuator channels play, the cross-mix, the glide and the tone
frequency.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a DualSense over USB is the gamepad (no XInput controller), the
title's low and high rumble levels from SetRumbleState now reach its two
motors as compatible vibration in output report 0x02, instead of going
to an XInput controller that is not there. A writer thread sends the
report only when it changes, on a write handle of its own, so the
title's thread never waits on HID.

Reads become overlapped and wait on a stop event too: at process exit
the NtTerminateProcess hook calls shutdown(), which cancels the pending
read and sends the motors to zero (a DualSense keeps rumbling at the last
level it got until it is switched off). Two seconds without a report
count as a disconnect, because a controller that drops out of Bluetooth
range can leave a read pending with no error.

Sending a report also sets the light bar and player LEDs to the report's
defaults (dim blue, the middle LED). Checked on a USB DualSense
(054c:0ce6): it was found and read, and both rumble reports were taken.

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

@⁠futurepro62 on GitHub · 2026-11-24 04:46 UTC · original

Tested exact head e014fbc (on its base 91f9a5e).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 699 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.

Not tested

  • A wired DualSense and rumble (none connected here), a retail title or scripts/smoke.ps1 (no title on this machine), AMD, a release build.

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-24 04:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/715#issuecomment-7122333634) Tested exact head `e014fbc` (on its base `91f9a5e`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **699 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. **Not tested** - A wired DualSense and rumble (none connected here), a retail title or `scripts/smoke.ps1` (no title on this machine), AMD, a release build. **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠MesshM on GitHub · 2026-11-24 04:47 UTC · original

Test run of e014fbcb63d1647c5d1bd884b070591fcdf39ccf on AMD RDNA4. I merged it onto current main 64b3f35 locally (clean merge), so the tree tested includes the stack under it (#552, #709, #710).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 708 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 667 passed, 0 failed, 21 ignored
  • 0 SKIPPED; dualsense_rumble_is_sent_when_it_changes and the dualsense_haptics tests pass (no DualSense attached here, so no output report reached a device).

Review: Rumble goes to the DualSense only when it is the gamepad (no XInput controller answers) and only when the value changes. I reviewed the top commit only.

Not tested: no retail title or regression run (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's head on its old base was not run, only its merge onto main.

Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

**@⁠MesshM** on GitHub · 2026-11-24 04:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/715#issuecomment-7122345654) Test run of `e014fbcb63d1647c5d1bd884b070591fcdf39ccf` on AMD RDNA4. I merged it onto current `main` `64b3f35` locally (clean merge), so the tree tested includes the stack under it (#552, #709, #710). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 `stable-x86_64-pc-windows-msvc`, debug - `cargo build --workspace` + `cargo test --workspace -- --test-threads=4` on the merge: **708 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 667 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; `dualsense_rumble_is_sent_when_it_changes` and the `dualsense_haptics` tests pass (no DualSense attached here, so no output report reached a device). **Review:** Rumble goes to the DualSense only when it is the gamepad (no XInput controller answers) and only when the value changes. I reviewed the top commit only. **Not tested:** no retail title or regression run (I have no unpacked game), no `XCL_SAMPLE_*` tests, release build; the PR's head on its old base was not run, only its merge onto `main`. Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 06:18 UTC · original

Empirical test report (e014fbcb)

Hardware / environment

  • PR #715 head: e014fbcb63d1647c5d1bd884b070591fcdf39ccf (detached checkout).
  • Windows x64 build 10.0.26200.9974, AMD Ryzen 7 3800X 8-Core Processor.
  • Rust 1.100.0 (0ef1bc386, x86_64-pc-windows-msvc), Cargo 1.100.0, DXC 1.9.2609.5 (01b62ad47).
  • The workspace test build and focused run both used the unoptimized test profile with debug info and incremental compilation disabled. The focused run set XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. Both commands ran outside Invoke-ArcTest.ps1 with zero Arc GPU mutex hold.

Commands and results

  • cargo test --workspace --no-run exited 0 and built 15 test executables. It executed zero tests. The compiler emitted a deprecation warning for AtomicU32::fetch_update in XGameRuntime.
  • cargo test -p xcl --lib -- hle::dualsense_haptics::tests:: hle::dualsense_report::tests:: hle::playstation::tests:: exited 0. The captured output reports 7 passed, 0 failed, 0 ignored, and 673 filtered out. It contains 0 lines matching the case-sensitive pattern ^SKIPPED .

Observed behavior

  • Rumble state produced an encoded USB report, suppressed repeat reports for unchanged values, and produced a zero-motor report when rumble stopped.
  • Report tests checked USB motor and trigger fields, LED and attenuation fields, and encoding for off, feedback, weapon, and vibration trigger effects.
  • Synthetic input tests checked matching DualShock 4 and DualSense USB gamepad states, rejection of short or unsupported reports, and HID identifier matching, including exclusion of Bluetooth DualSense.
  • Haptic synthesis tests checked silence at zero rumble, actuator channel routing and amplitude ramping, and the small motor's 230 Hz tone.

Not tested

  • Physical DualSense hardware, the full GPU workspace suite, and game smoke runs were omitted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr715-focused.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 06:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/715#issuecomment-7154655130) ### Empirical test report (e014fbcb) **Hardware / environment** - PR #715 head: `e014fbcb63d1647c5d1bd884b070591fcdf39ccf` (detached checkout). - Windows x64 build 10.0.26200.9974, AMD Ryzen 7 3800X 8-Core Processor. - Rust 1.100.0 (`0ef1bc386`, `x86_64-pc-windows-msvc`), Cargo 1.100.0, DXC 1.9.2609.5 (`01b62ad47`). - The workspace test build and focused run both used the unoptimized test profile with debug info and incremental compilation disabled. The focused run set `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1`. Both commands ran outside `Invoke-ArcTest.ps1` with zero Arc GPU mutex hold. **Commands and results** - `cargo test --workspace --no-run` exited 0 and built 15 test executables. It executed zero tests. The compiler emitted a deprecation warning for `AtomicU32::fetch_update` in XGameRuntime. - `cargo test -p xcl --lib -- hle::dualsense_haptics::tests:: hle::dualsense_report::tests:: hle::playstation::tests::` exited 0. The captured output reports 7 passed, 0 failed, 0 ignored, and 673 filtered out. It contains 0 lines matching the case-sensitive pattern `^SKIPPED `. **Observed behavior** - Rumble state produced an encoded USB report, suppressed repeat reports for unchanged values, and produced a zero-motor report when rumble stopped. - Report tests checked USB motor and trigger fields, LED and attenuation fields, and encoding for off, feedback, weapon, and vibration trigger effects. - Synthetic input tests checked matching DualShock 4 and DualSense USB gamepad states, rejection of short or unsupported reports, and HID identifier matching, including exclusion of Bluetooth DualSense. - Haptic synthesis tests checked silence at zero rumble, actuator channel routing and amplitude ramping, and the small motor's 230 Hz tone. **Not tested** - Physical DualSense hardware, the full GPU workspace suite, and game smoke runs were omitted. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr715-focused.log and published.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 11:38 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 11:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/715#issuecomment-7161318286) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • README.md
  • crates/xcl/src/hle/playstation.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/715/head:github-bot/gh-715'
git switch 'github-bot/gh-715'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-715'
git switch 'github-bot/gh-715'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-715'
git switch 'github-bot/gh-715'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-715'
git switch 'main'
git merge --squash 'github-bot/gh-715'
git switch 'main'
git merge --ff-only 'github-bot/gh-715'
git switch 'main'
git merge 'github-bot/gh-715'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.