[PR #120] [MERGED] Controllers: design note, gilrs input layer and gameplay #2339

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

📋 Pull Request Information

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

Base: main ← Head: feat/controllers-input


📝 Commits (3)

  • 0818190 docs: controller support design note
  • b7330ac Controllers: gilrs input layer, in-game movement, camera, actions and hotbar
  • e70b5e2 Controllers: a pad press lasts at least one game tick

📊 Changes

21 files changed (+1447 additions, -43 deletions)

View changed files

📝 .github/workflows/ci.yml (+2 -2)
📝 .github/workflows/release.yml (+2 -2)
📝 Cargo.lock (+110 -0)
📝 README.md (+1 -1)
📝 crates/horizon-client/Cargo.toml (+2 -0)
📝 crates/horizon-client/examples/scene_motion_probe.rs (+1 -0)
📝 crates/horizon-client/examples/sprint_probe.rs (+1 -0)
📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+4 -0)
📝 crates/horizon-client/src/game.rs (+48 -32)
📝 crates/horizon-client/src/game/books.rs (+1 -1)
📝 crates/horizon-client/src/game/control.rs (+2 -0)
➕ crates/horizon-client/src/game/pad.rs (+464 -0)
📝 crates/horizon-client/src/game/remote.rs (+4 -1)
📝 crates/horizon-client/src/game/screens.rs (+1 -1)
📝 crates/horizon-client/src/game/sign_edit.rs (+1 -1)
➕ crates/horizon-client/src/gamepad.rs (+596 -0)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/settings.rs (+11 -0)
📝 crates/horizon-client/src/sprint.rs (+20 -1)
➕ docs/controllers.md (+174 -0)

...and 1 more files

📄 Description

