GameInput: held keys are reported in the order they were pressed, as documented #927
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!927
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@BastienRodz on GitHub · 2026-11-24 14:17 UTC · original
BastienRodz:hle/held-keys-in-press-order→main· +47 −1 · 1 files · 2 commits · openWhat'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
@Zipettte on GitHub · 2026-11-24 15:40 UTC · original
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).
@BastienRodz on GitHub · 2026-11-25 00:27 UTC · original
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.@BastienRodz on GitHub · 2026-11-25 00:31 UTC · original
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.@BastienRodz on GitHub · 2026-11-25 00:56 UTC · original
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.@Marvisak on GitHub · 2026-11-25 02:32 UTC · original · edited 2026-11-26 03:18 UTC
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
@fuzeofficlal on GitHub · 2026-11-26 01:19 UTC · original
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.
@BastienRodz on GitHub · 2026-11-26 01:24 UTC · original
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.@BastienRodz on GitHub · 2026-11-26 02:19 UTC · original
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.