[PR #360] [MERGED] DualSense adaptive triggers #2523

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/360
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/dualsense-triggers


📝 Commits (4)

  • ac95593 DualSense output over HID: the report, a writer thread, and rumble through it
  • 6086758 DualSense output: rumble, LEDs and Bluetooth checked against SDL and the kernel
  • a316768 DualSense adaptive triggers
  • 6663af1 DualSense triggers: catches at the press point, shields, official modes only

📊 Changes

15 files changed (+1752 additions, -15 deletions)

View changed files

📝 Cargo.lock (+22 -0)
📝 Cargo.toml (+1 -1)
📝 crates/horizon-client/Cargo.toml (+2 -0)
📝 crates/horizon-client/src/game.rs (+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 (+144 -1)
📝 crates/horizon-client/src/options_horizon.rs (+2 -0)
📝 crates/horizon-client/src/options_ui.rs (+7 -0)
➕ crates/horizon-dualsense/Cargo.toml (+16 -0)
➕ crates/horizon-dualsense/examples/dualsense.rs (+276 -0)
➕ crates/horizon-dualsense/src/device.rs (+461 -0)
➕ crates/horizon-dualsense/src/lib.rs (+351 -0)
➕ crates/horizon-dualsense/src/trigger.rs (+148 -0)
📝 docs/controllers.md (+171 -9)

📄 Description

What

Second DualSense PR, stacked on #348 (merge that first). This one adds adaptive triggers: Horizon-only, on by default with a DualSense, with "Adaptive Triggers" in the controller options (adaptiveTriggers:) to turn them off.

Each trigger feels the action bound to it, so it follows rebinding. By default that is L2 = key.use and R2 = key.attack:

While Trigger Effect
drawing a bow use feedback from zone 1, strength 1→8 with BowItem.getPowerForTime
charging a trident use the same, full at the 10-tick throw threshold
loading a crossbow use the same, full when loaded
holding a loaded crossbow use weapon (resistance and click between zones 3 and 6, where it fires)
gliding with a rocket / pig + carrot on a stick / strider + warped fungus on a stick use a wall halfway (feedback from zone 4, strength 6)
mining (survival) attack 30 Hz buzz, amplitude 2–5 with hardness (none for instant-break or unbreakable blocks)

Triggers are free in menus, on the title screen, paused, unfocused, with another pad active, and with controllers off (the output closes). They are also freed on quit and on disconnect, since a reconnect rewrites the current state. horizon-dualsense::trigger encodes the feedback (0x21), weapon (0x25) and vibration (0x26) modes: ten zones, 3 bits per zone. pad status shows trigger_effects.

Verified

  • Unit tests check the mode bytes against hand-computed values (zones, strengths, frequency byte), which feels each action maps to through the bindings, the option round-trip, and the bow power curve.
  • On the pad over USB (in #348's session), the input report read back each raw effect: feedback gave effect nibble 1 and weapon gave 2.
  • Not verified in game on the pad. It disappeared from the Mac mini at 16:30 ("hardware connection lost" on USB-C port 6) and never came back while I worked. The game-side logic and the vibration (0x26) mode haven't been felt or read back. cargo run -p horizon-dualsense --example dualsense -- triggers plays every feel for 2 s each and prints the pad's readback.

Self-check

cargo fmt --check                                                     ok
cargo clippy -p horizon-client -p horizon-dualsense --all-targets -D warnings   ok
cargo test -p horizon-dualsense                                       ok (incl. trigger byte tests)
cargo test -p horizon-client --lib gamepad                            ok
tools/parity.py --changed origin/main (stack top, local)              see the last PR of the stack

Needs Ludovic

Feel-test: draw a bow, charge a trident, load and fire a crossbow, glide with rockets, mine dirt, then stone, then obsidian. Then open a menu, alt-tab and quit: the triggers must go free each time.

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/360 **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-triggers` --- ### 📝 Commits (4) - [`ac95593`](https://github.com/horizon-rust/horizon/commit/ac955934b501a451cc5b0c3c5d244e57a057517c) DualSense output over HID: the report, a writer thread, and rumble through it - [`6086758`](https://github.com/horizon-rust/horizon/commit/6086758f94cf1ab813137800d02f773e2c7b1f7c) DualSense output: rumble, LEDs and Bluetooth checked against SDL and the kernel - [`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 ### 📊 Changes **15 files changed** (+1752 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+22 -0) 📝 `Cargo.toml` (+1 -1) 📝 `crates/horizon-client/Cargo.toml` (+2 -0) 📝 `crates/horizon-client/src/game.rs` (+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` (+144 -1) 📝 `crates/horizon-client/src/options_horizon.rs` (+2 -0) 📝 `crates/horizon-client/src/options_ui.rs` (+7 -0) ➕ `crates/horizon-dualsense/Cargo.toml` (+16 -0) ➕ `crates/horizon-dualsense/examples/dualsense.rs` (+276 -0) ➕ `crates/horizon-dualsense/src/device.rs` (+461 -0) ➕ `crates/horizon-dualsense/src/lib.rs` (+351 -0) ➕ `crates/horizon-dualsense/src/trigger.rs` (+148 -0) 📝 `docs/controllers.md` (+171 -9) </details> ### 📄 Description ## What Second DualSense PR, stacked on #348 (merge that first). This one adds **adaptive triggers**: Horizon-only, on by default with a DualSense, with "Adaptive Triggers" in the controller options (`adaptiveTriggers:`) to turn them off. Each trigger feels the action bound to it, so it follows rebinding. By default that is L2 = `key.use` and R2 = `key.attack`: | While | Trigger | Effect | |---|---|---| | drawing a bow | use | feedback from zone 1, strength 1→8 with `BowItem.getPowerForTime` | | charging a trident | use | the same, full at the 10-tick throw threshold | | loading a crossbow | use | the same, full when loaded | | holding a loaded crossbow | use | weapon (resistance and click between zones 3 and 6, where it fires) | | gliding with a rocket / pig + carrot on a stick / strider + warped fungus on a stick | use | a wall halfway (feedback from zone 4, strength 6) | | mining (survival) | attack | 30 Hz buzz, amplitude 2–5 with hardness (none for instant-break or unbreakable blocks) | Triggers are free in menus, on the title screen, paused, unfocused, with another pad active, and with controllers off (the output closes). They are also freed on quit and on disconnect, since a reconnect rewrites the current state. `horizon-dualsense::trigger` encodes the feedback (0x21), weapon (0x25) and vibration (0x26) modes: ten zones, 3 bits per zone. `pad status` shows `trigger_effects`. ## Verified - Unit tests check the mode bytes against hand-computed values (zones, strengths, frequency byte), which feels each action maps to through the bindings, the option round-trip, and the bow power curve. - On the pad over USB (in #348's session), the input report read back each raw effect: feedback gave effect nibble 1 and weapon gave 2. - **Not verified in game on the pad.** It disappeared from the Mac mini at 16:30 ("hardware connection lost" on USB-C port 6) and never came back while I worked. The game-side logic and the vibration (0x26) mode haven't been felt or read back. `cargo run -p horizon-dualsense --example dualsense -- triggers` plays every feel for 2 s each and prints the pad's readback. ## Self-check ``` cargo fmt --check ok cargo clippy -p horizon-client -p horizon-dualsense --all-targets -D warnings ok cargo test -p horizon-dualsense ok (incl. trigger byte tests) cargo test -p horizon-client --lib gamepad ok tools/parity.py --changed origin/main (stack top, local) see the last PR of the stack ``` ## Needs Ludovic Feel-test: draw a bow, charge a trident, load and fire a crossbow, glide with rockets, mine dirt, then stone, then obsidian. Then open a menu, alt-tab and quit: the triggers must go free each time. ## 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/360#issuecomment-6198163758). 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#2523
No description provided.