Part 1 of controller support (NEXT-VERSION §9, Kira card#17). Design note: docs/controllers.md.

What

  • Vanilla 26.3 has no gamepad support (no GLFW gamepad/joystick calls, no controller options, no glyph sprites; only keyboard focus navigation). So this is Horizon's own feature, on Bedrock's default controller layout.
  • gilrs 0.11 reads the pads (evdev + libudev on Linux, IOKit on macOS, Windows.Gaming.Input on Windows). Cargo.lock gains 10 small crates (gilrs, gilrs-core, libudev-sys, inotify, nix, uuid, vec_map, fnv, objc2-io-kit); the Windows crate unifies with the one already locked. No second windowing/event stack: gilrs is polled in about_to_wait.
  • gamepad.rs (lib, unit-tested): positional buttons, bindings, radial deadzones, look curve, button edges with trigger hysteresis, and horizon-controller.txt (Horizon's own file next to options.txt, like horizon-graphics.txt; options.txt stays vanilla's; the file is only written once a setting differs from the defaults).
  • game/pad.rs: buttons act as the vanilla key mapping they're bound to, through the same path a rebound keyboard key takes: the keyboard's post-rebinding handling moved into Game::mapped_key, so toggle sneak/sprint, screens releasing keys and multiplayer behave exactly like the keyboard. Left stick = analog move vector (sprint::Keys::analog; the boolean direction flags are set past 30% for sprint/vehicles/the server packet). Right stick turns the view per frame (200°/s yaw, 140°/s pitch at default, squared curve, slower with a spyglass). A press lasts at least one game tick (vanilla samples keys per tick, so a quick stick click for sprint is never lost).
  • B / Start leave screens (title, signs, books, chat, every screen's Escape), Y closes inventories, A respawns. Full menu/inventory control is PR 2.
  • horizon-ctl pad BUTTON down|up|tap, pad stick left|right X Y, pad trigger left|right V, pad release, pad status: a virtual pad merged with real ones, for tests without hardware.
  • CI/release: libudev-dev in the apt installs; libudev.so.1 added to check_imports.py's Linux allowlist (every systemd distro and the Steam Deck have it). README dev requirements updated.

Keyboard and mouse are untouched; with no pad (or enabled:false) nothing changes.

Default mapping

Action Xbox PlayStation
Move / Look LS / RS LS / RS
Jump A ✕
Drop B ○
Swap offhand X □
Inventory Y △
Hotbar ← / → LB / RB L1 / R1
Use / place LT L2
Attack / break RT R2
Sprint LS click L3
Sneak (toggles) RS click R3
Perspective / pick block / chat / advancements D-pad ↑ ← → ↓ D-pad
Player list (hold) View Create
Pause / back Menu Options

How tested

  • Unit tests: gamepad::tests (defaults, settings round trip, deadzones, look curve, edges/hysteresis, merge, hotbar wrap, vendor glyph style). cargo clippy -p horizon-client --all-targets -D warnings clean on macOS; CI verify on Linux.
  • Linux build (ThinkPad) run on vscreen with the injected pad: full stick walks ~4.3 m/s, a 40% tilt walks slowly; full right stick turns ~200°/s, stick down looks down; RB/LB step the hotbar; R3 toggles sneak; Y opens/closes the creative inventory; B closes it; Start pauses/unpauses; RT breaks, LT places; A jumps; held L3 + forward sprints. gilrs opens on Linux (pad status → backend: true).
  • Nothing was tested with a real controller. Ludovic: please try a DualSense/Xbox pad (and the Deck) for stick feel, trigger thresholds and the stick-click sprint.

🤖 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/120 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/controllers-input` --- ### 📝 Commits (3) - [`0818190`](https://github.com/horizon-rust/horizon/commit/0818190ee4b23f93857d65e9f4dd39f35ea8e7d0) docs: controller support design note - [`b7330ac`](https://github.com/horizon-rust/horizon/commit/b7330ac0cc7f627bf32b8e058a6164946d8c23e0) Controllers: gilrs input layer, in-game movement, camera, actions and hotbar - [`e70b5e2`](https://github.com/horizon-rust/horizon/commit/e70b5e2882d83fe9d61ef42546ca7de04630e731) Controllers: a pad press lasts at least one game tick ### 📊 Changes **21 files changed** (+1447 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+2 -2) 📝 `.github/workflows/release.yml` (+2 -2) 📝 `Cargo.lock` (+110 -0) 📝 `README.md` (+1 -1) 📝 `crates/horizon-client/Cargo.toml` (+2 -0) 📝 `crates/horizon-client/examples/scene_motion_probe.rs` (+1 -0) 📝 `crates/horizon-client/examples/sprint_probe.rs` (+1 -0) 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+4 -0) 📝 `crates/horizon-client/src/game.rs` (+48 -32) 📝 `crates/horizon-client/src/game/books.rs` (+1 -1) 📝 `crates/horizon-client/src/game/control.rs` (+2 -0) ➕ `crates/horizon-client/src/game/pad.rs` (+464 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+4 -1) 📝 `crates/horizon-client/src/game/screens.rs` (+1 -1) 📝 `crates/horizon-client/src/game/sign_edit.rs` (+1 -1) ➕ `crates/horizon-client/src/gamepad.rs` (+596 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/settings.rs` (+11 -0) 📝 `crates/horizon-client/src/sprint.rs` (+20 -1) ➕ `docs/controllers.md` (+174 -0) _...and 1 more files_ </details> ### 📄 Description Part 1 of controller support (NEXT-VERSION §9, Kira card#17). Design note: `docs/controllers.md`. ## What - **Vanilla 26.3 has no gamepad support** (no GLFW gamepad/joystick calls, no controller options, no glyph sprites; only keyboard focus navigation). So this is Horizon's own feature, on **Bedrock's default controller layout**. - **gilrs 0.11** reads the pads (evdev + libudev on Linux, IOKit on macOS, Windows.Gaming.Input on Windows). Cargo.lock gains 10 small crates (gilrs, gilrs-core, libudev-sys, inotify, nix, uuid, vec_map, fnv, objc2-io-kit); the Windows crate unifies with the one already locked. No second windowing/event stack: gilrs is polled in `about_to_wait`. - `gamepad.rs` (lib, unit-tested): positional buttons, bindings, radial deadzones, look curve, button edges with trigger hysteresis, and `horizon-controller.txt` (Horizon's own file next to `options.txt`, like `horizon-graphics.txt`; options.txt stays vanilla's; the file is only written once a setting differs from the defaults). - `game/pad.rs`: buttons act as the **vanilla key mapping they're bound to, through the same path a rebound keyboard key takes**: the keyboard's post-rebinding handling moved into `Game::mapped_key`, so toggle sneak/sprint, screens releasing keys and multiplayer behave exactly like the keyboard. Left stick = analog move vector (`sprint::Keys::analog`; the boolean direction flags are set past 30% for sprint/vehicles/the server packet). Right stick turns the view per frame (200°/s yaw, 140°/s pitch at default, squared curve, slower with a spyglass). A press lasts at least one game tick (vanilla samples keys per tick, so a quick stick click for sprint is never lost). - B / Start leave screens (title, signs, books, chat, every screen's Escape), Y closes inventories, A respawns. Full menu/inventory control is PR 2. - `horizon-ctl pad BUTTON down|up|tap`, `pad stick left|right X Y`, `pad trigger left|right V`, `pad release`, `pad status`: a virtual pad merged with real ones, for tests without hardware. - CI/release: `libudev-dev` in the apt installs; `libudev.so.1` added to `check_imports.py`'s Linux allowlist (every systemd distro and the Steam Deck have it). README dev requirements updated. Keyboard and mouse are untouched; with no pad (or `enabled:false`) nothing changes. ## Default mapping | Action | Xbox | PlayStation | |---|---|---| | Move / Look | LS / RS | LS / RS | | Jump | A | ✕ | | Drop | B | ○ | | Swap offhand | X | □ | | Inventory | Y | △ | | Hotbar ← / → | LB / RB | L1 / R1 | | Use / place | LT | L2 | | Attack / break | RT | R2 | | Sprint | LS click | L3 | | Sneak (toggles) | RS click | R3 | | Perspective / pick block / chat / advancements | D-pad ↑ ← → ↓ | D-pad | | Player list (hold) | View | Create | | Pause / back | Menu | Options | ## How tested - Unit tests: `gamepad::tests` (defaults, settings round trip, deadzones, look curve, edges/hysteresis, merge, hotbar wrap, vendor glyph style). `cargo clippy -p horizon-client --all-targets -D warnings` clean on macOS; CI `verify` on Linux. - Linux build (ThinkPad) run on vscreen with the injected pad: full stick walks ~4.3 m/s, a 40% tilt walks slowly; full right stick turns ~200°/s, stick down looks down; RB/LB step the hotbar; R3 toggles sneak; Y opens/closes the creative inventory; B closes it; Start pauses/unpauses; RT breaks, LT places; A jumps; held L3 + forward sprints. gilrs opens on Linux (`pad status` → `backend: true`). - **Nothing was tested with a real controller.** Ludovic: please try a DualSense/Xbox pad (and the Deck) for stick feel, trigger thresholds and the stick-click sprint. 🤖 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:55:05 +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#2339
No description provided.