GameInput: held keys come back in virtual-key order, not in the order they were pressed #874
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#874
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 13:04 UTC · original
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).Fix
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.The fix is ready on a branch of my fork, since PR creation is limited to collaborators: https://github.com/BastienRodz/VIctory/commits/hle/held-keys-in-press-order (one commit on
mainffe310e,gameinput.rs+37/-1).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.
@MichaelSmithAI on GitHub · 2026-11-24 13:20 UTC · original
The guest GetKeyState check confirms the fix on Win64 under Wine. With Z held on one poll and A added on the next,
ffe310ereturns [A, Z] and 4ce99c1 returns [Z, A]. Release/repress, a two-key caller buffer, and reading older retained snapshots after later polls all passed. The keyboard states were injected at the host query boundary. The test is in BastienRodz/VIctory#2.For anyone combining this with #656, both branches edit Host::keys. Building the character state from the current held set and emitting the reading in remembered press order preserves both behaviors. All 11 GameInput tests passed with the new fixture on that merge, including the character and modifier tests. Tested merge resolution
@Marvisak on GitHub · 2026-11-25 06:55 UTC · original
Automated triage for the maintainers.
Confirmed on
main. Incrates/victory-hle/src/modules/gameinput.rs,host::Host::keysrebuilds the held keys on each poll by scanning0x08..=0xFEin ascending order and keeps no earlier order, sokey_statereturns them in virtual-key order and not in the press order GameInput documents. Your fix is open as PR #927 (hle/held-keys-in-press-order), so review continues there. The comment above has a tested merge with #656, which edits the same function.Generated by Claude Code