GameInput: held keys are reported in the order they were pressed, as documented #927
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/927"
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 BastienRodz on 2026-11-24T14:17:20Z.
What's wrong
Microsoft's GameInput keyboard and mouse documentation specifies the order of the array returned by
IGameInputReading::GetKeyState:In
crates/victory-hle/src/modules/gameinput.rs:1158-1163,host::Host::keysrebuilds the held-key list on every poll by scanning virtual-key codes in ascending numerical order:key_state(crates/victory-hle/src/modules/gameinput.rs:1003-1014) copies that list directly into the caller'sGameInputKeyStatebuffer. If the player holdsZ(0x5A) and then also pressesA(0x41), GameInput documents[Z, A], while VIctory reports[A, Z].Impact
Key-binding screens and any title code that identifies the most recently pressed key from the end of the
GetKeyStatearray read the wrong key whenever a newly pressed key has a lower virtual-key code than a key already held (for example, bindingZwhen the player pressedA).What the fix does
Track the previous poll's held virtual keys on
host::Hostand compute the next ordered list with a small purepress_order(previous, down)helper: keep keys frompreviousthat are still indownin their existing order, then append keys indownthat were not inprevious. Because PR #656 also editsHost::keys, the helper lives outsidekeysand the change insidekeysis limited to applyingpress_orderand iteratingself.held_keys, leaving key scanning, filtering, andKeyStateconstruction untouched.Tests
held_keys_keep_their_press_orderexercisespress_orderwith these sequences:[Z, A]. Today's scan gives[A, Z].[Z, A, B].[A].[A, Z].On GitHub's
windows-latest, with the upstream CI's commands (clippy-D warningswith and without--all-features, thencargo test --workspace --locked), everything passes:victory-hle95 passed, 0 failed (https://github.com/BastienRodz/VIctory/actions/runs/45399104790).Not tested: a title's key-binding screen.
No game data used. AI-assisted: found with GPT-6.2 Astra, written with Gemini 4 Neon, reviewed and verified with Claude Code.
Fixes #874.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:21:17Z.
Review: APPROVED
Tested head
4ce99c1(fast-forward onmainffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):cargo test -p victory-hle: 95 passed, 0 failed (plusno_dll_planting: 1 passed), includingmodules::gameinput::tests::held_keys_keep_their_press_ordercargo clippy -p victory-hle --all-targets: 0 warningscargo xtask policy: okClean fix preserving press order for held keys. Approving.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:59Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
4ce99c1:cargo test -p victory-hlepasses, 96 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T00:27:39Z.
Rebased onto current
main.keys()now builds itsKeyStates throughkey_state, so the change is justpress_orderapplied before that map.gameinputtests: 10 passed under Wine,held_keys_keep_their_press_orderandscripted_keys_merge_into_connected_host_padincluded.Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T00:31:51Z.
The CI failure is only
victory-shader'sgathers_at_a_level_match_the_hardwareandpermutes_read_the_lane_named_and_zero_from_lanes_left_out.mainfails those two the same way on the runner's software adapter, and #1752 fixes them.victory-hle, the only crate this PR touches, passes,gameinputtests included.Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-25T00:56:45Z.
Still red on the same two
victory-shadertests:main's own CI after42363abfails them too. The runner's Basic Render Driver doesn't set the software flag that commit checks. #1919 adds its vendor/device ids, andwindows-latestis green with it. This PR's crate passes.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:32:59Z.
Automated triage for the maintainers.
Verdict: merge candidate. Re-reviewed at
0832e0a, which merges cleanly intomain.ISSUE_DRAFT.mdis gone, and the PR touches onlycrates/victory-hle/src/modules/gameinput.rs, as you said.press_orderkeeps the previous poll's held keys in order and appends new ones once.host::Host::keysnow reportsheld_keysin that order, which matches the documented GetKeyState ordering.held_keys_keep_their_press_ordercovers a lower virtual-key code pressed second, releasing a middle key and the first key, pressing a key again, and a duplicate in one reading.CI: passing. Recommending a look, not approving.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:19:39Z.
Code review and Windows 11 verification at head
10dd2549d4damerged cleanly ontomain(63bcca43c6a0):crates/victory-hle/src/modules/gameinput.rs:1145-1152, 1217, 1261-1262):press_orderretains held keys in prior press order and appends newly pressed keys, clears cleanly on focus loss (press_order(&self.held_keys, &[])), and integrates cleanly withState::updateordered equality andkey_statetruncation.diagnostics, duplicate VKs emitted in the sameVICTORY_KEYSwindow aren't deduped before appending; (2) inheld_keys_keep_their_press_order(line 1916), passing&held(b"ZA") instead of&with_b(b"ZAB") only tests releasing the first key rather than releasing a middle key.cargo xtask policy:191 files ok;cargo clippy --locked -p victory-hle --tests -- -D warnings: 0 warningsvictory-hle -- gameinput: 11/11 passed.LGTM.
Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-26T01:24:32Z.
Thanks, both notes taken in
6166c20:press_ordernow appends each key once, so a key listed twice in one reading (scriptedVICTORY_KEYSin diagnostics builds) is held once.ZABwithBZdown givesZB) and the first key (ZABwithABdown givesAB), re-presses Z at the end, and checksAAgivesA.gameinputtests (11) pass under Wine, andcargo clippy --workspace --all-targets --locked -- -D warningsis clean.Imported from Marvisak/VIctory. Originally posted by BastienRodz on 2026-11-26T02:19:38Z.
Removed:
ISSUE_DRAFT.mdwas a stray untracked file in my checkout, and my commit picked it up by mistake.0832e0ais the same change without it; the PR touchescrates/victory-hle/src/modules/gameinput.rsonly.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.