Input: report the character each held key types #656

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

@⁠lameloball2813-ui on GitHub · 2026-11-24 06:21 UTC · original
lameloball2813-ui:input/keyboard-characters → main · +116 −8 · 1 files · 1 commits · open

Held keys reported code point 0 (the shortcut: in gameinput.rs's host source). They now report the character they type, as GameInput's keyboard state does:

  • ToUnicodeEx with the foreground window's keyboard layout, so it follows the user's layout.
  • The keyboard state it reads is built from the keys held this poll. Devices report left/right modifiers only, so either side's Shift/Ctrl/Alt also sets the generic one. Caps Lock's toggle comes from GetKeyState.
  • Called with flag 4 (keep keyboard state), so polling never eats a pending dead key the title's window is composing.
  • Dead keys set dead_key, with the accent's spacing form as the code point. Keys that type nothing, or several characters at once, report 0.

Grand Theft Auto VI reads scan codes and virtual keys only, so nothing changes for it. This fills in the platform side for titles that read characters.

Testing

Windows 11, RTX 5060 Ti. Not tested in a title (I don't have one to run).

  • Two new tests in gameinput::host: modifier sides set the generic modifier and Caps Lock sets its toggle; Space and Enter type 0x20/0x0D and F1 types nothing in the machine's layout (layout-independent keys only).
  • cargo test --workspace: everything passes except victory-loader's load_probe, which fails before and after this change on my machine. It builds the fixture into target/fixtures inside the checkout, and my checkout's path is long enough that link.exe hits LNK1104 (MAX_PATH). Unrelated to this change.
  • cargo clippy -p victory-hle --all-targets: no warnings in gameinput.rs. cargo xtask policy: ok.

Not covered: dead keys and Caps Lock have no automated test (they depend on the machine's layout and toggle state), and I haven't checked them by hand on a layout with dead keys.

**@⁠lameloball2813-ui** on GitHub · 2026-11-24 06:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/656) `lameloball2813-ui:input/keyboard-characters` → `main` · +116 −8 · 1 files · 1 commits · open Held keys reported code point 0 (the `shortcut:` in `gameinput.rs`'s host source). They now report the character they type, as GameInput's keyboard state does: - `ToUnicodeEx` with the foreground window's keyboard layout, so it follows the user's layout. - The keyboard state it reads is built from the keys held this poll. Devices report left/right modifiers only, so either side's Shift/Ctrl/Alt also sets the generic one. Caps Lock's toggle comes from `GetKeyState`. - Called with flag 4 (keep keyboard state), so polling never eats a pending dead key the title's window is composing. - Dead keys set `dead_key`, with the accent's spacing form as the code point. Keys that type nothing, or several characters at once, report 0. Grand Theft Auto VI reads scan codes and virtual keys only, so nothing changes for it. This fills in the platform side for titles that read characters. ## Testing Windows 11, RTX 5060 Ti. Not tested in a title (I don't have one to run). - Two new tests in `gameinput::host`: modifier sides set the generic modifier and Caps Lock sets its toggle; Space and Enter type `0x20`/`0x0D` and F1 types nothing in the machine's layout (layout-independent keys only). - `cargo test --workspace`: everything passes except `victory-loader`'s `load_probe`, which fails before and after this change on my machine. It builds the fixture into `target/fixtures` inside the checkout, and my checkout's path is long enough that `link.exe` hits LNK1104 (MAX_PATH). Unrelated to this change. - `cargo clippy -p victory-hle --all-targets`: no warnings in `gameinput.rs`. `cargo xtask policy`: ok. Not covered: dead keys and Caps Lock have no automated test (they depend on the machine's layout and toggle state), and I haven't checked them by hand on a layout with dead keys.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:11:46 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 11:39 UTC · original

Independent verification & code review on Windows 11 Pro (build 26100, Rust 1.98.1), cleanly merged onto main (ffe310e):

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: PASS
  • cargo clippy -p victory-hle --all-targets --features diagnostics --locked -- -D warnings: PASS
  • cargo test -p victory-hle --locked: 96 passed + 1 integration test (no_dll_planting), 0 failed (including new either_sides_modifier_holds_the_generic_one and keys_type_their_characters)

Diff review (crates/victory-hle/src/modules/gameinput.rs): clean and thoughtful — using ToUnicodeEx with flag 4 (KEEP_STATE) avoids mutating keyboard dead-key state, and populating generic 0x10..=0x12 from sided 0xA0..=0xA5 ensures Shift/Ctrl/Alt modifiers work accurately.

  • Tiny non-blocking note: when ToUnicodeEx returns n < 0 (dead key), &text[..1] covers BMP dead keys; using n.unsigned_abs() as usize (clamped to text.len()) would also preserve a 2-unit surrogate pair if a layout ever emits a non-BMP dead-key spacing character.

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 11:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/656#issuecomment-7130381088) Independent verification & code review on Windows 11 Pro (build 26100, Rust `1.98.1`), cleanly merged onto `main` (`ffe310e`): - `cargo xtask policy`: PASS (`154 files ok`) - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: PASS - `cargo clippy -p victory-hle --all-targets --features diagnostics --locked -- -D warnings`: PASS - `cargo test -p victory-hle --locked`: **96 passed + 1 integration test (`no_dll_planting`), 0 failed** (including new `either_sides_modifier_holds_the_generic_one` and `keys_type_their_characters`) Diff review (`crates/victory-hle/src/modules/gameinput.rs`): clean and thoughtful — using `ToUnicodeEx` with flag `4` (`KEEP_STATE`) avoids mutating keyboard dead-key state, and populating generic `0x10..=0x12` from sided `0xA0..=0xA5` ensures Shift/Ctrl/Alt modifiers work accurately. - Tiny non-blocking note: when `ToUnicodeEx` returns `n < 0` (dead key), `&text[..1]` covers BMP dead keys; using `n.unsigned_abs() as usize` (clamped to `text.len()`) would also preserve a 2-unit surrogate pair if a layout ever emits a non-BMP dead-key spacing character. *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠molodayamama on GitHub · 2026-11-24 14:04 UTC · original

Independent Windows check of 3b001ed80c97a9da158696ae06c4961548953a53 (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).

  • cargo test -p victory-hle --locked --lib either_sides_modifier_holds_the_generic_one -- --test-threads=1 --nocapture: 1 passed.
  • cargo test -p victory-hle --locked --lib keys_type_their_characters -- --test-threads=1 --nocapture: 1 passed.

The focused checks passed for left/right modifier aliases and the characters produced from held keys.

Only source-built synthetic fixtures were used. AI-assisted verification.

**@⁠molodayamama** on GitHub · 2026-11-24 14:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/656#issuecomment-7133796651) Independent Windows check of `3b001ed80c97a9da158696ae06c4961548953a53` (Windows 10 22H2 19045, Rust 1.98.1, MSVC x64). - `cargo test -p victory-hle --locked --lib either_sides_modifier_holds_the_generic_one -- --test-threads=1 --nocapture`: 1 passed. - `cargo test -p victory-hle --locked --lib keys_type_their_characters -- --test-threads=1 --nocapture`: 1 passed. The focused checks passed for left/right modifier aliases and the characters produced from held keys. Only source-built synthetic fixtures were used. AI-assisted verification.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:16 UTC · original

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-hle/src/modules/gameinput.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/656#issuecomment-7149386859) <!-- victory-triage v1 head=3b001ed80c97a9da158696ae06c4961548953a53 verdict=needs-rebase at=2026-11-25T01:16:51Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-hle/src/modules/gameinput.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-hle/src/modules/gameinput.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-656'
git switch 'github-bot/gh-656'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-656'
git switch 'github-bot/gh-656'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-656'
git switch 'main'
git merge --squash 'github-bot/gh-656'
git switch 'main'
git merge --ff-only 'github-bot/gh-656'
git switch 'main'
git merge 'github-bot/gh-656'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!656
No description provided.