[PR #2016] [MERGED] Mod keys: players rebind them on the mod's page (input) #3942

Closed
opened 2026-11-03 04:13:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/mod-ui-key


📝 Commits (4)

  • 7e4012c Mod API: a key widget, so players bind a mod's keys (ui, input)
  • 3e3c0ce Mod keys: rows the game adds to the settings page, not a WIT widget
  • 82deb28 Merge main into feat/mod-ui-key
  • 2f46365 Merge remote-tracking branch 'origin/main' into feat/mod-ui-key

📊 Changes

9 files changed (+305 additions, -30 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+4 -3)
📝 crates/horizon-client/src/game/mods.rs (+142 -10)
📝 crates/horizon-client/src/mod_list.rs (+46 -6)
📝 crates/horizon-mod-sdk/wit/horizon.wit (+3 -1)
📝 crates/horizon-mods/src/runtime.rs (+66 -4)
📝 crates/horizon-mods/tests/sandbox.rs (+37 -0)
📝 docs/api/mods-reference.md (+1 -1)
📝 docs/api/stability.md (+5 -4)
📝 docs/mods.md (+1 -1)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Stacked on #2013 (zoom and the mouse wheel). Review the last two commits. Until #2013 merges, the diff also shows its commit.

Players can rebind the built-in zoom's key on Options > Horizon Extras. Once zoom is an official mod, its key has to be rebindable too. That's what this PR adds, for every mod.

What players and modders get

  • A mod's keys (input.register-key) are listed first on its page in Options > Mods, as Key Binds rows: "Zoom: Z".
    • A click marks the row "> Zoom: Z <" in yellow and waits for the next key or mouse button, which becomes the key. Esc binds none, as on Key Binds.
    • A mod with keys gets a page even without ui.
  • The choice is kept in horizon-mods.txt (key.<mod>.<name>:key.keyboard.g). It applies when the mods load or reload and to keys a mod registers later, so register-key's key is now the default. The mod's key-down / key-up follow the new key, and a key held while it is rebound lets go first.
  • No WIT type changes. The first commit added a key case to ui's widget variant. That would have stopped every ui mod built before it from loading, including the published FPS Counter and Keystrokes: the runtime links a component only when each imported function's types match exactly ("expected variant of 5 cases, found 4"). The second commit replaces it with the rows above.
  • docs/api/stability.md is corrected. It said a new WIT case the mod sends isn't breaking. It now lists any change to a WIT type a function uses as breaking, and a new function or type as not breaking.

How tested

  • Sandbox tests:
    • Rebinding a held key lets it go; the new key is heard and the old one isn't.
    • A key that isn't a key, or a name the mod never registered, is refused.
    • A saved choice wins over the default, whether the key was registered before or after the choice was applied.
    • A mod with keys alone has a settings page.
  • mod_list unit test: the key.* lines round-trip, key names with dots included.
  • In game, with the test guest installed and on, in-frame and on the server thread, fresh HORIZON_HOME/XDG folders and HORIZON_NO_AUDIO=1. 12 checks in each mode, 24/24:
    • The page shows "Open the wheel: R" above the mod's own widgets. A click shows "> Open the wheel: R <", and G binds it.
    • horizon-mods.txt keeps key.test_ui_guest.wheel:key.keyboard.g.
    • In the world, R no longer reaches the mod and G does.
    • A right click while waiting binds the right button. Esc binds none (saved as key.keyboard.unknown) and leaves the page open.
    • After a second start, G is still the key.
    • No panic and no stopped mod in either run.
  • Compatibility: Keystrokes built from #1982 (before this WIT) loads on this build, and its settings page works.

Self-check against #2013's head:

pr_ready (tools/pr_ready.py --quick --base de294e34b on ludovics-mac-mini, against de294e34b at de294e34b, 4 min 14 s)

Check Result
Scope ✅ 9 files, +305 −30
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ✅ (20 s)
tests: horizon-client, horizon-mod-sdk, horizon-mods ✅ 1302 passed (3 min 24 s)
doc tests ✅ 1 passed (5 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (1 s)
launcher clippy ✅ (2 s)
launcher tests ✅ 128 passed (4 s)
Parity ➖ 104 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 92 more

skip-release: players see no change until a mod with keys ships.

🤖 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/2016 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/mod-ui-key` --- ### 📝 Commits (4) - [`7e4012c`](https://github.com/horizon-rust/horizon/commit/7e4012c83ec859b5fa18f6f5975e49f97719854a) Mod API: a key widget, so players bind a mod's keys (ui, input) - [`3e3c0ce`](https://github.com/horizon-rust/horizon/commit/3e3c0cebb51fa5deb0022ff1c0ca8fa4ba9fc42d) Mod keys: rows the game adds to the settings page, not a WIT widget - [`82deb28`](https://github.com/horizon-rust/horizon/commit/82deb28954c55973b59d2d4552a2a07f054a4323) Merge main into feat/mod-ui-key - [`2f46365`](https://github.com/horizon-rust/horizon/commit/2f46365df1f0a72ec0894050cc998e2835f15f46) Merge remote-tracking branch 'origin/main' into feat/mod-ui-key ### 📊 Changes **9 files changed** (+305 additions, -30 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+4 -3) 📝 `crates/horizon-client/src/game/mods.rs` (+142 -10) 📝 `crates/horizon-client/src/mod_list.rs` (+46 -6) 📝 `crates/horizon-mod-sdk/wit/horizon.wit` (+3 -1) 📝 `crates/horizon-mods/src/runtime.rs` (+66 -4) 📝 `crates/horizon-mods/tests/sandbox.rs` (+37 -0) 📝 `docs/api/mods-reference.md` (+1 -1) 📝 `docs/api/stability.md` (+5 -4) 📝 `docs/mods.md` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. **Stacked on #2013** (zoom and the mouse wheel). Review the last two commits. Until #2013 merges, the diff also shows its commit. Players can rebind the built-in zoom's key on Options > Horizon Extras. Once zoom is an official mod, its key has to be rebindable too. That's what this PR adds, for every mod. ## What players and modders get - **A mod's keys (`input.register-key`) are listed first on its page in Options > Mods**, as Key Binds rows: "Zoom: Z". - A click marks the row "> Zoom: Z <" in yellow and waits for the next key or mouse button, which becomes the key. Esc binds none, as on Key Binds. - A mod with keys gets a page even without `ui`. - **The choice is kept in `horizon-mods.txt`** (`key.<mod>.<name>:key.keyboard.g`). It applies when the mods load or reload and to keys a mod registers later, so `register-key`'s key is now the default. The mod's `key-down` / `key-up` follow the new key, and a key held while it is rebound lets go first. - **No WIT type changes.** The first commit added a `key` case to ui's widget variant. That would have stopped every `ui` mod built before it from loading, including the published FPS Counter and Keystrokes: the runtime links a component only when each imported function's types match exactly ("expected variant of 5 cases, found 4"). The second commit replaces it with the rows above. - **`docs/api/stability.md` is corrected.** It said a new WIT case the mod sends isn't breaking. It now lists any change to a WIT type a function uses as breaking, and a new function or type as not breaking. ## How tested - **Sandbox tests:** - Rebinding a held key lets it go; the new key is heard and the old one isn't. - A key that isn't a key, or a name the mod never registered, is refused. - A saved choice wins over the default, whether the key was registered before or after the choice was applied. - A mod with keys alone has a settings page. - **`mod_list` unit test:** the `key.*` lines round-trip, key names with dots included. - **In game**, with the test guest installed and on, in-frame and on the server thread, fresh `HORIZON_HOME`/XDG folders and `HORIZON_NO_AUDIO=1`. 12 checks in each mode, 24/24: - The page shows "Open the wheel: R" above the mod's own widgets. A click shows "> Open the wheel: R <", and G binds it. - `horizon-mods.txt` keeps `key.test_ui_guest.wheel:key.keyboard.g`. - In the world, R no longer reaches the mod and G does. - A right click while waiting binds the right button. Esc binds none (saved as `key.keyboard.unknown`) and leaves the page open. - After a second start, G is still the key. - No panic and no stopped mod in either run. - **Compatibility:** Keystrokes built from #1982 (before this WIT) loads on this build, and its settings page works. **Self-check** against #2013's head: **pr_ready** (`tools/pr_ready.py --quick --base de294e34b` on ludovics-mac-mini, against de294e34b at de294e34b, 4 min 14 s) | Check | Result | | --- | --- | | Scope | ✅ 9 files, +305 −30 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ✅ (20 s) | | tests: horizon-client, horizon-mod-sdk, horizon-mods | ✅ 1302 passed (3 min 24 s) | | doc tests | ✅ 1 passed (5 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (1 s) | | launcher clippy | ✅ (2 s) | | launcher tests | ✅ 128 passed (4 s) | | Parity | ➖ 104 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 92 more | `skip-release`: players see no change until a mod with keys ships. 🤖 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-03 04:13:26 +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#3942
No description provided.