feat: drive pads from a file with VICTORY_INPUT_LIVE #417

Open
github-bot wants to merge 1 commit from github-bot/gh-417 into main AGit
Owner

@⁠jean-melikian on GitHub · 2026-11-26 18:00 UTC · original
jean-melikian:feat/input-live → main · +635 −7 · 3 files · 1 commits · draft

Change

Adds an opt-in, file-driven input channel so an external tool can press buttons on the emulated pads deterministically and without SendInput: no keystrokes are injected into Windows, and the game window does not need focus. It is meant for automated test loops (passing title/menu screens, holding a button for a known number of frames, replaying short input sequences), and for users who stream the PC (Moonlight/Sunshine/Apollo), where SendInput would type into whatever window is in front.

VICTORY_INPUT_LIVE=<file>: the existing gameinput poll thread re-reads the file at most every 100 ms and only acts on lines appended since the previous read. Content present at start-up is ignored, a truncated file is read again from the start, and both UTF-8 and UTF-16 LE are accepted.

Line format:

line     := empty | "#" text | press | release
press    := button [":" duration]          (no duration: 0.3 s)
release  := "release" [":" button]         (all buttons, or just one)
duration := seconds ["s"]                  e.g. 3, 0.5s   (0 < s <= 600)
          | integer "f"                    frames presented since the press, e.g. 90f
          | "hold"                         until a matching release, or a cap
button   := a b x y start|menu back|view lb rb ls rs up down left right lt rt

Example: printf 'b:hold\n' >> live.txt, then printf 'release\n' >> live.txt once the screen has changed.

Holds are capped by VICTORY_INPUT_LIVE_MAX_S (default 30) and VICTORY_INPUT_LIVE_MAX_FRAMES (default 1800), whichever is hit first.

  • Frame-counted durations. Title gauges ("hold B to confirm") fill in game time, and at a low frame rate a hold of a few wall-clock seconds covers only a few frames. Durations can therefore be given in presented frames, counted with queue::frame_count(), which becomes pub for this.
  • Every pad. Presses go to every connected pad, plus the matching keyboard keys (Enter, Backspace, Escape, Tab, arrows). When a streaming host creates a virtual XInput pad, the keyboard-driven stand-in pad does not exist, and a keyboard-only channel such as VICTORY_AUTO_A never reaches a title screen that listens to the pad.
  • Logging. Each release is logged with its duration and the number of frames presented while it was held, e.g. gameinput: release b@… after 3.2 s, 7 frames presented (live, hold, release line). This tells whether a hold actually reached the title.

Without the variable, nothing changes: no file is read and no thread is added.

Linked issue: Refs #368. It is a small first piece of the deterministic input replay discussed there, a pad-input channel driven by frame counts. It does not record or replay full pad states.

Verification

cargo test --offline -p victory-hle --lib gameinput     (third_party/victory, -j 4)
  → test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 116 filtered out; finished in 0.12s
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!
python -m pytest                                                      → 1415 passed, 488 skipped in 11.40s

The 488 skipped tests are the ones that need the C++ runtime built locally ("runtime C++ non compilé (cmake -S runtime -B runtime/build)"), plus the GPU tests gated on it; the CI pytest job builds the runtime and runs them. This PR touches only Rust code under third_party/victory, which the cargo test run above covers.

The 5 new tests:

  • live::tests::grammar ;
  • live::tests::apply_adds_to_a_pad ;
  • live::tests::presses_hold_end_and_log (seconds, frames, hold/release, caps) ;
  • live::tests::a_file_made_later_counts_from_its_start ;
  • tests::live_presses_reach_a_host_pad_and_the_keyboard_without_focus, where a host pad sits in slot 0, as with a streaming host's virtual pad.

They fail without the change, since the module does not exist without it.

The build emits two victory-gpu warnings, already on main and not touched by this PR: host.rs:8648 unused doc comment, and descriptor/host.rs:1844 left_to_draws never used.

Runtime check: one short session on a local release build (RTX 3080 Ti, driver 621.24 (32.0.16.2124), Windows 11) with an external pilot script appending lines to the file. The log shows the press reaching the gameinput path and its frame count: gameinput: live press [email protected]:0.3, then gameinput: release [email protected] after 0.3 s, 9 frames presented (live, 0.3 s). hold / release and frame-counted durations are covered by the unit tests only so far. No game files are involved in the tests.

Oracle and test data

Unit tests only, with no title data: they build pad states and input files in a temporary directory. Failure case: without this change, VICTORY_INPUT_LIVE is ignored and no press reaches a pad.

Checklist

  • The PR covers a single reviewable behaviour.
  • 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. (No new emulated function.)
  • README: no README change.
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: none.
  • Code taken from another project: none.

AI assistance: this change was written with AI assistance (Claude); it was reviewed and tested as described above.

🤖 Generated with Claude Code

