[PR #361] [MERGED] DualSense vibration: shaped pulses, HD haptics on USB (opt-in) #2522

Closed
opened 2026-11-02 15:56:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/361
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/dualsense-vibration


📝 Commits (4)

  • a316768 DualSense adaptive triggers
  • 6663af1 DualSense triggers: catches at the press point, shields, official modes only
  • 0681064 DualSense vibration: shaped pulses, HD haptics on USB (opt-in)
  • be57f82 DualSense HD haptics: Windows' device name, the arming rule, Bluetooth notes

📊 Changes

12 files changed (+790 additions, -17 deletions)

View changed files

📝 Cargo.lock (+1 -0)
📝 crates/horizon-client/src/game/pad.rs (+146 -3)
📝 crates/horizon-client/src/game/shield.rs (+4 -1)
📝 crates/horizon-client/src/gamepad.rs (+196 -1)
📝 crates/horizon-client/src/options_horizon.rs (+2 -0)
📝 crates/horizon-client/src/options_ui.rs (+7 -0)
📝 crates/horizon-dualsense/Cargo.toml (+2 -0)
📝 crates/horizon-dualsense/examples/dualsense.rs (+16 -10)
➕ crates/horizon-dualsense/src/haptics.rs (+149 -0)
📝 crates/horizon-dualsense/src/lib.rs (+2 -0)
➕ crates/horizon-dualsense/src/trigger.rs (+148 -0)
📝 docs/controllers.md (+117 -2)

📄 Description

What

Third DualSense PR, stacked on #360. This one makes vibration better.

  • Each event now plays a shape instead of one flat block (Rumble::shape):
    • hurt: 50 ms at full, then 55% and 25%
    • explosion: 80 ms at full, then 60%, 35% and 15% (150 ms each)
    • totem: swells 40% → 70% → 100% → 50%
    • broken block: a 35 ms tick
      The writer thread plays these steps over HID (compatible-vibration bytes).
  • HD haptics, opt-in (HORIZON_DUALSENSE_HAPTICS=1): horizon-dualsense::haptics opens the pad's own 4-channel 48 kHz audio device, by name only and never the default output. It synthesizes each shape on channels 3–4 as 80 Hz (heavy) and 200 Hz (light) tones with 4 ms ramps, keeping channels 1–2 (speaker, headset) silent. It is never used with HORIZON_NO_AUDIO. It is opt-in because I couldn't confirm it on the actuators (below); it should become the USB default once it's felt.
  • docs/controllers.md covers HD-haptics feasibility per OS. USB: macOS (CoreAudio; the 4-channel device is present on the Mac mini), Linux (snd-usb-audio card "Controller"), Windows (WASAPI). Bluetooth: no audio device. BT haptics travel in partly reverse-engineered vendor reports, which aren't done, so BT keeps the motor emulation.

Why

On the pad, the motor emulation has inertia: after a full-strength step, accel jitter took about 0.5 s to settle (2,886 at 250–550 ms, then 72, then 19). Flat 300–500 ms blocks feel mushy, which is what Ludovic reported. Shapes help over HID, and the actuators driven directly are what makes vibration feel crisp.

Verified

  • Unit tests: shapes start at the pulse's strength, decay monotonically and keep its length. The waveform test checks the ramp-in from silence, full amplitude, the ramp-out and no clipping.
  • Not verified on the pad: it was unplugged before this PR. The probe that measures haptics on the IMU is ready (/tmp/hapticprobe on the Mac mini; same method as #348's rumble check).

Self-check

cargo fmt --check / clippy -D warnings (horizon-client, horizon-dualsense)   ok
cargo test -p horizon-dualsense                                             ok
cargo test -p horizon-client --lib gamepad                                  ok

Needs Ludovic

  • Feel-test the shaped rumble on USB and BT: take hits, a nearby TNT, a totem.
  • Then run with HORIZON_DUALSENSE_HAPTICS=1 on USB and compare. If it's better, a follow-up makes it the USB default.

Reference audit (dualsense-2, no pad)

Every byte was checked against SDL, the Linux kernel, dualsensectl and Nielk1's notes, and the discrepancies were fixed in this PR's top commit; see the audit comment. The self-check on the stack top passed: fmt, workspace clippy -D warnings, cargo test -p horizon-dualsense -p horizon-client. Anything not listed above as verified on hardware is verified against the references only.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/361 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/dualsense-vibration` --- ### 📝 Commits (4) - [`a316768`](https://github.com/horizon-rust/horizon/commit/a316768bfcb97ee2eb43ab731c700841da1a0b8c) DualSense adaptive triggers - [`6663af1`](https://github.com/horizon-rust/horizon/commit/6663af199ec6b1576b873dcc44f7c946a8ff9358) DualSense triggers: catches at the press point, shields, official modes only - [`0681064`](https://github.com/horizon-rust/horizon/commit/0681064767fc79401e0e320ac0543e1f68769c3a) DualSense vibration: shaped pulses, HD haptics on USB (opt-in) - [`be57f82`](https://github.com/horizon-rust/horizon/commit/be57f82a07342195f1a2dda7f8b388f54e096d45) DualSense HD haptics: Windows' device name, the arming rule, Bluetooth notes ### 📊 Changes **12 files changed** (+790 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+1 -0) 📝 `crates/horizon-client/src/game/pad.rs` (+146 -3) 📝 `crates/horizon-client/src/game/shield.rs` (+4 -1) 📝 `crates/horizon-client/src/gamepad.rs` (+196 -1) 📝 `crates/horizon-client/src/options_horizon.rs` (+2 -0) 📝 `crates/horizon-client/src/options_ui.rs` (+7 -0) 📝 `crates/horizon-dualsense/Cargo.toml` (+2 -0) 📝 `crates/horizon-dualsense/examples/dualsense.rs` (+16 -10) ➕ `crates/horizon-dualsense/src/haptics.rs` (+149 -0) 📝 `crates/horizon-dualsense/src/lib.rs` (+2 -0) ➕ `crates/horizon-dualsense/src/trigger.rs` (+148 -0) 📝 `docs/controllers.md` (+117 -2) </details> ### 📄 Description ## What Third DualSense PR, stacked on #360. This one makes **vibration better**. - Each event now plays a shape instead of one flat block (`Rumble::shape`): - hurt: 50 ms at full, then 55% and 25% - explosion: 80 ms at full, then 60%, 35% and 15% (150 ms each) - totem: swells 40% → 70% → 100% → 50% - broken block: a 35 ms tick The writer thread plays these steps over HID (compatible-vibration bytes). - **HD haptics, opt-in (`HORIZON_DUALSENSE_HAPTICS=1`)**: `horizon-dualsense::haptics` opens the pad's own 4-channel 48 kHz audio device, by name only and never the default output. It synthesizes each shape on channels 3–4 as 80 Hz (heavy) and 200 Hz (light) tones with 4 ms ramps, keeping channels 1–2 (speaker, headset) silent. It is never used with `HORIZON_NO_AUDIO`. It is opt-in because I couldn't confirm it on the actuators (below); it should become the USB default once it's felt. - docs/controllers.md covers HD-haptics feasibility per OS. USB: macOS (CoreAudio; the 4-channel device is present on the Mac mini), Linux (snd-usb-audio card "Controller"), Windows (WASAPI). Bluetooth: no audio device. BT haptics travel in partly reverse-engineered vendor reports, which aren't done, so BT keeps the motor emulation. ## Why On the pad, the motor emulation has inertia: after a full-strength step, accel jitter took about 0.5 s to settle (2,886 at 250–550 ms, then 72, then 19). Flat 300–500 ms blocks feel mushy, which is what Ludovic reported. Shapes help over HID, and the actuators driven directly are what makes vibration feel crisp. ## Verified - Unit tests: shapes start at the pulse's strength, decay monotonically and keep its length. The waveform test checks the ramp-in from silence, full amplitude, the ramp-out and no clipping. - **Not verified on the pad**: it was unplugged before this PR. The probe that measures haptics on the IMU is ready (`/tmp/hapticprobe` on the Mac mini; same method as #348's rumble check). ## Self-check ``` cargo fmt --check / clippy -D warnings (horizon-client, horizon-dualsense) ok cargo test -p horizon-dualsense ok cargo test -p horizon-client --lib gamepad ok ``` ## Needs Ludovic - Feel-test the shaped rumble on USB and BT: take hits, a nearby TNT, a totem. - Then run with `HORIZON_DUALSENSE_HAPTICS=1` on USB and compare. If it's better, a follow-up makes it the USB default. ## Reference audit (dualsense-2, no pad) Every byte was checked against SDL, the Linux kernel, dualsensectl and Nielk1's notes, and the discrepancies were fixed in this PR's top commit; see [the audit comment](https://github.com/ludovic111/horizon/pull/361#issuecomment-6198164309). The self-check on the stack top passed: fmt, workspace clippy `-D warnings`, `cargo test -p horizon-dualsense -p horizon-client`. Anything not listed above as verified on hardware is verified against the references only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:56:54 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2522
No description provided.