fix: show the title a pad press that ends between two of its readings #258

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

@⁠Skyfrye on GitHub · 2026-11-25 21:57 UTC · original
Skyfrye:nep/input-latch → main · +241 −19 · 3 files · 2 commits · draft

Draft: the in-game check on this base is pending (the test machine's GPU is in use for a few hours). Everything else below is done.

Change

A title that asks GameInput for a pad's current reading is handed the newest reading our 8 ms poll thread recorded. A button pressed and released between two such requests is in the history (down, then up) but is never the newest reading, so the title does not see it. On a console at 30 frames a second that needs a press shorter than 33 ms. At the 2 to 4 frames a second the game reaches here today, two requests are 0.25 to 0.5 s apart, so an ordinary tap usually falls between them, and so do the 0.2 s presses of VICTORY_KEYS. This is why the docs told users to hold each key.

Now the poll thread notes each pad button that goes down. When the title asks for the current reading and such a button is already up again, it gets one reading made for it: the pad as it is now (sticks and triggers) with that button down. The next poll records the host's state again, so the title's next request shows the release, and "previous of current" has the button up, which is what an edge check compares.

  • XInput pads and the keyboard's stand-in pad take the same path. No new thread: the existing poll thread already samples both.
  • A press is kept for 2 s at most, so a title that stops asking for a while is not handed old presses.
  • Nothing changes for a button held across requests, for sticks and triggers, or while the title asks more often than buttons change: same readings, same sequence numbers as before.
  • With no device named, a pad with such a press comes before a newer reading of another pad.

This departs from the console on purpose, in the direction the API's own reference allows for: Microsoft's page for IGameInput::GetCurrentReading says a game that polls it must "permit some missing input". Limits, marked in the code: releases are not latched, two taps of one button between two readings show as one, sticks and triggers are not latched, and a title that both walks a pad's readings forward and asks for the current one would see a short press twice.

The second commit updates the controls paragraph of docs/running-gta6.md and docs/fr/lancer-gta6.md (it said a short tap can be missed).

Linked issue: none.

Verification

Windows 11 26300, Rust 1.98.1 (MSVC), builds and tests at below-normal priority, RTX 5080, on upstream main at affaf15 (the Neptune base, PR #243), from third_party/victory.

cargo test --locked -p victory-hle   -> main: 110 passed (+1 integration); this branch: 115 passed, 0 failed (+1)
cargo build --locked --release -p victory                              -> Finished, no new warning (the 3 of main)
cargo build --locked --profile diag -p victory --features diagnostics  -> Finished, no new warning
cargo xtask policy                                                     -> asset policy: 197 files ok

Before the change, with the new tests applied to the unchanged input code: the press test and the stand-in test fail (buttons 0, expected A).

In game: pending on this base. On the previous base (4f2cf5c), two runs of 240 s and 300 s with scripted Enter presses (GTA VI 1.0.2.1, my own copy, launcher settings), with this and three other local fixes: no exception, and the scripted presses still took the title through its start screens into the world. Not measured: how many presses the start screens need before and after; the title was not instrumented for that.

Oracle and test data

None involved. Failure cases (5 new tests in gameinput.rs): a press and release between two readings is shown exactly once, also beside a held button and for two buttons at once; a held button is in every reading and an idle pad reports nothing; a short key press reaches the stand-in pad; a press older than 2 s is dropped; the no-device case.

Checklist

  • The PR covers a single reviewable behaviour (a pad press that ends between two readings of the current state).
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (Not concerned.)
  • README: not touched (the controls paragraph of the two run pages is, in both languages).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: only what the existing code comment already records (the title asks for a pad's current reading and the one before it).
  • Code taken from another project: none.

AI assistance: written with Claude Code. Claude Fable 5.2 wrote the change and its tests; Claude Sonnet 5.5 ported it to the Neptune base and ran the checks there; Claude Opus 5.5 reviewed the port, ran the game on my machine and wrote this description.

🤖 Generated with Claude Code

**@⁠Skyfrye** on GitHub · 2026-11-25 21:57 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/258) `Skyfrye:nep/input-latch` → `main` · +241 −19 · 3 files · 2 commits · draft **Draft: the in-game check on this base is pending** (the test machine's GPU is in use for a few hours). Everything else below is done. ## Change A title that asks GameInput for a pad's **current** reading is handed the newest reading our 8 ms poll thread recorded. A button pressed and released between two such requests is in the history (down, then up) but is never the newest reading, so the title does not see it. On a console at 30 frames a second that needs a press shorter than 33 ms. At the 2 to 4 frames a second the game reaches here today, two requests are 0.25 to 0.5 s apart, so an ordinary tap usually falls between them, and so do the 0.2 s presses of `VICTORY_KEYS`. This is why the docs told users to hold each key. Now the poll thread notes each pad button that goes down. When the title asks for the current reading and such a button is already up again, it gets one reading made for it: the pad as it is now (sticks and triggers) with that button down. The next poll records the host's state again, so the title's next request shows the release, and "previous of current" has the button up, which is what an edge check compares. - XInput pads and the keyboard's stand-in pad take the same path. No new thread: the existing poll thread already samples both. - A press is kept for 2 s at most, so a title that stops asking for a while is not handed old presses. - Nothing changes for a button held across requests, for sticks and triggers, or while the title asks more often than buttons change: same readings, same sequence numbers as before. - With no device named, a pad with such a press comes before a newer reading of another pad. This departs from the console on purpose, in the direction the API's own reference allows for: Microsoft's page for `IGameInput::GetCurrentReading` says a game that polls it must "permit some missing input". Limits, marked in the code: releases are not latched, two taps of one button between two readings show as one, sticks and triggers are not latched, and a title that both walks a pad's readings forward and asks for the current one would see a short press twice. The second commit updates the controls paragraph of `docs/running-gta6.md` and `docs/fr/lancer-gta6.md` (it said a short tap can be missed). Linked issue: none. ## Verification Windows 11 26300, Rust 1.98.1 (MSVC), builds and tests at below-normal priority, RTX 5080, on upstream `main` at `affaf15` (the Neptune base, PR #243), from `third_party/victory`. ``` cargo test --locked -p victory-hle -> main: 110 passed (+1 integration); this branch: 115 passed, 0 failed (+1) cargo build --locked --release -p victory -> Finished, no new warning (the 3 of main) cargo build --locked --profile diag -p victory --features diagnostics -> Finished, no new warning cargo xtask policy -> asset policy: 197 files ok ``` Before the change, with the new tests applied to the unchanged input code: the press test and the stand-in test fail (`buttons 0`, expected A). In game: pending on this base. On the previous base (`4f2cf5c`), two runs of 240 s and 300 s with scripted Enter presses (GTA VI 1.0.2.1, my own copy, launcher settings), with this and three other local fixes: no exception, and the scripted presses still took the title through its start screens into the world. Not measured: how many presses the start screens need before and after; the title was not instrumented for that. ## Oracle and test data None involved. Failure cases (5 new tests in `gameinput.rs`): a press and release between two readings is shown exactly once, also beside a held button and for two buttons at once; a held button is in every reading and an idle pad reports nothing; a short key press reaches the stand-in pad; a press older than 2 s is dropped; the no-device case. ## Checklist - [x] The PR covers a single reviewable behaviour (a pad press that ends between two readings of the current state). - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (Not concerned.) - [x] README: not touched (the controls paragraph of the two run pages is, in both languages). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: only what the existing code comment already records (the title asks for a pad's current reading and the one before it). - [x] Code taken from another project: none. AI assistance: written with Claude Code. Claude Fable 5.2 wrote the change and its tests; Claude Sonnet 5.5 ported it to the Neptune base and ran the checks there; Claude Opus 5.5 reviewed the port, ran the game on my machine and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A title that asks for a pad's current reading once per frame is handed the
newest reading our 8 ms poll thread recorded. A button pressed and released
between two such requests is in the history (down, then up) but is never
the newest reading, so the title does not see it. At the 2 to 3 frames per
second we reach, requests are 0.3 to 0.5 s apart and a tap usually falls
between two of them; so do the 0.2 s presses of VICTORY_KEYS.

The poll thread now notes each pad button that goes down. When the title
asks for the current reading and such a button is up again, it gets one
reading made for it: the pad as it is now (sticks and triggers) with that
button down. The next poll records the host's state again, so the title's
next request shows the release. The reading before the made one has the
button up, which is what an edge check by "previous of current" compares.

- XInput pads and the keyboard's stand-in pad alike: both become the same
  readings. No new sampler thread: the poll thread already samples both
  every 8 ms, and XInput only reports the current state (its packet number
  says that something changed, not what).
- A press is kept for 2 s, so a title that stops asking for a while is not
  handed old presses when it asks again.
- Nothing changes for a button held across requests, for sticks and
  triggers, or while the title asks more often than buttons change: the
  same readings with the same sequence numbers as before.
- With no device named, a pad with such a press comes before a newer
  reading of another pad.

This departs from the console on purpose. Microsoft's reference for
IGameInput::GetCurrentReading leaves such a game to "permit some missing
input": at 30 frames per second that is a press shorter than 33 ms, at 3 it
is nearly every press.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The controls section said to hold each key because a short tap can be
missed. Pad buttons (and the keys standing in for them) no longer need
that; sticks and triggers still do. English and French pages.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:40:44 +00:00
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-26 00:06 UTC · original

Thanks — please add a VICTORY_* switch to turn the latch off, so it can be A/B tested, then mark it ready.

**@⁠LooperSalty** on GitHub · 2026-11-26 00:06 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/258#issuecomment-7178410282) Thanks — please add a `VICTORY_*` switch to turn the latch off, so it can be A/B tested, then mark it ready.
Author
Owner

@⁠KainanP on GitHub · 2026-11-26 10:32 UTC · original

Test report for #258.

Merges cleanly onto current main. Setup: current origin/main (c4c93bd) merged with this PR, Windows 11 on the RTX 4060 Laptop machine. cargo test --locked -p victory-hle (CPU only, so I did not repeat it per adapter).

victory-hle main main + #258
unit 110 passed 115 passed
no_dll_planting 1 passed 1 passed

No failure. The five new GameInput tests pass.

Notes from reading the diff:

  • With device == null, only the chosen slot's pressed is cleared. A press on another pad stays latched (up to 2 s) and wins the next null-device request over a newer reading. That is what the PR says it wants, but no test has two pads with a latched press each.
  • State::current returns history.back() without the kind filter that picked the slot. That is fine because the latched reading has the same kind as the slot, but a debug_assert! on the kind would keep it true.
  • pressed_at keeps the time of the newest press only, so an older missed button in pressed lives as long as the newest one. That is a minor case.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

**@⁠KainanP** on GitHub · 2026-11-26 10:32 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/258#issuecomment-7189496553) Test report for #258. Merges cleanly onto current main. Setup: current `origin/main` (c4c93bd) merged with this PR, Windows 11 on the RTX 4060 Laptop machine. `cargo test --locked -p victory-hle` (CPU only, so I did not repeat it per adapter). | `victory-hle` | main | main + #258 | |---|---|---| | unit | 110 passed | 115 passed | | `no_dll_planting` | 1 passed | 1 passed | No failure. The five new GameInput tests pass. Notes from reading the diff: - With `device == null`, only the chosen slot's `pressed` is cleared. A press on another pad stays latched (up to 2 s) and wins the next null-device request over a newer reading. That is what the PR says it wants, but no test has two pads with a latched press each. - `State::current` returns `history.back()` without the `kind` filter that picked the slot. That is fine because the latched reading has the same kind as the slot, but a `debug_assert!` on the kind would keep it true. - `pressed_at` keeps the time of the newest press only, so an older missed button in `pressed` lives as long as the newest one. That is a minor case. _AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this._
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/258/head:github-bot/gh-258'
git switch 'github-bot/gh-258'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-258'
git switch 'github-bot/gh-258'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-258'
git switch 'github-bot/gh-258'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-258'
git switch 'main'
git merge --squash 'github-bot/gh-258'
git switch 'main'
git merge --ff-only 'github-bot/gh-258'
git switch 'main'
git merge 'github-bot/gh-258'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.