[PR #129] [MERGED] Controllers: menus, screens and inventories (virtual cursor) #2341

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

📋 Pull Request Information

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

Base: main ← Head: feat/controllers-menus


📝 Commits (3)

  • cbf4b53 Controllers: menus, screens and inventories with a virtual cursor
  • b58e964 Controllers: Horizon-style menus' controls are focus targets too
  • 79ea17f Controllers: classic sliders are focus targets; the D-pad nudges with A held

📊 Changes

9 files changed (+569 additions, -40 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+3 -1)
📝 crates/horizon-client/src/game/pad.rs (+27 -37)
➕ crates/horizon-client/src/game/pad_menu.rs (+436 -0)
📝 crates/horizon-client/src/game/screens.rs (+1 -1)
📝 crates/horizon-client/src/gamepad.rs (+72 -0)
📝 crates/horizon-client/src/ui.rs (+4 -0)
📝 crates/horizon-client/src/ui_theme.rs (+6 -0)
📝 crates/horizon-client/src/widgets.rs (+19 -0)
📝 docs/controllers.md (+1 -1)

📄 Description

Part 2 of controller support (design: docs/controllers.md). Follows #120 (merged).

What

Menus, screens and inventories with a pad, through a virtual cursor (as Bedrock's classic inventory UI and Java controller mods do), not a per-screen focus system: vanilla's and Horizon's screens are all mouse-driven, so the pad feeds window_event the same CursorMoved / MouseInput / MouseWheel events a mouse sends (as horizon-ctl click-at already does). Every screen keeps its exact mouse behaviour (drag-splitting, sliders, scrollbars, tooltips) with no pad code of its own.

Input In menus
Left stick moves the cursor (squared curve), settles onto a slot/button within 10 px when let go
D-pad jumps focus to the nearest slot or control in that direction (gamepad::focus_step), auto-repeat when held
A / ✕ left click (held = held, so drags work)
X / □ right click (half stack / place one)
Y / △ quick move (shift-click) in inventories
B / ○, Menu back (Escape)
LB / RB previous / next creative tab
Right stick scrolls (creative grid, option lists, chat, advancements)
  • Focus targets: labelled buttons (widgets::last), every enabled control of the Horizon-style menus (new widgets::target, recorded in Ui::interact: sidebar items, switches, sliders, segments), inventory/station slots (slots() + slot_position), the creative grid, hotbar and tabs.
  • When a menu opens while the pad is in use, focus lands on its first button (the held hotbar slot in inventories). The cursor is drawn by Horizon (a small outlined arrow) and the OS pointer is hidden; moving the real mouse hands the pointer back at once.
  • The death screen's A shortcut from #120 is replaced by the cursor (focus starts on Respawn).

How tested

  • Unit test gamepad::tests::focus_moves_between_slots (focus steps in a grid, nearest settle, cursor speed). Clippy clean on macOS.
  • Linux build on vscreen with horizon-ctl pad: Start opens the pause menu with focus on "Back to game"; D-pad left/down reaches the Horizon sidebar, A opens Options; B goes back twice to the game; Y opens the creative inventory; RB twice switches to Natural Blocks; D-pad walks the grid, hotbar and bottom tabs with tooltips following; A picks up a full stack.
  • Not tested with a real controller: stick cursor speed/feel, D-pad repeat timing.

🤖 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/129 **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-menus` --- ### 📝 Commits (3) - [`cbf4b53`](https://github.com/horizon-rust/horizon/commit/cbf4b53b0c2f5f2c5bda138b90d81a307eb27f6a) Controllers: menus, screens and inventories with a virtual cursor - [`b58e964`](https://github.com/horizon-rust/horizon/commit/b58e96436af2f9e0917f0d1936d19cac807a0987) Controllers: Horizon-style menus' controls are focus targets too - [`79ea17f`](https://github.com/horizon-rust/horizon/commit/79ea17ffc5ac2dc81ee2dddde3ecf3941cdeaf5b) Controllers: classic sliders are focus targets; the D-pad nudges with A held ### 📊 Changes **9 files changed** (+569 additions, -40 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+3 -1) 📝 `crates/horizon-client/src/game/pad.rs` (+27 -37) ➕ `crates/horizon-client/src/game/pad_menu.rs` (+436 -0) 📝 `crates/horizon-client/src/game/screens.rs` (+1 -1) 📝 `crates/horizon-client/src/gamepad.rs` (+72 -0) 📝 `crates/horizon-client/src/ui.rs` (+4 -0) 📝 `crates/horizon-client/src/ui_theme.rs` (+6 -0) 📝 `crates/horizon-client/src/widgets.rs` (+19 -0) 📝 `docs/controllers.md` (+1 -1) </details> ### 📄 Description Part 2 of controller support (design: `docs/controllers.md`). Follows #120 (merged). ## What Menus, screens and inventories with a pad, through a **virtual cursor** (as Bedrock's classic inventory UI and Java controller mods do), not a per-screen focus system: vanilla's and Horizon's screens are all mouse-driven, so the pad feeds `window_event` the same `CursorMoved` / `MouseInput` / `MouseWheel` events a mouse sends (as `horizon-ctl click-at` already does). Every screen keeps its exact mouse behaviour (drag-splitting, sliders, scrollbars, tooltips) with no pad code of its own. | Input | In menus | |---|---| | Left stick | moves the cursor (squared curve), settles onto a slot/button within 10 px when let go | | D-pad | jumps focus to the nearest slot or control in that direction (`gamepad::focus_step`), auto-repeat when held | | A / ✕ | left click (held = held, so drags work) | | X / □ | right click (half stack / place one) | | Y / △ | quick move (shift-click) in inventories | | B / ○, Menu | back (Escape) | | LB / RB | previous / next creative tab | | Right stick | scrolls (creative grid, option lists, chat, advancements) | - Focus targets: labelled buttons (`widgets::last`), every enabled control of the Horizon-style menus (new `widgets::target`, recorded in `Ui::interact`: sidebar items, switches, sliders, segments), inventory/station slots (`slots()` + `slot_position`), the creative grid, hotbar and tabs. - When a menu opens while the pad is in use, focus lands on its first button (the held hotbar slot in inventories). The cursor is drawn by Horizon (a small outlined arrow) and the OS pointer is hidden; moving the real mouse hands the pointer back at once. - The death screen's A shortcut from #120 is replaced by the cursor (focus starts on Respawn). ## How tested - Unit test `gamepad::tests::focus_moves_between_slots` (focus steps in a grid, nearest settle, cursor speed). Clippy clean on macOS. - Linux build on vscreen with `horizon-ctl pad`: Start opens the pause menu with focus on "Back to game"; D-pad left/down reaches the Horizon sidebar, A opens Options; B goes back twice to the game; Y opens the creative inventory; RB twice switches to Natural Blocks; D-pad walks the grid, hotbar and bottom tabs with tooltips following; A picks up a full stack. - **Not tested with a real controller**: stick cursor speed/feel, D-pad repeat timing. 🤖 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:08 +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#2341
No description provided.