GameInput: a player for the DualSense's haptic actuators over USB audio #710

Open
github-bot wants to merge 3 commits from github-bot/gh-710 into main AGit
Owner

@⁠MrCheese5 on GitHub · 2026-11-24 03:59 UTC · original
MrCheese5:ds-b-haptics-player → main · +664 −3 · 7 files · 3 commits · open

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

Over USB the DualSense is also a 4-channel audio output, and its channels 3 and 4 drive the two voice-coil actuators. dualsense_haptics finds that output by name with WASAPI (shared mode) and plays from a thread of its own. The title's big motor becomes a 100 Hz tone, mostly on the left, and the small motor a 230 Hz tone, mostly on the 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; #731 does. The windows crate gets three features for the device property store: Win32_System_Com_StructuredStorage, Win32_System_Variant and Win32_UI_Shell_PropertiesSystem. No new crates.

What is in it

  • crates/xcl/src/hle/dualsense_haptics.rs: the synthesiser and the WASAPI player, with tests of the synthesiser (only the actuator channels play, the cross-mix, the glide, each tone's frequency by zero crossings)
  • crates/xcl/Cargo.toml: the three features
  • crates/xcl/src/hle/mod.rs: the module

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 dualsense_haptics: 2 passed
  • cargo test --workspace -- --test-threads=1: 698 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).
  • With #731 on top, on a USB DualSense (054c:0ce6): the player found the controller's output in 4 channels at 48 kHz, started, and stopped at shutdown.

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: 4eebfdca13fe91e94f0892435242854f96d7c001
gpu: NVIDIA GeForce RTX 4090
title: Xbox
seconds: 60
exit: 0x0
frames shown: 827 (PresentX 827)
presents per 2 s (last 3): 36 37 36
device removals: 0
crashes: 0
peak commit: 15563 MB

Not tested

  • Whether the actuators feel right: nobody held the controller during the run.
  • An output that is not in 4 channels was not tried, so the refusal path is untested on hardware.
  • Nothing starts the player in this PR on its own.
  • 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 03:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/710) `MrCheese5:ds-b-haptics-player` → `main` · +664 −3 · 7 files · 3 commits · open Stacked on #552 and #709; only the top commit belongs here. Over USB the DualSense is also a 4-channel audio output, and its channels 3 and 4 drive the two voice-coil actuators. `dualsense_haptics` finds that output by name with WASAPI (shared mode) and plays from a thread of its own. The title's big motor becomes a 100 Hz tone, mostly on the left, and the small motor a 230 Hz tone, mostly on the 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; #731 does. The `windows` crate gets three features for the device property store: `Win32_System_Com_StructuredStorage`, `Win32_System_Variant` and `Win32_UI_Shell_PropertiesSystem`. No new crates. **What is in it** - `crates/xcl/src/hle/dualsense_haptics.rs`: the synthesiser and the WASAPI player, with tests of the synthesiser (only the actuator channels play, the cross-mix, the glide, each tone's frequency by zero crossings) - `crates/xcl/Cargo.toml`: the three features - `crates/xcl/src/hle/mod.rs`: the module **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 dualsense_haptics`: 2 passed - `cargo test --workspace -- --test-threads=1`: 698 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). - With #731 on top, on a USB DualSense (054c:0ce6): the player found the controller's output in 4 channels at 48 kHz, started, and stopped at shutdown. **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: 4eebfdca13fe91e94f0892435242854f96d7c001 gpu: NVIDIA GeForce RTX 4090 title: Xbox seconds: 60 exit: 0x0 frames shown: 827 (PresentX 827) presents per 2 s (last 3): 36 37 36 device removals: 0 crashes: 0 peak commit: 15563 MB ``` **Not tested** - Whether the actuators feel right: nobody held the controller during the run. - An output that is not in 4 channels was not tried, so the refusal path is untested on hardware. - Nothing starts the player in this PR on its own. - 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]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:30:10 +00:00
Author
Owner

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

