Skip to content

gameinput: report a missed press once to a slow reader (RT-GAMEINPUT-SLOW-READER) - #1510

Open
QemmHD wants to merge 2 commits into
mainfrom
claude/gameinput-slow-reader
Open

QemmHD wants to merge 2 commits into
mainfrom
claude/gameinput-slow-reader

Conversation

@QemmHD

@QemmHD QemmHD commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue as: RT-GAMEINPUT-SLOW-READER (#14 (comment))

Carries DadaCap's kSlowReaderUs from their boot-prototype branch (commit fa497b9), with DadaCap's authorship and date kept, as agreed in #14 (comment 7151032887).

What and why

The title reads each pad with GetCurrentReading once a frame. At a few frames a second, a press can start and end between two reads, so it's lost. That's why the first-run pages need several presses to advance at low frame rates (#233 fills the history, which the title doesn't read). Each pad now remembers the newest reading that pressed a button the last read didn't report. A read that comes more than kSlowReaderUs (50 ms) after the previous one is given that press once, and the next read gets the pad's real state. close_pad clears it.

Scope: only the GameInput part of fa497b9 (runtime/shims/gameinput.cpp +32, runtime/test/gameinput_test.cpp +16), unchanged apart from line positions. The prototype's other changes in that commit aren't included. It doesn't conflict with #1074's LEONIDA_INPUT_SCRIPT: scripted presses go through the same path, so a short scripted press now also reaches a slow reader.

Tested

Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja, RelWithDebInfo, on main 2213d5c:

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.24, Windows 11

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.
  • A new translator rule is in the contract table of docs/design.md. (n/a)

AI-assisted (Claude Code, Claude Opus 5.5).

🤖 Generated with Claude Code

https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf

…SLOW-READER)

A title that reads a pad with GetCurrentReading once a frame, at a few
frames a second, never sees a press that came and went between two
reads. A pad now keeps the newest reading that pressed a button the last
read did not report; a read more than kSlowReaderUs (50 ms) after the
previous one answers that press once, and the next read the pad's real
state.

Carried from DadaCap's boot-prototype fa497b9, split to the GameInput
part (runtime/shims/gameinput.cpp and its test in
runtime/test/gameinput_test.cpp); the other shims in that commit are not
included. Applied unchanged.

AI-assisted. Run on Windows 11, RTX 5080. No game data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
@ytsodacan

ytsodacan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

[KEEP]

  • Overlaps open gameinput: preserve controller transitions between polls #233 ("gameinput: preserve controller transitions between polls"), which touches the same runtime/shims/gameinput.cpp and runtime/test/gameinput_test.cpp and addresses the same missed-press problem; make_game, gameinput: controller, keyboard and mouse input out of the box (INPUT-OUT-OF-THE-BOX) #1528 also edits gameinput. A maintainer should decide which approach lands and the others should rebase on it.
  • Design concern: GetCurrentReading now has side effects (a stored missed reading, read_buttons/read_us state, and a 50 ms kSlowReaderUs timing heuristic), so returning a stale press once changes what callers see; this deserves maintainer sign-off.
  • Only one test was added (about 15 lines, a slow reader sees a missed press once), with a wall-clock Sleep(80) that could be flaky on slow runners; it does not cover close_pad reset or multiple devices.
  • CI is entirely pending (windows, macos, linux-gpu-tools, no-game-data, change-scope), so the build and test are unverified.

@QemmHD

QemmHD commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @ytsodacan, fair points:

  • gameinput: preserve controller transitions between polls #233 is a different approach to the same symptom. It keeps the transitions in the reading history. DadaCap's finding (Coordinating who works on what #14, comment 7136979744) is that the title reads only GetCurrentReading once a frame and never the history, so the history alone doesn't bring the press back. That's why this changes what the current reading returns. gameinput: preserve controller transitions between polls #233 is still a draft. If a maintainer prefers one approach, I'm happy to rebase this onto it or drop it.
  • The side effect is intended: a reader slower than 50 ms is shown the press it missed, once. I agree it deserves a maintainer's sign-off.
  • Tests: you're right that close_pad and multiple devices aren't covered, and that the Sleep(80) against the 50 ms threshold is timing-based. I'll add a close_pad reset case and a two-device case, and widen the margin.

AI-assisted (Claude Code, Claude Opus 5.5).

… wider slow-reader margin

Review follow-up for the kSlowReaderUs missed-press logic:
- close_pad: a press missed by a slow reader, then an unplug/replug, must
  not come back on the first slow read after reconnecting.
- two pads: a missed press on the Xbox pad and one on the DualSense are
  each reported only on their own pad, once.
- the slow-reader sleeps are now 150 ms (3x kSlowReaderUs) for slow CI.

Tested: ctest -R ^gameinput passes plain and with LEONIDA_VK_VALIDATION=1
(VS 2022, Ninja). Against the pre-fix shim the slow-reader and both
two-pad checks fail (the close_pad check passes trivially there); with the
fix minus close_pad's missed reset, the close_pad check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
@QemmHD

QemmHD commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Added the coverage asked for, in 045bb0f (DadaCap's commit is untouched):

  • the slow-reader check now waits 150 ms, 3× the 50 ms threshold;
  • two pads: a press on each pad is reported only on that pad's next read, and once;
  • close_pad: a pending press doesn't survive an unplug and replug.

gameinput_test now runs 369 checks with 0 failures, and ctest ^gameinput passes 3/3 both plain and with validation. Against main's shim, the slow-reader and per-pad checks fail. With the fix but without the reset in close_pad, the close_pad check fails, so it does catch a missing reset.

AI-assisted (Claude Code, Claude Opus 5.5).

@djrolfes

Copy link
Copy Markdown
Contributor

Independent RTX 3070 Ti / Linux Wine 11.22 integration validation starting for exact head 045bb0f. Main 42537e7 + owned #1558 / FSPX translator fixes now reaches the rendered first-run setup. With two ordinary scripted A presses, each logged by GameInput (60 s and 100 s), the first moves from the player prompt to Navigation Experience, but the second does not visibly advance it by the 160-second bound. Presented captures after the first press are ~36 seconds apart, so this is consistent with your slow-reader diagnosis, not yet proof of the exact consumption path.

I have preserved that build and am adding only your two commits before synthetic GameInput checks and the identical bounded two-press retest. Runtime assertions/watchdog stay enabled; no legal agreement acceptance is scripted. No duplication of implementation ownership; raw images/logs stay local. AI-assisted.

@djrolfes

Copy link
Copy Markdown
Contributor

Retest update: exact head 045bb0f applied locally as a14a691b7 builds; gameinput passes 369 checks and gameinput_script passes 10. gameinput_host fails the same three checks on both this candidate and unmodified 42537e7 under the same Wine prefix (host GameInputCreate returns E_NOTIMPL), so that host-comparison limitation is not counted as a shim pass.

The identical 160-second retail probe with A@60/A@100 still ends visually on Navigation Experience. Both scripted presses are logged; 25,450 native graphics PSOs succeed, no fatal title exception, and late captures are ~45 seconds apart per 300 frames. This does NOT establish that the fix is ineffective generally, nor that this title read used the covered explicit-pad path. I am adding opt-in local GetCurrentReading return-path/button-state logging, with no behavior change, to distinguish actual delivery from a mere poll-thread press log. The diagnostic will not be submitted as a competing implementation. No legal acceptance or world claim; raw evidence remains local. AI-assisted.

@djrolfes

Copy link
Copy Markdown
Contributor

Diagnostic/caveat update: the local trace confirms this title uses the explicit-pad GetCurrentReading path, predominantly one caller/thread. A press delayed beyond its real 300 ms hold is returned once by the fix, then the current released state is returned on the next read; a press sampled while held appears in repeated reads. That matches the intended policy. It does not by itself prove the UI consumes the one-shot replay.

Important configuration caveat: I found that my local launcher used --run rather than the documented --first-run-ui profile, so it omitted the profile’s graphics-layout, GPU-label and frame-pacing defaults. Treat the earlier setup-page symptom as evidence from that incomplete/custom configuration, NOT a confirmed failure of this PR under the supported UI profile. I am correcting the launcher/profile and refreshing the independent main baseline before further attribution. No delivery policy was changed in the diagnostic build; no legal agreement was accepted. AI-assisted; raw traces/images remain local.

milk4sale pushed a commit to milk4sale/leonida that referenced this pull request Nov 27, 2026
…get-in-order

GPU: the indirect budget is charged in record order and no longer wraps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants