hle/gameinput: match keyboard controls by physical position, not letter #105

Open
github-bot wants to merge 1 commit from github-bot/gh-105 into main AGit
Owner

@⁠omeuniercombet on GitHub · 2026-11-24 21:32 UTC · original
omeuniercombet:pr/keyboard-layout-mouse-look → main · +100 −31 · 2 files · 1 commits · open

Problem

Players on non-US keyboard layouts (AZERTY, QWERTZ, Dvorak...) have to remap movement keys manually: the stand-in gamepad looks up keys by virtual key code (letter), so pressing Z/Q on an AZERTY keyboard never triggers W/A.

Change

  • Introduces a \Place\ type that matches a key either by its physical position (scan code) or by its virtual key (for layout-independent keys like Esc, Enter, Space, Tab, arrows, Backspace).
  • \FALLBACK_BUTTONS\ maps letter keys by US scan codes so AZERTY users automatically get ZQSD, QWERTZ users get WASD, etc., with no configuration needed.
  • Keys identical across layouts continue to match by virtual key, and Space (\
**@⁠omeuniercombet** on GitHub · 2026-11-24 21:32 UTC · [original](https://github.com/fxceless/victory-fork/pull/105) `omeuniercombet:pr/keyboard-layout-mouse-look` → `main` · +100 −31 · 2 files · 1 commits · open ### Problem Players on non-US keyboard layouts (AZERTY, QWERTZ, Dvorak...) have to remap movement keys manually: the stand-in gamepad looks up keys by virtual key code (letter), so pressing Z/Q on an AZERTY keyboard never triggers W/A. ### Change - Introduces a \Place\ type that matches a key either by its **physical position** (scan code) or by its **virtual key** (for layout-independent keys like Esc, Enter, Space, Tab, arrows, Backspace). - \FALLBACK_BUTTONS\ maps letter keys by US scan codes so AZERTY users automatically get ZQSD, QWERTZ users get WASD, etc., with no configuration needed. - Keys identical across layouts continue to match by virtual key, and Space (\
AZERTY users automatically get ZQSD without any configuration; US QWERTY
is unchanged. Keys that are common to all layouts (Esc, Enter, Space,
Tab, arrows, Backspace) continue to match by virtual key so they work
everywhere.

New test: the_stand_in_pad_follows_key_places_not_letters verifies that
AZERTY scan codes map to the correct stick/button positions.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:15 +00:00
Author
Owner

@⁠Revens2 on GitHub · 2026-11-25 07:10 UTC · original

Measured on a French (fr-FR, AZERTY) Windows 11 machine, no game run: I mapped virtual keys to scan codes with MapVirtualKeyW(vk, MAPVK_VK_TO_VSC) on the active layout.

virtual key scan code US place of that scan code
W 0x2C Z (LT on this PR)
A 0x10 Q (left shoulder)
Z 0x11 W (forward)
Q 0x1E A (left)
S, D 0x1F, 0x20 S, D (same)
I, J, K, L 0x17, 0x24, 0x25, 0x26 same

Two consequences, both from reading the code (not run in game):

  1. On main today the stand-in pad matches by virtual key, so on AZERTY the key labelled Z (forward for a French player) is LT, and Q is not bound. This PR fixes that: the key labelled Z lands on forward.
  2. The diagnostics VICTORY_KEYS list goes through the same table: host::Host::pad / keys() build a KeyState from the scripted virtual key with MapVirtualKeyW, so with this PR a script written as W,A,S,D on an AZERTY machine presses LT, the left shoulder, S, D. A script has to be written Z,Q,S,D there. Not a blocker, but the README / the VICTORY_KEYS doc comment could say that scripted letters follow the active layout once this lands (or scripted() could carry the scan code of the US place directly).

Not tested here: the PR's own tests (not built on this branch yet) and a real key press in game.

Written with an AI assistant (Claude).

**@⁠Revens2** on GitHub · 2026-11-25 07:10 UTC · [original](https://github.com/fxceless/victory-fork/pull/105#issuecomment-7155562382) Measured on a French (fr-FR, AZERTY) Windows 11 machine, no game run: I mapped virtual keys to scan codes with `MapVirtualKeyW(vk, MAPVK_VK_TO_VSC)` on the active layout. | virtual key | scan code | US place of that scan code | |---|---|---| | W | 0x2C | Z (LT on this PR) | | A | 0x10 | Q (left shoulder) | | Z | 0x11 | W (forward) | | Q | 0x1E | A (left) | | S, D | 0x1F, 0x20 | S, D (same) | | I, J, K, L | 0x17, 0x24, 0x25, 0x26 | same | Two consequences, both from reading the code (not run in game): 1. On main today the stand-in pad matches by virtual key, so on AZERTY the key labelled Z (forward for a French player) is LT, and Q is not bound. This PR fixes that: the key labelled Z lands on forward. 2. The diagnostics `VICTORY_KEYS` list goes through the same table: `host::Host::pad` / `keys()` build a `KeyState` from the scripted virtual key with `MapVirtualKeyW`, so with this PR a script written as `W,A,S,D` on an AZERTY machine presses LT, the left shoulder, S, D. A script has to be written `Z,Q,S,D` there. Not a blocker, but the README / the `VICTORY_KEYS` doc comment could say that scripted letters follow the active layout once this lands (or `scripted()` could carry the scan code of the US place directly). Not tested here: the PR's own tests (not built on this branch yet) and a real key press in game. Written with an AI assistant (Claude).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/105/head:github-bot/gh-105'
git switch 'github-bot/gh-105'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-105'
git switch 'github-bot/gh-105'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-105'
git switch 'github-bot/gh-105'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-105'
git switch 'main'
git merge --squash 'github-bot/gh-105'
git switch 'main'
git merge --ff-only 'github-bot/gh-105'
git switch 'main'
git merge 'github-bot/gh-105'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.