GameInput: keep 256 readings per device, not 32 (input lost at low frame rates) #2218

Closed
github-bot wants to merge 1 commit from gh-pr/2218/head into gh-pr/2218/base
Owner

@⁠desplmfao on GitHub · 2026-11-25 08:08 UTC · original
desplmfao:fix/gameinput-history → main · +1 −1 · 1 files · 1 commits · closed without merging

Problem

GameInput keeps the last 32 readings per device (HISTORY in crates/victory-hle/src/modules/gameinput.rs). VIctory polls every 8 ms, so 32 readings cover about 256 ms. A title that reads input once per frame and asks for readings since its last one (GetNextReading / GetPreviousReading from a reference) gets REFERENCE_TOO_OLD whenever a frame takes longer than that. At the 1–3 fps Grand Theft Auto VI currently runs at, that's every frame, so input is lost.

Change

HISTORY goes from 32 to 256: about 2 s of readings per device. Nothing is sized by the constant. history is a VecDeque that grows as readings arrive, and a reading is only recorded when a device's state changes. Lookups walk it linearly, as before.

Memory: a reading is about 80 bytes (72 for the boxed reading plus its queue slot), so full histories for 6 devices go from about 15 KiB to about 120 KiB.

The idea comes from fxceless/victory-fork#23 by @⁠youroot-code (credited in the commit).

Tested

  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo test -p victory-hle gameinput on Windows x64 (under Proton here): 9 passed.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠desplmfao** on GitHub · 2026-11-25 08:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/2218) `desplmfao:fix/gameinput-history` → `main` · +1 −1 · 1 files · 1 commits · closed without merging ## Problem GameInput keeps the last 32 readings per device (`HISTORY` in `crates/victory-hle/src/modules/gameinput.rs`). VIctory polls every 8 ms, so 32 readings cover about 256 ms. A title that reads input once per frame and asks for readings since its last one (`GetNextReading` / `GetPreviousReading` from a reference) gets `REFERENCE_TOO_OLD` whenever a frame takes longer than that. At the 1–3 fps Grand Theft Auto VI currently runs at, that's every frame, so input is lost. ## Change `HISTORY` goes from 32 to 256: about 2 s of readings per device. Nothing is sized by the constant. `history` is a `VecDeque` that grows as readings arrive, and a reading is only recorded when a device's state changes. Lookups walk it linearly, as before. Memory: a reading is about 80 bytes (72 for the boxed reading plus its queue slot), so full histories for 6 devices go from about 15 KiB to about 120 KiB. The idea comes from fxceless/victory-fork#23 by @⁠youroot-code (credited in the commit). ## Tested - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo test -p victory-hle gameinput` on Windows x64 (under Proton here): 9 passed. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Readings are polled every 8 ms (POLL) and one is recorded whenever a
device's state changes, so a device whose state keeps changing (a moving
stick) fills 32 entries in about 256 ms. A title that walks the readings
once per frame with GetNextReading / GetPreviousReading loses readings,
and gets REFERENCE_TOO_OLD for the one it holds, as soon as a frame takes
longer than that: at 1-3 fps (330-1000 ms frames) every frame does. 256
entries hold about 2 s of continuous change, enough for 1 fps.

Memory: the history is a VecDeque that grows on demand (nothing is sized
by HISTORY up front); each entry is a boxed 72-byte Reading plus an 8-byte
slot (keyboard readings add 12 bytes per held key). Full histories on all
6 devices take about 6 x 256 x 80 B = 120 KiB, against about 15 KiB
before. Lookups scan the history linearly, which stays cheap at 256.

From fxceless/victory-fork#23.

Co-Authored-By: youroot-code <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:58:48 +00:00
github-bot closed this pull request 2026-11-26 04:58:50 +00:00
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 08:53 UTC · original

@⁠catminou4 thanks. I checked the two together: #2218 and #2230 (head d3d9cd1) merge with no conflict, and the merged gameinput.rs has HISTORY = 256. #2230 doesn't touch the constant, it only shows 32 because it's based on main. So either merge order works without a reconcile step.

**@⁠desplmfao** on GitHub · 2026-11-25 08:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2218#issuecomment-7157595773) @⁠catminou4 thanks. I checked the two together: #2218 and #2230 (head `d3d9cd1`) merge with no conflict, and the merged `gameinput.rs` has `HISTORY = 256`. #2230 doesn't touch the constant, it only shows 32 because it's based on `main`. So either merge order works without a reconcile step.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 12:42 UTC · original

Automated triage for the maintainers.

Merge candidate. HISTORY in crates/victory-hle/src/modules/gameinput.rs (readings kept per device for the next/previous-reading lookups) goes from 32 to 256. With the 8 ms POLL, 32 readings cover only about 256 ms. A title frame longer than that, which is common at the current frame rates, finds the reading it last saw already dropped, and input between the two frames is lost. 256 readings cover about 2 s, at a small memory cost per device.

CI check passes, and the branch merges cleanly. It also combines cleanly with #2230 (see the note above).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 12:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2218#issuecomment-7162755567) <!-- victory-triage v1 head=42dd7a374e30261eb79d2f3aff44dafec1abeba5 verdict=merge-candidate at=2026-11-25T12:46:00Z --> Automated triage for the maintainers. **Merge candidate.** `HISTORY` in `crates/victory-hle/src/modules/gameinput.rs` (readings kept per device for the next/previous-reading lookups) goes from 32 to 256. With the 8 ms `POLL`, 32 readings cover only about 256 ms. A title frame longer than that, which is common at the current frame rates, finds the reading it last saw already dropped, and input between the two frames is lost. 256 readings cover about 2 s, at a small memory cost per device. CI `check` passes, and the branch merges cleanly. It also combines cleanly with #2230 (see the note above). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

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

Automated triage for the maintainers, second look (a review against current main, with builds and tests where they could change the verdict).

Closing because the title cannot hit the case. Its keyboard reader calls GetCurrentReading and then GetNextReading starting from that reading, and its pad code calls GetPreviousReading of the current reading, so no reference older than the newest reading is ever passed. The figure "32 readings = 256 ms" does not hold either: a reading is recorded only when the state changes, not on every poll.

If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 22:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2218#issuecomment-7175946206) Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because the title cannot hit the case. Its keyboard reader calls `GetCurrentReading` and then `GetNextReading` starting from that reading, and its pad code calls `GetPreviousReading` of the current reading, so no reference older than the newest reading is ever passed. The figure "32 readings = 256 ms" does not hold either: a reading is recorded only when the state changes, not on every poll. If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.

Pull request closed

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!2218
No description provided.