Report keyboard glyphs and dead keys using the focused window layout #2755
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2757"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by maxence468 on 2026-11-25T19:48:56Z.
Keyboard readings always returned zero for codePoint and false for isDeadKey. Resolve these fields from the keyboard layout of the focused title window using MapVirtualKeyExW. Scripted inputs without a focused title window use the polling thread layout. This supplies key labels to GameInput clients without consuming dead-key state. Tested on a French AZERTY Windows system, including é, dead circumflex and right Ctrl. All ten GameInput tests passed with default features and with diagnostics enabled. No in-game UI was tested.
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:07:45Z.
Correct use of MAPVK_VK_TO_CHAR: low word is the keycap glyph, high bit flags a dead key, and the query doesn't consume a pending accent. Querying the foreground thread's layout (not the calling thread's) is the right detail - it matches the layout actually active in our window. The GetKeyboardLayout(0) fallback for scripted keys keeps diagnostics working unfocused.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T20:13:44Z.
Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.
AI-assisted (Hy4 flash).
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T20:15:40Z.
Independent WARP/CPU verification for head
9ff50e868eagainst origin/main13f91caee2. State check at start and again before posting: open, non-draft, mergeable, head unchanged; no prior oni-swr comment.Environment: Windows 11 x64, Rust 1.98.1 (48a229cea 2026-09-01), cargo 1.98.1, Windows SDK dxil.dll 10.0.26100.0 (file version 1.8.2502.11).
VICTORY_WARP=1andVICTORY_D3D12_WARP=1set (WARP only, no physical GPU); no game files.CARGO_TARGET_DIR=D:\victory-warp-2741-target. Tested commit: the PR head itself, which is exactly one commit on top oforigin/main(merge-base =origin/main, so no temporary merge was needed). Host keyboard layouts: de-CH, en-GB (a Windows API test, so it ran on the real host layout; no layout was switched).Commands/results:
cargo test --locked -p victory-hle— lib 146 passed, 0 failed; other binaries pass.cargo clippy --locked -p victory-hle --all-targets -- -D warnings— pass.cargo test --locked -p victory-hle --lib keyboard_readings— 1/1 passed.cargo test --locked -p victory-hle— lib 147 passed (+1), 0 failed; and with--features diagnosticsalso lib 147 passed, 0 failed. Clippy--all-targets -- -D warningspasses with and without--features diagnostics.code_point: 0(the pre-PR value) ->keyboard_readings_include_keycap_and_extended_scan_codeFAILED at gameinput.rs:1322.dead_key: false-> the test still PASSED.Review findings:
code_point == 'A'assertion is also layout dependent: it would fail on a layout where VK_A maps to a non-Latin glyph (for example Russian or Greek). A synthetic layout-independent check, or skipping unless the layout is Latin, would be safer./// The foreground window is one of ours ...now sits abovereadingsinstead offocused_layout(the function it described).No production blocker found: the layout used is the foreground window thread's (falling back to the calling thread's for scripted keys with no focus), and the dead-key bit and low word are taken from
MAPVK_VK_TO_CHARas documented.Not tested additionally: the AZERTY branch itself (not installed here).
Not tested: physical GPU, retail title/game behavior, release build (debug profile only).
AI disclosure: Claude Code (Claude Sonnet 5.5).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:21:59Z.
Reviewed and verified
9ff50e86on Windows 11 againstmain(13f91ca).Code review
focused_layout()cleanly guards foreground ownership (process == GetCurrentProcessId()) and skips physical keyboard polling when unfocused or focused in another process, whileVICTORY_KEYSunderdiagnosticsstill falls back toGetKeyboardLayout(0).MapVirtualKeyExW(MAPVK_VK_TO_VSC_EXandMAPVK_VK_TO_CHAR) is safe with respect to system dead-key state (unlike unflaggedToUnicodeEx, it does not mutate kernel keyboard state, has no buffer truncation or surrogate issues, and handleshkl == 0gracefully).MAPVK_VK_TO_CHARreports unshifted keycap glyphs (e.g., uppercase letters, no Shift/AltGr punctuation or non-BMP glyphs), whereas#656(which conflicts in the samegameinput.rshunk) usesToUnicodeEx(..., wFlags=4)for shifted/composed characters.Verification (Windows 11,
rustc 1.98.1MSVC)cargo test -p victory-hle --lib --locked(6 consecutive full parallel runs): 6/6 passed (147 passed, 0 failed).cargo test -p victory-hle --lib --features diagnostics --locked -- modules::gameinput::: 10 passed, 0 failed (includingkeyboard_readings_include_keycap_and_extended_scan_code).cargo clippy -p victory-hle --all-targets --locked -- -D warnings(default &--all-features): 0 warnings;cargo xtask policy: 184 files ok.git merge-treeagainst13f91ca,#1430,#2715, and#2717; conflicts with#656.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:27:13Z.
Automated triage for the maintainers. In
crates/victory-hle/src/modules/gameinput.rs,key_statenow fillscode_pointanddead_keyfromMapVirtualKeyExW(MAPVK_VK_TO_CHAR)with the focused window's layout. The API use looks right, but a few things need changing first. (1) The removed comment said the title reads only scan codes and virtual keys. Please say where these fields are read, and give evidence for what the console reports incodePoint:MAPVK_VK_TO_CHARgives the unshifted keycap glyph (uppercase 'A' for the A key), which is not obviously the console's value. (2)keyboard_readings_include_keycap_and_extended_scan_codeassertscode_point == 'A'on the host layout, so it fails on non-Latin layouts (for example Russian or Greek). The dead-key assertion runs only on French AZERTY, so most machines and CI never check it. Please make the test independent of the layout, for example by loading a known layout or skipping when the layout does not match. (3) The doc comment/// The foreground window is one of ours ...now sits abovereadingsinstead offocused_layout. CI:checkpassing.Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.