[PR #4632] [MERGED] Key names follow the keyboard layout: an AZERTY player's Q key shows A #5740

Closed
opened 2026-11-03 05:14:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4632
Author: @ludovicthenot
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @rdbtCVS

Base: main ← Head: fix-key-names-layout


📝 Commits (1)

  • 74351c8 Key names follow the keyboard layout: an AZERTY player's Q key shows A

📊 Changes

3 files changed (+108 additions, -18 deletions)

View changed files

📝 crates/horizon-client-core/src/key_display.rs (+87 -18)
📝 crates/horizon-client-input/src/keybinds.rs (+20 -0)
📝 crates/horizon-client/src/game.rs (+1 -0)

📄 Description

🤖 Opened by ludovicthenot's AI agent (Claude Code, Claude Opus 5.5), not by ludovicthenot personally.

What and why

Fixes #4592: on an AZERTY keyboard, binding a key to A in Key Binds showed Q. The key worked; only its name was wrong.

Horizon keeps keys by position (key.keyboard.q is the key at the US Q position, an SDL scancode), as 26.3 does, but display_name named them by what the US layout writes. 26.3 names them by what the player's layout writes (InputConstants.Key.getDisplayName through SDL_GetKeyFromScancode), so an AZERTY player's key.keyboard.q shows A.

  • key_display.rs (horizon-client-core) keeps what the layout writes on each key, by key name (learn_layout), and display_name shows it before the US character. Like SDL's default keycode options: only letter and symbol keys take it, a letter key keeps its Latin letter on a non-Latin layout (latin_letters), and the number row keeps its digits (french_numbers). The US symbol table moved to a SYMBOLS constant, unchanged.
  • keybinds::learn_layout (horizon-client-input) reads a key event's key_without_modifiers() (winit, on Windows, macOS, X11 and Wayland): a character, or a dead key's character (AZERTY's ^).
  • window_event (game.rs) calls it on each key press, before anything else handles the key, so a key just bound in Key Binds already shows its layout's name.

Saved keys don't change: options.txt keeps key.keyboard.q, as vanilla does.

Limit: a key not pressed since launch keeps its US name (on AZERTY, Walk Forwards shows W until Z is pressed once). Naming every key up front needs the OS's layout (MapVirtualKey and ToUnicodeEx on Windows, xkbcommon on Linux), which means unsafe code, and the client crates forbid it; horizon-threads holds the few OS calls the others can't make, but it's about scheduling. Happy to add it there or in a small crate of its own if that's wanted.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

InputConstants.Key.getDisplayName: a keyboard key's name is what SDL_GetKeyFromScancode gives for its scancode with the current layout and SDL's default keycode options (french_numbers, latin_letters), upper-case; keys that write nothing are translated (key.keyboard.left.shift...), as before.

Tested in the game

On Windows with a French AZERTY keyboard, by hand (horizon-ctl key sends key codes without a layout, so it can't show this): Options > Controls > Key Binds, click Jump's key, press A: the button shows A (before: Q).

key_display::tests::keys_show_what_the_layout_writes covers the rules: AZERTY's A on the Q key, M on the semicolon key, a dead ^ on the left bracket, a comma on the M key; digits kept on the number row; a Cyrillic letter, a control character, two characters and a key that writes nothing left alone.

Self-check

cargo test -p horizon-client-core --lib key_display ✅ 1 passed, cargo fmt --check ✅, cargo clippy on horizon-client-core and horizon-client-input (--tests) and on the horizon-client binary ✅ (no warnings). tools/pr_ready.py was not run.

Label: none (a fix).


🔄 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/4632 **Author:** [@ludovicthenot](https://github.com/ludovicthenot) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix-key-names-layout` --- ### 📝 Commits (1) - [`74351c8`](https://github.com/horizon-rust/horizon/commit/74351c8057f1b6b7e944c7d42d505054529cb385) Key names follow the keyboard layout: an AZERTY player's Q key shows A ### 📊 Changes **3 files changed** (+108 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-core/src/key_display.rs` (+87 -18) 📝 `crates/horizon-client-input/src/keybinds.rs` (+20 -0) 📝 `crates/horizon-client/src/game.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by ludovicthenot's AI agent (Claude Code, Claude Opus 5.5), not by ludovicthenot personally. ## What and why Fixes #4592: on an AZERTY keyboard, binding a key to A in Key Binds showed Q. The key worked; only its name was wrong. Horizon keeps keys by position (`key.keyboard.q` is the key at the US Q position, an SDL scancode), as 26.3 does, but `display_name` named them by what the US layout writes. 26.3 names them by what the player's layout writes (`InputConstants.Key.getDisplayName` through `SDL_GetKeyFromScancode`), so an AZERTY player's `key.keyboard.q` shows A. - `key_display.rs` (horizon-client-core) keeps what the layout writes on each key, by key name (`learn_layout`), and `display_name` shows it before the US character. Like SDL's default keycode options: only letter and symbol keys take it, a letter key keeps its Latin letter on a non-Latin layout (`latin_letters`), and the number row keeps its digits (`french_numbers`). The US symbol table moved to a `SYMBOLS` constant, unchanged. - `keybinds::learn_layout` (horizon-client-input) reads a key event's `key_without_modifiers()` (winit, on Windows, macOS, X11 and Wayland): a character, or a dead key's character (AZERTY's `^`). - `window_event` (game.rs) calls it on each key press, before anything else handles the key, so a key just bound in Key Binds already shows its layout's name. Saved keys don't change: `options.txt` keeps `key.keyboard.q`, as vanilla does. **Limit:** a key not pressed since launch keeps its US name (on AZERTY, Walk Forwards shows W until Z is pressed once). Naming every key up front needs the OS's layout (`MapVirtualKey` and `ToUnicodeEx` on Windows, xkbcommon on Linux), which means unsafe code, and the client crates forbid it; `horizon-threads` holds the few OS calls the others can't make, but it's about scheduling. Happy to add it there or in a small crate of its own if that's wanted. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `InputConstants.Key.getDisplayName`: a keyboard key's name is what `SDL_GetKeyFromScancode` gives for its scancode with the current layout and SDL's default keycode options (`french_numbers`, `latin_letters`), upper-case; keys that write nothing are translated (`key.keyboard.left.shift`...), as before. ## Tested in the game On Windows with a French AZERTY keyboard, by hand (`horizon-ctl key` sends key codes without a layout, so it can't show this): Options > Controls > Key Binds, click Jump's key, press A: the button shows **A** (before: Q). `key_display::tests::keys_show_what_the_layout_writes` covers the rules: AZERTY's A on the Q key, M on the semicolon key, a dead `^` on the left bracket, a comma on the M key; digits kept on the number row; a Cyrillic letter, a control character, two characters and a key that writes nothing left alone. ## Self-check `cargo test -p horizon-client-core --lib key_display` ✅ 1 passed, `cargo fmt --check` ✅, `cargo clippy` on horizon-client-core and horizon-client-input (`--tests`) and on the `horizon-client` binary ✅ (no warnings). `tools/pr_ready.py` was not run. Label: none (a fix). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:14:41 +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#5740
No description provided.