Preserve held-key order in GameInput keyboard readings #2717

Open
github-bot wants to merge 2 commits from github-bot/gh-2717 into main AGit
Owner

@⁠VlREX on GitHub · 2026-11-25 18:44 UTC · original
VlREX:fix/gameinput-key-order → main · +60 −1 · 1 files · 2 commits · open

The Windows keyboard source scans virtual keys numerically. Pressing W, then A while holding W, previously returned [A, W]. GetKeyState documents that newly pressed keys are appended and released entries shift out. Preserve the order of surviving keys from the last reading, using scan code and virtual key for identity. Keep the host order for keys first observed together. Regression covers adding, removing, re-pressing, and avoiding an extra sequence number when only the poll order changes. It failed before the fix and all eight fake-host GameInput tests passed locally. No hardware or game run. GetKeyState documentation.

**@⁠VlREX** on GitHub · 2026-11-25 18:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2717) `VlREX:fix/gameinput-key-order` → `main` · +60 −1 · 1 files · 2 commits · open The Windows keyboard source scans virtual keys numerically. Pressing W, then A while holding W, previously returned [A, W]. GetKeyState documents that newly pressed keys are appended and released entries shift out. Preserve the order of surviving keys from the last reading, using scan code and virtual key for identity. Keep the host order for keys first observed together. Regression covers adding, removing, re-pressing, and avoiding an extra sequence number when only the poll order changes. It failed before the fix and all eight fake-host GameInput tests passed locally. No hardware or game run. [GetKeyState documentation](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getkeystate).
Cover small output buffers, retained readings, and stable sequence numbers.
The buffer and snapshot cases are adapted from MichaelSmithAI's
BastienRodz/VIctory#2 regression based on Marvisak/VIctory#927.
Place the test next to the keyboard reading tests so it can merge with #2715.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:12:41 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 18:47 UTC · original

#927 is still open for the same #874 fix, and the issue links a guest-facing GetKeyState test of that implementation. This PR applies the ordering in State::poll, keeps Host::keys clear of the overlap with #656, and adds a useful check that a change in poll order alone doesn’t advance the reading sequence.

Could we land one implementation and carry over the guest-facing test and the sequence-number check?

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-25 18:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/2717#issuecomment-7171396830) #927 is still open for the same #874 fix, and the issue links a guest-facing `GetKeyState` test of that implementation. This PR applies the ordering in `State::poll`, keeps `Host::keys` clear of the overlap with #656, and adds a useful check that a change in poll order alone doesn’t advance the reading sequence. Could we land one implementation and carry over the guest-facing test and the sequence-number check? *AI-assisted with Codex.*
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 18:51 UTC · original

Matches the documented semantics: surviving keys keep their relative order from the previous reading, newly pressed keys append in host poll order (stable sort with usize::MAX position). Identity by (scan_code, virtual_key) is the right pair. The regression covers the important sequences including re-press order and the sequence-number non-bump on poll-order-only change.

**@⁠kotekompotek** on GitHub · 2026-11-25 18:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2717#issuecomment-7171503707) Matches the documented semantics: surviving keys keep their relative order from the previous reading, newly pressed keys append in host poll order (stable sort with usize::MAX position). Identity by (scan_code, virtual_key) is the right pair. The regression covers the important sequences including re-press order and the sequence-number non-bump on poll-order-only change.
Author
Owner

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

Automated triage for the maintainers.

Needs rebase. This branch no longer merges cleanly into main: the conflict is in crates/victory-hle/src/modules/gameinput.rs. No content review was done yet; it will be reviewed once it is rebased onto current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2717#issuecomment-7176156987) <!-- victory-triage v1 head=16509549f834377fc8cafb9fd39c285c85bcabbb verdict=needs-rebase at=2026-11-25T22:17:40Z --> Automated triage for the maintainers. **Needs rebase.** This branch no longer merges cleanly into `main`: the conflict is in `crates/victory-hle/src/modules/gameinput.rs`. No content review was done yet; it will be reviewed once it is rebased onto 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/2717/head:github-bot/gh-2717'
git switch 'github-bot/gh-2717'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2717'
git switch 'github-bot/gh-2717'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2717'
git switch 'github-bot/gh-2717'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2717'
git switch 'main'
git merge --squash 'github-bot/gh-2717'
git switch 'main'
git merge --ff-only 'github-bot/gh-2717'
git switch 'main'
git merge 'github-bot/gh-2717'
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!2717
No description provided.