Tested exact head 4eebfdc (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: 698 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 DualSense or its haptics (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/710#issuecomment-7122333233) Tested exact head `4eebfdc` (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`: **698 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 DualSense or its haptics (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 05:00 UTC · original

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

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: 707 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 666 passed, 0 failed, 21 ignored
  • 0 SKIPPED; the dualsense_haptics tests pass (no DualSense attached, so no WASAPI output was opened).

Review: I reviewed the top commit only, as the description asks.

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 05:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/710#issuecomment-7122542508) Test run of `4eebfdca13fe91e94f0892435242854f96d7c001` on AMD RDNA4. I merged it onto current `main` `64b3f35` locally (clean merge), so the tree tested includes the stack under it (#552, #709). **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: **707 passed, 0 failed, 41 ignored**, exit code 0; `xcl` lib tests 666 passed, 0 failed, 21 ignored - **0 `SKIPPED`**; the `dualsense_haptics` tests pass (no DualSense attached, so no WASAPI output was opened). **Review:** I reviewed the top commit only, as the description asks. **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 (4eebfdca)

Hardware / environment

  • PR #710 head 4eebfdca13fe91e94f0892435242854f96d7c001, checked out detached on STOR-WINLAB.
  • Windows 11 Enterprise Evaluation, x64, build 26200 (10.0.26200). AMD Ryzen 7 3800X, with 6 cores and 12 logical processors visible to Windows.
  • Rust 1.100.0 (0ef1bc386), target x86_64-pc-windows-msvc. DXC 1.9.2609.5 (01b62ad47). Cargo test profile unoptimized, with debug info and incremental compilation disabled.
  • The focused run used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1. The build and all three runs were outside Invoke-ArcTest.ps1, with no Arc GPU mutex held.

Commands and results

Command Exit Passed / failed / ignored / skipped
cargo test --workspace --no-run 0 Compile only
cargo test -p xcl --lib hle::dualsense_haptics::tests:: 0 2 / 0 / 0 / 0
cargo test -p xcl --lib hle::dualsense_report::tests:: 0 2 / 0 / 0 / 0
cargo test -p xcl --lib hle::playstation::tests:: 0 2 / 0 / 0 / 0

The total was 6 passed, 0 failed, 0 ignored, and 0 case-sensitive SKIPPED lines. Each focused invocation filtered out 677 tests. The build emitted a deprecation warning for Atomic::fetch_update in XGameRuntime.

Observed behavior

  • The synthesizer left the speaker channels silent and drove the actuator channels in memory. The tests also checked the amplitude ramp, stereo silence, and the 230 Hz tone by counting zero crossings.
  • The report tests verified trigger-effect encoding and USB output layout. The HID tests checked DualShock 4 and DualSense input parsing and controller identification from sample HID paths.
  • None of the six tests opened an audio endpoint. No audio-device skips were reported.

Not tested

Physical DualSense USB audio hardware, Windows audio endpoint discovery and playback, the full GPU workspace suite, and game smoke runs.

AI use

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

**@⁠JJAutoCompare** on GitHub · 2026-11-25 06:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/710#issuecomment-7154656017) ### Empirical test report (4eebfdca) **Hardware / environment** - PR #710 head `4eebfdca13fe91e94f0892435242854f96d7c001`, checked out detached on STOR-WINLAB. - Windows 11 Enterprise Evaluation, x64, build 26200 (10.0.26200). AMD Ryzen 7 3800X, with 6 cores and 12 logical processors visible to Windows. - Rust 1.100.0 (0ef1bc386), target `x86_64-pc-windows-msvc`. DXC 1.9.2609.5 (01b62ad47). Cargo test profile unoptimized, with debug info and incremental compilation disabled. - The focused run used `XCL_ADAPTER=NONE_CPU_ONLY` and `RUST_TEST_NOCAPTURE=1`. The build and all three runs were outside `Invoke-ArcTest.ps1`, with no Arc GPU mutex held. **Commands and results** | Command | Exit | Passed / failed / ignored / skipped | | --- | ---: | --- | | `cargo test --workspace --no-run` | 0 | Compile only | | `cargo test -p xcl --lib hle::dualsense_haptics::tests::` | 0 | 2 / 0 / 0 / 0 | | `cargo test -p xcl --lib hle::dualsense_report::tests::` | 0 | 2 / 0 / 0 / 0 | | `cargo test -p xcl --lib hle::playstation::tests::` | 0 | 2 / 0 / 0 / 0 | The total was 6 passed, 0 failed, 0 ignored, and 0 case-sensitive `SKIPPED ` lines. Each focused invocation filtered out 677 tests. The build emitted a deprecation warning for `Atomic::fetch_update` in XGameRuntime. **Observed behavior** - The synthesizer left the speaker channels silent and drove the actuator channels in memory. The tests also checked the amplitude ramp, stereo silence, and the 230 Hz tone by counting zero crossings. - The report tests verified trigger-effect encoding and USB output layout. The HID tests checked DualShock 4 and DualSense input parsing and controller identification from sample HID paths. - None of the six tests opened an audio endpoint. No audio-device skips were reported. **Not tested** Physical DualSense USB audio hardware, Windows audio endpoint discovery and playback, the full GPU workspace suite, and game smoke runs. **AI use** Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr710-focused.log and published.
Author
Owner

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

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 11:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/710#issuecomment-7161661334) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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