Skip to content

GameInput: XCL_PRESS_LIVE presses the lines appended to a file while the title runs - #2449

Open
Zayfway wants to merge 2 commits into
xcl-dev:mainfrom
Zayfway:input/press-live
Open

Zayfway wants to merge 2 commits into
xcl-dev:mainfrom
Zayfway:input/press-live

Conversation

@Zayfway

@Zayfway Zayfway commented Nov 25, 2026 •

Copy link
Copy Markdown

XCL_PRESS_LIVE=<file>: lines appended to the file while the title runs are pressed in order, one after another. A script or an agent can then walk a title's menus by deciding each press after it has seen the last screen. Until now every press had to be timed before the run (XCL_PRESS_AT) or made through the keyboard, which needs the window's focus.

What is in it

  • hle/gameinput.rs: a live module. A thread reads what is appended to the file every 100 ms. Each complete line is queued; lines already in the file at the start are not pressed.
  • Line format: BUTTON[+BUTTON…][:ms], names as in XCL_PRESS_AT (case does not matter), held 200 ms unless a time is given; wait:ms holds nothing.
  • 150 ms of nothing follow each line, so the same button twice is two presses.
  • A line with an unknown name is logged and skipped, not pressed as nothing.
  • The held buttons are or-ed into scripted(), the path XCL_PRESS_AT already uses, so they need no focus.
  • 4 unit tests:
    • line parsing (a press held 0 ms is refused);
    • one line after another, with the gap;
    • polls 10 s apart lose no press;
    • a line is taken only once its newline is written.
  • follow() reads only the bytes appended since its last look. Emptying the file (or replacing it with a shorter one) starts over; the append-only contract is in the doc.

Why: from a background process, SetForegroundWindow / SendInput are often refused (no focus, a system dialog on top). Screens such as first boot, legal pages with a countdown, and loading screens come at different times from run to run, so fixed XCL_PRESS_AT timings drift.

