HLE: timed GameInput recording and replay (VICTORY_INPUT_RECORD / VICTORY_INPUT_REPLAY) #3833

Open
CaullenOmdahl wants to merge 1 commit from upstream-pr/3833 into main
CaullenOmdahl commented 2026-11-29 12:16:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by CaullenOmdahl on 2026-11-29T12:16:36Z.


Summary

Adds opt-in, zero-overhead-when-unset input recording and timed replay around GameInput's Source trait in crates/victory-hle/src/modules/gameinput.rs, enabling repeatable multi-scene playthrough and traversal benchmarks without external OS key injection or window-focus requirements.

  • VICTORY_INPUT_RECORD=<path>: Wraps the host Source in RecordingSource, writing delta-encoded JSONL records (pad, keys, and F9 rising-edge bookmark markers stripped from title keys) and flushing each line immediately so process exit never loses trailing events.
  • VICTORY_INPUT_REPLAY=<path>: Replaces the host Source with ReplayingSource:
    • VICTORY_INPUT_START_MS, VICTORY_INPUT_END_MS, and VICTORY_INPUT_BOOKMARK select and rebase a time slice while carrying forward prior pad/key state at t=0.
    • VICTORY_INPUT_REPLAY_GATE=<path> holds the playback clock at t=0 until the gate file appears (so variable boot/load durations do not desync gameplay slices), while keeping recorded pad slots connected to avoid hotplug churn.
    • VICTORY_INPUT_MENU_SKIP=1 pulses A (or Enter when no pad is connected) every 2 s while gated; VICTORY_INPUT_LOOP=1 loops the slice.
    • Maps /... paths to Z:\... automatically when running under Wine (wine_get_version), leaving native Windows paths untouched.

Ported from CaullenOmdahl/Boxon.

Validation

  • cargo xtask policy
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings
  • cargo clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings
  • 12/12 modules::gameinput::tests passing (record_and_replay_round_trip_suppresses_deltas_and_strips_f9, replay_gate_holds_clock_at_zero_and_pulses_menu_skip, replay_sorts_out_of_order_records_handles_unicode_escapes_and_rejects_bad_lines, plus all existing GameInput tests).
<!-- greyfinch-sync:Marvisak/VIctory:issue:5550614818 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3833). Originally posted by [CaullenOmdahl](https://github.com/CaullenOmdahl) on 2026-11-29T12:16:36Z. --- ## Summary Adds opt-in, zero-overhead-when-unset input recording and timed replay around `GameInput`'s `Source` trait in `crates/victory-hle/src/modules/gameinput.rs`, enabling repeatable multi-scene playthrough and traversal benchmarks without external OS key injection or window-focus requirements. - **`VICTORY_INPUT_RECORD=<path>`:** Wraps the host `Source` in `RecordingSource`, writing delta-encoded JSONL records (`pad`, `keys`, and `F9` rising-edge `bookmark` markers stripped from title keys) and flushing each line immediately so process exit never loses trailing events. - **`VICTORY_INPUT_REPLAY=<path>`:** Replaces the host `Source` with `ReplayingSource`: - `VICTORY_INPUT_START_MS`, `VICTORY_INPUT_END_MS`, and `VICTORY_INPUT_BOOKMARK` select and rebase a time slice while carrying forward prior pad/key state at `t=0`. - `VICTORY_INPUT_REPLAY_GATE=<path>` holds the playback clock at `t=0` until the gate file appears (so variable boot/load durations do not desync gameplay slices), while keeping recorded pad slots connected to avoid hotplug churn. - `VICTORY_INPUT_MENU_SKIP=1` pulses `A` (or `Enter` when no pad is connected) every 2 s while gated; `VICTORY_INPUT_LOOP=1` loops the slice. - Maps `/...` paths to `Z:\...` automatically when running under Wine (`wine_get_version`), leaving native Windows paths untouched. Ported from [`CaullenOmdahl/Boxon`](https://github.com/CaullenOmdahl/Boxon). ## Validation - `cargo xtask policy` - `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings` - `cargo clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings` - `12/12` `modules::gameinput::tests` passing (`record_and_replay_round_trip_suppresses_deltas_and_strips_f9`, `replay_gate_holds_clock_at_zero_and_pulses_menu_skip`, `replay_sorts_out_of_order_records_handles_unicode_escapes_and_rejects_bad_lines`, plus all existing `GameInput` tests).
passerbyyhx commented 2026-12-01 14:04:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-12-01T14:04:35Z.


Tested the JSONL replay source at b677dfac with a nonzero clock origin and a trace containing a pad update, held key, bookmark, disconnect, key release and a subsequent key. A bookmark start at 30 ms and explicit starts at 20/34 ms with the same bookmark each inherited the preexisting pad/key state. All three reported the disconnect at 35 ms, included the key release exactly at the 40 ms end, and excluded the key at 41 ms (18 observations).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7313653144 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3833#issuecomment-7313653144). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-12-01T14:04:35Z. --- Tested the JSONL replay source at b677dfac with a nonzero clock origin and a trace containing a pad update, held key, bookmark, disconnect, key release and a subsequent key. A bookmark start at 30 ms and explicit starts at 20/34 ms with the same bookmark each inherited the preexisting pad/key state. All three reported the disconnect at 35 ms, included the key release exactly at the 40 ms end, and excluded the key at 41 ms (18 observations).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3833:upstream-pr/3833'
git switch 'upstream-pr/3833'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3833'
git switch 'upstream-pr/3833'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3833'
git switch 'upstream-pr/3833'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3833'
git switch 'main'
git merge --squash 'upstream-pr/3833'
git switch 'main'
git merge --ff-only 'upstream-pr/3833'
git switch 'main'
git merge 'upstream-pr/3833'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3833
No description provided.