Input: a tap is kept until the title has read it (taps were lost at a few frames a second) #640

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

@⁠sagouindupm on GitHub · 2026-11-25 03:45 UTC · original
sagouindupm:input-latch-pr → main · +154 −14 · 1 files · 2 commits · open

What

A key or pad button that is pressed and released between two of the title's input readings is now reported as down until the title has read it.

Why

The host is polled every 8 ms, and the title takes the current reading about once a frame. On a slow card a frame is far longer than a tap, so the press is down and up again before the title looks, and it is lost. On my 8 GB card (Series S profile, about 370 ms a frame in the world) the menu key only answered when held for a frame or more.

#23 (history 32 to 256) helps a title that walks the history, but here the title takes the current reading, so a longer history alone is not enough: see the numbers below.

How

crates/victory-hle/src/modules/gameinput.rs only:

  • current_reading counts the title's readings (LOOKS).
  • A small Latch keeps each press from when it begins until the title has taken 2 current readings since (2, because a pad reading and a keyboard reading of the same frame are separate calls), or 2 s for a title that is not reading at all. A key that is still held is untouched, and is released as soon as it is let go once the title has seen it.
  • The host source uses one latch for the keyboard and one per pad for the buttons. Sticks and triggers are not latched.

Cost when nothing is tapped: nothing changes. Cost of a tap: it lasts at most 2 title readings longer than the finger.

Measured

RTX 3050 8 GB, i5-12400F, Windows 11, release build, Series S profile, first room of the world (about 370 ms a frame). A script presses the menu key for 60 ms; the pause menu opening shows as the window title falling from about 4600 draws to about 90 draws a frame.

Build 60 ms taps that opened the menu
main (c96b4f2 + the Series S PRs) 0 of 3
the same + #23 2 of 5
the same + this PR (without #23) 5 of 5

A 1.5 s hold opens the menu on all three.

cargo test --release -p victory-hle on 310c6eb + this commit: 100 passed, 0 failed (4 new tests of the latch: a tap between two readings is kept, a held key is released when let go, a tap is dropped after 2 s without readings, keys are latched one by one).

Not tested: a real pad (the button path uses the same latch, but I only have a keyboard here), Series X, Linux/Proton.

AI-assisted: Claude Code (Claude Fable 5.2) wrote the change and ran the measurements, under my direction.

**@⁠sagouindupm** on GitHub · 2026-11-25 03:45 UTC · [original](https://github.com/fxceless/victory-fork/pull/640) `sagouindupm:input-latch-pr` → `main` · +154 −14 · 1 files · 2 commits · open ## What A key or pad button that is pressed and released between two of the title's input readings is now reported as down until the title has read it. ## Why The host is polled every 8 ms, and the title takes the current reading about once a frame. On a slow card a frame is far longer than a tap, so the press is down and up again before the title looks, and it is lost. On my 8 GB card (Series S profile, about 370 ms a frame in the world) the menu key only answered when held for a frame or more. #23 (history 32 to 256) helps a title that walks the history, but here the title takes the current reading, so a longer history alone is not enough: see the numbers below. ## How `crates/victory-hle/src/modules/gameinput.rs` only: - `current_reading` counts the title's readings (`LOOKS`). - A small `Latch` keeps each press from when it begins until the title has taken 2 current readings since (2, because a pad reading and a keyboard reading of the same frame are separate calls), or 2 s for a title that is not reading at all. A key that is still held is untouched, and is released as soon as it is let go once the title has seen it. - The host source uses one latch for the keyboard and one per pad for the buttons. Sticks and triggers are not latched. Cost when nothing is tapped: nothing changes. Cost of a tap: it lasts at most 2 title readings longer than the finger. ## Measured RTX 3050 8 GB, i5-12400F, Windows 11, release build, Series S profile, first room of the world (about 370 ms a frame). A script presses the menu key for 60 ms; the pause menu opening shows as the window title falling from about 4600 draws to about 90 draws a frame. | Build | 60 ms taps that opened the menu | |---|---| | `main` (`c96b4f2` + the Series S PRs) | 0 of 3 | | the same + #23 | 2 of 5 | | the same + this PR (without #23) | 5 of 5 | A 1.5 s hold opens the menu on all three. `cargo test --release -p victory-hle` on `310c6eb` + this commit: 100 passed, 0 failed (4 new tests of the latch: a tap between two readings is kept, a held key is released when let go, a tap is dropped after 2 s without readings, keys are latched one by one). Not tested: a real pad (the button path uses the same latch, but I only have a keyboard here), Series X, Linux/Proton. AI-assisted: Claude Code (Claude Fable 5.2) wrote the change and ran the measurements, under my direction.
The host is polled every 8 ms and the title takes the current reading once a frame. At about 370 ms a frame a 60 ms tap is down and up again between two readings and is lost. A press is now reported from when it begins until the title has taken two current readings since, or two seconds.

Measured on an RTX 3050 8 GB, Series S profile: 60 ms taps of the menu key that open the pause menu, 0 of 3 before, 5 of 5 with this.
(cherry picked from commit 317d7a48a77a393ce859141bb07a1d201e177b8c)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:47:56 +00:00
Author
Owner

@⁠ryotdev on GitHub · 2026-11-25 03:54 UTC · original

I reproduced one way a tap can still disappear on f0fecd2. In a Windows test I queued a short keyboard press, then called GetCurrentReading twice for a disconnected pad before the next host poll. Both calls returned DEVICE_DISCONNECTED. The next poll released the key before the title received any keyboard reading. Successful reads of a different physical controller can also consume the same global count.

One-file follow-up with regression test. It counts successful deliveries per input source, with the stand-in pad and keyboard sharing their sampled keys. The test covers a disconnected slot, a separate connected pad and returns through both keyboard-backed devices. The disconnected case failed on the original PR. The updated Windows HLE suite passed 101/101 using a simulated controller. I haven't tested a physical controller. AI-assisted.

**@⁠ryotdev** on GitHub · 2026-11-25 03:54 UTC · [original](https://github.com/fxceless/victory-fork/pull/640#issuecomment-7152344875) I reproduced one way a tap can still disappear on `f0fecd2`. In a Windows test I queued a short keyboard press, then called `GetCurrentReading` twice for a disconnected pad before the next host poll. Both calls returned `DEVICE_DISCONNECTED`. The next poll released the key before the title received any keyboard reading. Successful reads of a different physical controller can also consume the same global count. [One-file follow-up with regression test](https://github.com/ryotdev/victory-gta6/commit/317d7a48a77a393ce859141bb07a1d201e177b8c). It counts successful deliveries per input source, with the stand-in pad and keyboard sharing their sampled keys. The test covers a disconnected slot, a separate connected pad and returns through both keyboard-backed devices. The disconnected case failed on the original PR. The updated Windows HLE suite passed 101/101 using a simulated controller. I haven't tested a physical controller. AI-assisted.
Author
Owner

@⁠sagouindupm on GitHub · 2026-11-25 04:44 UTC · original

@⁠ryotdev thank you, you are right on both counts: a failed read and a read of another controller should not count. Taken as 91d9e53 on this branch (your 317d7a4 cherry-picked with -x, your authorship kept).

Here on Windows: cargo test --release -p victory-hle 101 passed, 0 failed, with only_successful_reads_from_the_input_source_count_toward_a_tap among them. The in-game count in the description (5 of 5 taps) was made on f0fecd2; I have not repeated it on 91d9e53 yet.

AI-assisted: Claude Code (Claude Fable 5.2) reviewed and tested the follow-up.

**@⁠sagouindupm** on GitHub · 2026-11-25 04:44 UTC · [original](https://github.com/fxceless/victory-fork/pull/640#issuecomment-7153115312) @⁠ryotdev thank you, you are right on both counts: a failed read and a read of another controller should not count. Taken as `91d9e53` on this branch (your `317d7a4` cherry-picked with `-x`, your authorship kept). Here on Windows: `cargo test --release -p victory-hle` 101 passed, 0 failed, with `only_successful_reads_from_the_input_source_count_toward_a_tap` among them. The in-game count in the description (5 of 5 taps) was made on `f0fecd2`; I have not repeated it on `91d9e53` yet. AI-assisted: Claude Code (Claude Fable 5.2) reviewed and tested the follow-up.
Author
Owner

@⁠sagouindupm on GitHub · 2026-11-25 04:56 UTC · original

In-game count repeated on 91d9e53 (same card and scene, about 340 ms a frame): 5 of 5 taps of 60 ms opened the pause menu, as on f0fecd2.

AI-assisted: Claude Code (Claude Fable 5.2) ran the test.

**@⁠sagouindupm** on GitHub · 2026-11-25 04:56 UTC · [original](https://github.com/fxceless/victory-fork/pull/640#issuecomment-7153302171) In-game count repeated on `91d9e53` (same card and scene, about 340 ms a frame): 5 of 5 taps of 60 ms opened the pause menu, as on `f0fecd2`. AI-assisted: Claude Code (Claude Fable 5.2) ran the test.
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/640/head:github-bot/gh-640'
git switch 'github-bot/gh-640'

Merge

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