Tested

  • RTX 3060 12 GB (driver 610.88, 32-lane), Ryzen 7 5700X, 16 GB RAM, Windows 11 26300, Rust 1.100.0, debug and release.

  • cargo test --workspace --no-fail-fast -- --test-threads=4 at d0a127e: 1292 passed, 1 failed, 46 ignored.

    • The failure is gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier. It fails the same way on main at 50a9fde on this card, and is not touched here.
    • SKIPPED GPU tests: 25, all "no wave64" (32-lane card).
    • tests/e2e.rs needs cargo build --workspace first; with it, 3 passed.
  • In the game at this head (d0a127e): on the profile screen, with no focus, Bogus then A were written to the file. The log shows:

    • XCL_PRESS_LIVE "Bogus" not understood …;
    • XCL_PRESS_LIVE "A" pressed;
    • gamepad buttons 0x4 pressed for the first time, 13 ms later.

    The title then left its profile screen for its intro (checked on a screenshot before and after, not attached).

  • An earlier form of the same code (same module, on D3D12.X: integration branch that reaches the in-world HUD on NVIDIA (reference, not for merge) #2057's branch) drove 3 runs of the newer retail title from a fresh data folder: profile, first-boot screens, legal pages, policy checkboxes, into loading. The log shows GameInput: live press … for each line, and the screens advance as pressed. These presses were made without the window's focus; SendInput had been refused.

Regression run

main:

xcl-smoke v1
commit: 50a9fdef81cb796b8756a31defb0648301d002ce
gpu: NVIDIA GeForce RTX 3060
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 835 (PresentX 835)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14902 MB

PR:

xcl-smoke v1
commit: d0a127e662b8055cfb8f11f7e899546b7d09a829
gpu: NVIDIA GeForce RTX 3060
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1616 (PresentX 1616)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14836 MB

(main ran first, with colder caches; neither run reaches the code, which only acts with XCL_PRESS_LIVE set.)

Not tested

  • AMD; stick input (the live file only presses buttons, like XCL_PRESS_AT).

AI use

  • Claude Code (Claude Opus 5.5) wrote the code and the tests, ran the suite and the smoke runs on the hardware above, and wrote this description.

🤖 Generated with Claude Code

…the title runs

XCL_PRESS_AT needs every press timed before the run starts. A title's
first-boot screens, legal pages with a countdown and loading screens come at
different times from run to run, so a script or an agent walking them needs
to decide the next press after it has seen the last screen, and a process
in the background often cannot give the XCL window the focus that the
keyboard path needs.

With XCL_PRESS_LIVE=<file>, a thread follows the file and every complete
line appended is pressed in order: a button name of XCL_PRESS_AT (case does
not matter), several joined by + to be held together, an optional hold in
ms (200 by default), or wait:<ms>. 150 ms of nothing follow each line so
the same button twice is two presses. Lines already in the file at the
start are not pressed; a line with a name it does not know is logged and
skipped. The buttons are or-ed into scripted(), so they need no focus.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: 1 real failure, deterministic (also fails --test-threads=1, 1219/1):
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
  assertion failed: group barriers in the program (lower_dxil.rs:1155)

The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.

— Devin

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not merge-ready. follow() rereads the entire file every 100 ms rather than reading from offset, making a long-lived append-only automation file O(total size) per poll with repeated full allocations. Truncate-and-rewrite/atomic replacement can also be missed if the file regrows beyond offset before polling; document append-only semantics or robustly identify rotation. Finally, Queue::held advances through all expired lines with the same now, so a long inter-poll interval drops queued presses despite the comment that late polling still sees every press. Decide/test that contract, and provide current Windows/title-driven XCL_PRESS_LIVE evidence.

…t look

Review: the file was read whole every 100 ms. follow() now seeks to the
offset already read and reads only the new bytes; an incomplete last line
is kept for the next look (complete_lines). Emptying the file, or replacing
it with a shorter one, starts over from its beginning; the append-only
contract and the case of a longer replacement are written in the doc.

A button press held 0 ms is refused (the title could never see it).

Tests: polls_far_apart_lose_no_press (three presses, polls 10 s apart: each
is seen, in order; a line's hold starts at the first poll after it is
due), lines_are_taken_only_once_complete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Zayfway

Zayfway commented Nov 25, 2026

Copy link
Copy Markdown
Author

Thanks both. Updated in d0a127e; the description has the new suite counts, a new regression block and an in-title check at this head.

@bmjask:

  • Whole file every 100 ms: fixed. follow() keeps the offset already read, seeks to it, and reads only the bytes appended since. An incomplete last line waits in a buffer for the next look (complete_lines, tested).
  • Rotation: the contract is now written down as append-only. Emptying the file, or replacing it with a shorter one, starts over from its beginning. Replacing it with a longer one between two looks reads its tail as if appended; that case is named in the doc rather than detected.
  • Late polls: I believe no press is dropped. held(now) only leaves the current line when now is past its end. The line it then takes gets until = now + hold with hold > 0, so it is returned on that same poll and is never skipped by it. One poll can therefore move past at most one finished line.
    • The one way to lose a press was a hold of 0 ms; A:0 is now refused at parse time.
    • polls_far_apart_lose_no_press pins this down: three presses, polls 10 s apart, all three seen, in order.
  • In-title evidence: at d0a127e, on the profile screen with no window focus, Bogus then A written to the file give XCL_PRESS_LIVE "Bogus" not understood, then XCL_PRESS_LIVE "A" pressed, then gamepad buttons 0x4 pressed for the first time 13 ms later. The title then left its profile screen.

@DavidM1911: a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier fails the same way on main at 50a9fde on an RTX 3060, run alone with cargo test -p xcl --lib a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier. This PR only touches hle/gameinput.rs, so that failure belongs to main (the recompiler), not to this change.

AI-assisted (Claude Code); every result above is from this machine.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gameinput.rs:344–349,415–416: the watcher takes its initial file length only when QUEUE is first accessed, and that happens inside scripted() on the first GameInput state poll (line 263). The documented contract says lines already present at startup are skipped and lines appended while the title runs are pressed. With an empty precreated file, launch the title, append A\n during startup before its first state poll, then let it poll: QUEUE initializes with length 2 and starts follow at EOF, silently discarding that command. This gap can be long on a title that delays its first input query, and the late-poll queue test cannot cover it because that test starts after watcher initialization.

Could the initial offset/watcher be established at host or title startup, before GameInput polling, and could a fixture append between startup and first poll? If first-poll initialization is intentional, the docs and a ready signal need to make that boundary explicit for automation clients. Source review at exact head d0a127e662b8055cfb8f11f7e899546b7d09a829; I have not run a title-timed reproduction. AI-assisted review with Codex.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
@Gevroska

Copy link
Copy Markdown

I tested XCL_PRESS_LIVE through a GameInput reading callback on PR head d0a127e6. Appending A:100 to the selected file delivered an A press followed by a neutral reading. A B press in a separate file produced no callback. After I unregistered the callback, the poller still observed a Down press from the selected file, and no callback arrived during the following 350 ms. The focused Windows test passed with zero skips.

I also ran the GTA VI menu sequence twice on an RTX 3080 using local build 648786af, instrumented to record button transitions. Both runs recorded all 14 presses and 14 releases, checked both boxes, and reached loading without sending desktop input or changing focus. Navigation took 91.228 s and 91.295 s.

The first run later faulted during loading. The second reached its scheduled 300-second exit. Neither showed a playable scene.

I used Codex GPT-6.2 Sol for the callback fixture and title runs. A separate Codex GPT-6.2 Sol agent verified the recorded transitions and loading observations. Codex GPT-6.2 Astra wrote this comment.

I reviewed and approved this comment before posting.

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.

5 participants