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

Open
omeuniercombet wants to merge 1 commit from upstream-pr/105 into main
omeuniercombet commented 2026-11-24 21:32:06 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by omeuniercombet on 2026-11-24T21:32:06Z.


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 (\
<!-- greyfinch-sync:fxceless/victory-fork:issue:6591831443 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/105). Originally posted by [omeuniercombet](https://github.com/omeuniercombet) on 2026-11-24T21:32:06Z. --- ### 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 (\
Revens2 commented 2026-11-25 08:08:57 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Revens2 on 2026-11-25T07:10:07Z.


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).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7155562382 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/105#issuecomment-7155562382). Originally posted by [Revens2](https://github.com/Revens2) on 2026-11-25T07:10:07Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/105:upstream-pr/105'
git switch 'upstream-pr/105'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/105'
git switch 'upstream-pr/105'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/105'
git switch 'upstream-pr/105'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/105'
git switch 'main'
git merge --squash 'upstream-pr/105'
git switch 'main'
git merge --ff-only 'upstream-pr/105'
git switch 'main'
git merge 'upstream-pr/105'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
fxceless/victory-fork!105
No description provided.