Skip to content

Diagnostics: script gamepad input by frame (VICTORY_SCRIPTED_INPUT) - #3293

Open
neonbyte1 wants to merge 2 commits into
Marvisak:mainfrom
neonbyte1:pr/scripted-input
Open

neonbyte1 wants to merge 2 commits into
Marvisak:mainfrom
neonbyte1:pr/scripted-input

Conversation

@neonbyte1

Copy link
Copy Markdown

A diagnostics switch that plays a scripted gamepad timeline, so a headless run can move the character without a real controller or window focus:

VICTORY_SCRIPTED_INPUT='1500:back;1800:look_left;1860:fwd;2400:off'

Each entry sets the pad from that presented frame until the next entry. It's keyed on the frame token that victory_gpu::frame present logs show. The states:

  • left stick: fwd, back, left, right;
  • right stick: look_*;
  • triggers: lt, rt;
  • buttons: a/b/x/y, menu, view, lb/rb/ls/rs, and the d-pad (du/dd/dl/dr);
  • off releases everything.

States combine with + (fwd+look_right). The script overlays a connected pad, or the keyboard stand-in pad when none is connected.

How it relates to VICTORY_KEYS: VICTORY_KEYS (and #3239's holds and repeats) is timed in seconds and goes through the keyboard path. This one is timed in presented frames and sets pad state directly. At about one frame per second, wall-clock timing lands at different points of the game from run to run, while frame-keyed timing is repeatable. The README row says so next to VICTORY_KEYS.

Changes:

  • gameinput.rs: the parser, the timeline lookup, and the overlay in the poll, plus three unit tests: parsing, segment lookup, and the overlaid reading.
  • frame.rs: a diagnostics-only accessor for the frame number.
  • README.md: one row next to VICTORY_KEYS.

All of it is behind diagnostics; when the variable is unset, nothing changes.

In game (GTA VI on Linux, RTX 5090, GE-Proton11-14, headless gamescope, main plus the PRs needed on that setup):

  • The script above walked the character back from the cell window from frame 1500, turned the camera from 1800, and walked forward from 1860.
  • The hints changed to "Approach a cellmate to interact with them", then "Hold … to interact".
  • By frame 2200 the objective was "Go with the prison guard".
  • No faults during the run.

Tested: the gameinput tests pass under cargo xtask wine-test (#1218), 13/13, with and without diagnostics. Clippy -D warnings and cargo xtask policy are clean. Not run on native Windows.

AI-assisted (Claude); measured on my machine, no game data shared.

@AurumCarlos AurumCarlos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Frame-keyed timing is a good complement to VICTORY_KEYS, and the diagnostics forwarding to victory-gpu is already there, so frame::number() resolves.

One trap: unknown tokens are ignored but the entry is still kept, so a typo'd entry (1800:fwrd, look_rigth) becomes a neutral pad and silently acts like off from that frame on. In an unattended run that looks like the character just stopped. A warn! naming the token (once, at parse time) would make that obvious; and scripted_input_timeline_holds_the_last_state could pin it.

@neonbyte1

Copy link
Copy Markdown
Author

@AurumCarlos good catch, thanks. Fixed in 56dcd63. An entry with an unknown token is now dropped whole, so the last valid state stays active, and the parser warns once per bad token with the entry text (unknown scripted input token; entry ignored).

I chose dropping the whole entry over keeping the recognised tokens: applying fwd from fwd+bogus would invent a state the script never asked for, and a lone typo would still look like off.

The timeline test now includes 40:fwd+bogus and 50:look_rigth, and checks that the previous state (back) is still active at frame 49. A second test checks that a bad token is reported once. The gameinput tests pass under Wine (14/14), and clippy, policy and formatting are clean.

AI-assisted (Claude); measured on my machine, no game data shared.

@AurumCarlos AurumCarlos left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

56dcd63 resolves it: dropping the whole entry keeps the last valid state, and the warning names the token and the entry once. The two tests cover both. LGTM.

Tiny edge, no change needed: a trailing + (1500:fwd+) now yields an empty token, so that entry is dropped with a warning for "". That's the right outcome, just a slightly cryptic message.

@neonbyte1

Copy link
Copy Markdown
Author

@AurumCarlos thanks for re-checking. Agreed on 1500:fwd+: dropping it is the right outcome, and the "" in the warning is cryptic. I'll leave it as is unless a maintainer would like the message to say "empty token" explicitly; that's a one-line change.

AI-assisted (Claude); no game data shared.

@cloph-dsp

Copy link
Copy Markdown

Independent Windows verification of PR #3293 (head 56dcd63).

  • Environment: Windows, Rust 1.100.0/MSVC, per-worktree CARGO_TARGET_DIR=D:\Victory-Contrib\target-3293, CARGO_BUILD_JOBS=2.
  • Command: cargo test --locked -p victory-hle --lib -- --exact modules::gameinput::tests::scripted_input_timeline_holds_the_last_state modules::gameinput::tests::scripted_pad_reaches_the_stand_in_reading modules::gameinput::tests::scripted_pad_overlays_a_host_pad
  • Result: 3 passed; 0 failed; 153 filtered out, exit 0.
  • git diff --check origin/main HEAD clean.
  • Negative control: none of the three new test names exists on the merge base 63bcca4 (synthetic tests are added by this PR).
  • Scope: CPU/HLE-only synthetic timeline tests; the in-game scripted-input scenario was not replayed.
  • AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only). No game data or assets used.

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed and verified locally on Windows 11 x64:

  • VICTORY_SCRIPTED_INPUT cleanly drives frame-indexed gamepad state timelines over both stand-in and connected host pads without affecting normal input when unset.
  • cargo test -p victory-hle --lib modules::gameinput:: -- --test-threads=1: 14 passed, 0 failed (including scripted_input_timeline_holds_the_last_state, scripted_input_warns_once_per_unknown_token, scripted_pad_overlays_a_host_pad, and scripted_pad_reaches_the_stand_in_reading).
  • cargo clippy -p victory-gpu -p victory-hle --all-targets -- -D warnings: clean.
  • cargo clippy -p victory-gpu -p victory-hle --features diagnostics --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

@fuzeofficlal fuzeofficlal 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.

LGTM — verified against origin/main (63bcca43) on Windows x64.

  • 56dcd63 cleanly addresses earlier parsing concerns by dropping the entire entry on unknown tokens, preserving the prior valid state, and emitting a one-time warning (unknown scripted input token; entry ignored).
  • Everything stays gated behind diagnostics with no behavior change when VICTORY_SCRIPTED_INPUT is unset.
  • Minor non-blocking notes:
    • Single-frame entries (e.g. 1500:a;1501:off) can be skipped if multiple frames advance within the 8 ms input polling interval (crates/victory-hle/src/modules/gameinput.rs:254, 510).
    • merge_pad overlays additively over host/stand-in state, diagnostics builds still read frame::number() (gameinput.rs:1376) even when the env var is unset, and repeated conflicting stick tokens in one entry clamp sequentially per token (gameinput.rs:199).
  • Checks:
    • cargo test --locked -p victory-gpu --lib frame:: (default and --features diagnostics): 2 passed, 0 failed.
    • cargo test --locked -p victory-hle --lib modules::gameinput:: (default and --features diagnostics): 14 passed, 0 failed.
    • cargo clippy -p victory-gpu -p victory-hle --all-targets --locked -- -D warnings (default and --all-features): clean.
    • cargo xtask policy: 191 files ok; rustfmt --edition 2024: clean on changed hunks.

Synthetic tests only; no game data used.

@futurepro62

Copy link
Copy Markdown

NVIDIA full-suite run, to go with the reports above by Dukestar69, cloph-dsp, fuzeofficlal, since none of them names a GPU run. Tested exact head 56dcd63 (on its base 63bcca4).

Tested

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@neonbyte1

Copy link
Copy Markdown
Author

@futurepro62 thanks, that's the GPU run this PR was missing, and it matches what I see on an RTX 5090 under Wine (the gameinput tests pass there too). Good to have the pre-existing NVIDIA failures named with their issues.

AI-assisted (Claude); no game data shared.

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.

6 participants