**@⁠jean-melikian** on GitHub · 2026-11-26 18:00 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/417) `jean-melikian:feat/input-live` → `main` · +635 −7 · 3 files · 1 commits · draft ## Change Adds an opt-in, file-driven input channel so an external tool can press buttons on the emulated pads **deterministically and without `SendInput`**: no keystrokes are injected into Windows, and the game window does not need focus. It is meant for automated test loops (passing title/menu screens, holding a button for a known number of frames, replaying short input sequences), and for users who stream the PC (Moonlight/Sunshine/Apollo), where `SendInput` would type into whatever window is in front. `VICTORY_INPUT_LIVE=<file>`: the existing gameinput poll thread re-reads the file at most every 100 ms and only acts on **lines appended since the previous read**. Content present at start-up is ignored, a truncated file is read again from the start, and both UTF-8 and UTF-16 LE are accepted. Line format: ``` line := empty | "#" text | press | release press := button [":" duration] (no duration: 0.3 s) release := "release" [":" button] (all buttons, or just one) duration := seconds ["s"] e.g. 3, 0.5s (0 < s <= 600) | integer "f" frames presented since the press, e.g. 90f | "hold" until a matching release, or a cap button := a b x y start|menu back|view lb rb ls rs up down left right lt rt ``` Example: `printf 'b:hold\n' >> live.txt`, then `printf 'release\n' >> live.txt` once the screen has changed. Holds are capped by `VICTORY_INPUT_LIVE_MAX_S` (default 30) and `VICTORY_INPUT_LIVE_MAX_FRAMES` (default 1800), whichever is hit first. - **Frame-counted durations.** Title gauges ("hold B to confirm") fill in game time, and at a low frame rate a hold of a few wall-clock seconds covers only a few frames. Durations can therefore be given in presented frames, counted with `queue::frame_count()`, which becomes `pub` for this. - **Every pad.** Presses go to **every connected pad**, plus the matching keyboard keys (Enter, Backspace, Escape, Tab, arrows). When a streaming host creates a virtual XInput pad, the keyboard-driven stand-in pad does not exist, and a keyboard-only channel such as `VICTORY_AUTO_A` never reaches a title screen that listens to the pad. - **Logging.** Each release is logged with its duration and the number of frames presented while it was held, e.g. `gameinput: release b@… after 3.2 s, 7 frames presented (live, hold, release line)`. This tells whether a hold actually reached the title. Without the variable, nothing changes: no file is read and no thread is added. Linked issue: Refs #368. It is a small first piece of the deterministic input replay discussed there, a pad-input channel driven by frame counts. It does not record or replay full pad states. ## Verification ``` cargo test --offline -p victory-hle --lib gameinput (third_party/victory, -j 4) → test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 116 filtered out; finished in 0.12s python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! python -m pytest → 1415 passed, 488 skipped in 11.40s ``` The 488 skipped tests are the ones that need the C++ runtime built locally ("runtime C++ non compilé (cmake -S runtime -B runtime/build)"), plus the GPU tests gated on it; the CI `pytest` job builds the runtime and runs them. This PR touches only Rust code under `third_party/victory`, which the `cargo test` run above covers. The 5 new tests: - `live::tests::grammar` ; - `live::tests::apply_adds_to_a_pad` ; - `live::tests::presses_hold_end_and_log` (seconds, frames, hold/release, caps) ; - `live::tests::a_file_made_later_counts_from_its_start` ; - `tests::live_presses_reach_a_host_pad_and_the_keyboard_without_focus`, where a host pad sits in slot 0, as with a streaming host's virtual pad. They fail without the change, since the module does not exist without it. The build emits two `victory-gpu` warnings, already on `main` and not touched by this PR: `host.rs:8648` unused doc comment, and `descriptor/host.rs:1844` `left_to_draws` never used. Runtime check: one short session on a local release build (RTX 3080 Ti, driver 621.24 (32.0.16.2124), Windows 11) with an external pilot script appending lines to the file. The log shows the press reaching the gameinput path and its frame count: `gameinput: live press [email protected]:0.3`, then `gameinput: release [email protected] after 0.3 s, 9 frames presented (live, 0.3 s)`. `hold` / `release` and frame-counted durations are covered by the unit tests only so far. No game files are involved in the tests. ## Oracle and test data Unit tests only, with no title data: they build pad states and input files in a temporary directory. Failure case: without this change, `VICTORY_INPUT_LIVE` is ignored and no press reaches a pad. ## Checklist - [x] The PR covers a single reviewable behaviour. - [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. (No new emulated function.) - [x] README: no README change. - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: none. - [x] Code taken from another project: none. AI assistance: this change was written with AI assistance (Claude); it was reviewed and tested as described above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
VICTORY_INPUT_LIVE=<file> lets an external tool press buttons on the
emulated pads, without SendInput and without window focus. The poll
thread re-reads the file at most every 100 ms and only acts on lines
appended since the last read (content present at start-up is skipped;
a truncated file is re-read from the start; UTF-8 and UTF-16 LE).

Line format: `button[:duration]` or `release[:button]`, where the
duration is seconds (`3`, `0.5s`), presented frames (`90f`) or `hold`
(until `release`). Holds are capped by VICTORY_INPUT_LIVE_MAX_S
(default 30) and VICTORY_INPUT_LIVE_MAX_FRAMES (default 1800). Presses
go to every connected pad, so they also reach a pad created by a
streaming host (ViGEm), plus the matching keyboard keys. Each release
is logged with its duration and the number of frames presented while
it was held, to tell whether a hold reached the title.

queue::frame_count() becomes pub so durations can count frames.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:03:30 +00:00
This pull request has changes conflicting with the target branch.
  • third_party/victory/crates/victory-gpu/src/queue.rs
  • third_party/victory/crates/victory-hle/src/modules/gameinput.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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