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

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

@⁠Zayfway on GitHub · 2026-11-25 19:20 UTC · original
Zayfway:input/press-live → main · +231 −1 · 1 files · 2 commits · open

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 #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

**@⁠Zayfway** on GitHub · 2026-11-25 19:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/2449) `Zayfway:input/press-live` → `main` · +231 −1 · 1 files · 2 commits · open `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 #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](https://claude.com/claude-code)
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 <[email protected]>
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 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:17 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 20:29 UTC · original

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

**@⁠DavidM1911** on GitHub · 2026-11-25 20:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2449#issuecomment-7173744332) 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
Author
Owner

@⁠Zayfway on GitHub · 2026-11-25 21:17 UTC · original

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.

**@⁠Zayfway** on GitHub · 2026-11-25 21:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/2449#issuecomment-7174883730) 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.*
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 01:50 UTC · original

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

**@⁠DavidM1911** on GitHub · 2026-11-26 01:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2449#issuecomment-7180183269) 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
Author
Owner

@⁠bmjask on GitHub · 2026-11-25 20:38 UTC · original · reviewed

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.

**@⁠bmjask** on GitHub · 2026-11-25 20:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/2449#pullrequestreview-6064640077) · **reviewed** 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.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 07:38 UTC · original · reviewed

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.

**@⁠luckyteagirl** on GitHub · 2026-11-26 07:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/2449#pullrequestreview-6070158855) · **reviewed** `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.
Author
Owner

@⁠Gevroska on GitHub · 2026-11-26 10:17 UTC · original

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.

**@⁠Gevroska** on GitHub · 2026-11-26 10:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/2449#issuecomment-7189163437) 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.
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/2449/head:github-bot/gh-2449'
git switch 'github-bot/gh-2449'

Merge

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