Preserve held-key order in GameInput keyboard readings #2715

Open
VlREX wants to merge 2 commits from upstream-pr/2717 into main
VlREX commented 2026-11-25 18:44:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VlREX on 2026-11-25T18:44:06Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6611313364 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2717). Originally posted by [VlREX](https://github.com/VlREX) on 2026-11-25T18:44:06Z. --- 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).
DrDarkDK commented 2026-11-25 19:06:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:47:10Z.


#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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171396830 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2717#issuecomment-7171396830). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T18:47:10Z. --- #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.*
kotekompotek commented 2026-11-25 19:06:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:51:43Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171503707 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2717#issuecomment-7171503707). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:51:43Z. --- 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.
Marvisak commented 2026-11-25 23:06:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:16:32Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176156987 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2717#issuecomment-7176156987). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:16:32Z. --- <!-- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2717:upstream-pr/2717'
git switch 'upstream-pr/2717'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2717'
git switch 'upstream-pr/2717'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2717'
git switch 'upstream-pr/2717'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2717'
git switch 'main'
git merge --squash 'upstream-pr/2717'
git switch 'main'
git merge --ff-only 'upstream-pr/2717'
git switch 'main'
git merge 'upstream-pr/2717'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!2715
No description provided.