hle: VICTORY_KEYS entries can hold a key, so a scripted run can walk #3392

Open
pes7 wants to merge 3 commits from upstream-pr/3392 into main
pes7 commented 2026-11-26 21:40:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-26T21:40:05Z.


VICTORY_KEYS=<seconds>:<key> (diagnostics builds) holds each key for 200 ms: enough for a menu press, not for walking. An entry now takes an optional third field, the hold in milliseconds:

VICTORY_KEYS=10:Enter:300,20:Enter:300,200:W:6000
  • Without the third field the hold stays 200 ms, so existing schedules behave exactly as before.
  • Both the keyboard device and the stand-in pad see the keys (Enter is the pad's A, W the left stick up), with or without window focus. A run can be driven while the title's window stays in the background, and nothing steals focus from whoever uses the machine.
  • In use for a while on our prologue runs: with Enter presses and a held W, the title reached the world with no window activation (1 862 draws/frame at 153 s).

Split out of #2936 (the review there asked for its diagnostics as separate PRs). gameinput.rs and the README's switch table only, +22/-7.

Checked: cargo clippy --workspace --all-targets -D warnings (also --all-features, which builds the diagnostics path) clean; cargo test -p victory-hle --all-features 155 passed.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:5517505044 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3392). Originally posted by [pes7](https://github.com/pes7) on 2026-11-26T21:40:05Z. --- `VICTORY_KEYS=<seconds>:<key>` (diagnostics builds) holds each key for 200 ms: enough for a menu press, not for walking. An entry now takes an optional third field, the hold in milliseconds: ``` VICTORY_KEYS=10:Enter:300,20:Enter:300,200:W:6000 ``` - Without the third field the hold stays 200 ms, so existing schedules behave exactly as before. - Both the keyboard device and the stand-in pad see the keys (`Enter` is the pad's A, `W` the left stick up), with or without window focus. A run can be driven while the title's window stays in the background, and nothing steals focus from whoever uses the machine. - In use for a while on our prologue runs: with `Enter` presses and a held `W`, the title reached the world with no window activation (1 862 draws/frame at 153 s). Split out of #2936 (the review there asked for its diagnostics as separate PRs). `gameinput.rs` and the README's switch table only, +22/-7. Checked: `cargo clippy --workspace --all-targets -D warnings` (also `--all-features`, which builds the diagnostics path) clean; `cargo test -p victory-hle --all-features` 155 passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Dukestar69 commented 2026-11-26 21:47:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T21:47:54Z.

Review: APPROVED


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

  • Allowing VICTORY_KEYS entries to hold a key for a duration cleanly extends scripted input testing without affecting existing entries.
  • cargo test -p victory-hle --lib modules::gameinput:: -- --test-threads=1: 10 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6080839216 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3392#pullrequestreview-6080839216). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T21:47:54Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Allowing `VICTORY_KEYS` entries to hold a key for a duration cleanly extends scripted input testing without affecting existing entries. - `cargo test -p victory-hle --lib modules::gameinput:: -- --test-threads=1`: 10 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 22:08:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T22:08:18Z.

Review: APPROVED


Verified on 57233443:

  • cargo xtask policy: 191 files ok.
  • rustfmt --edition 2024 --check: clean on the modified hunks in crates/victory-hle/src/modules/gameinput.rs.
  • cargo clippy --locked -p victory-hle --all-targets -- -D warnings (default, --features diagnostics, and --all-features): clean.
  • cargo test --locked -p victory-hle --lib modules::gameinput:: (default and --features diagnostics): 10 passed, 0 failed.

Clean, backward-compatible extension of VICTORY_KEYS (<seconds>:<key> continues defaulting to 200 ms) with zero overhead when diagnostics is off.

Two small non-blocking suggestions if you touch this again:

  • Using at.saturating_add(hold) instead of at + hold (crates/victory-hle/src/modules/gameinput.rs:1322) avoids a Duration overflow panic if a huge timestamp + hold duration is ever passed in VICTORY_KEYS.
  • Adding a small unit test for the parser (<seconds>:<key> default vs <seconds>:<key>:<hold_ms>, malformed hold fields, and [at, at + hold) timing) would cover the new syntax directly.

LGTM!

<!-- greyfinch-sync:Marvisak/VIctory:review:6080999363 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3392#pullrequestreview-6080999363). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T22:08:18Z. **Review:** APPROVED --- Verified on `57233443`: - `cargo xtask policy`: `191 files ok`. - `rustfmt --edition 2024 --check`: clean on the modified hunks in `crates/victory-hle/src/modules/gameinput.rs`. - `cargo clippy --locked -p victory-hle --all-targets -- -D warnings` (default, `--features diagnostics`, and `--all-features`): clean. - `cargo test --locked -p victory-hle --lib modules::gameinput::` (default and `--features diagnostics`): **10 passed, 0 failed**. Clean, backward-compatible extension of `VICTORY_KEYS` (`<seconds>:<key>` continues defaulting to 200 ms) with zero overhead when `diagnostics` is off. Two small non-blocking suggestions if you touch this again: - Using `at.saturating_add(hold)` instead of `at + hold` (`crates/victory-hle/src/modules/gameinput.rs:1322`) avoids a `Duration` overflow panic if a huge timestamp + hold duration is ever passed in `VICTORY_KEYS`. - Adding a small unit test for the parser (`<seconds>:<key>` default vs `<seconds>:<key>:<hold_ms>`, malformed hold fields, and `[at, at + hold)` timing) would cover the new syntax directly. LGTM!
passerbyyhx commented 2026-11-26 22:32:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-26T22:32:58Z.


Windows controlled-clock check at 5723344 against 63bcca4. Both revisions passed all 12 focused GameInput tests, including synthetic input cases. Across 19 exact timestamps, omitted hold stayed at 200 ms, explicit 600 ms and 100 ms holds used inclusive starts and exclusive ends, and overlapping Enter/W and W/Right were delivered together. Enter mapped to pad A and W to left stick Y=1.0.

One edge case in the new parser: 18446744073709549568:W:18446744073709551615 parses successfully, then the first query at elapsed zero panics at at + hold with overflow when adding durations. The parent skips that three-field entry. now.checked_sub(at).is_some_and(|age| age < hold) would implement the same half-open check without adding the durations.

Synthetic fixture

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204777383 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3392#issuecomment-7204777383). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-26T22:32:58Z. --- Windows controlled-clock check at `5723344` against `63bcca4`. Both revisions passed all 12 focused GameInput tests, including synthetic input cases. Across 19 exact timestamps, omitted hold stayed at 200 ms, explicit 600 ms and 100 ms holds used inclusive starts and exclusive ends, and overlapping Enter/W and W/Right were delivered together. Enter mapped to pad A and W to left stick Y=1.0. One edge case in the new parser: `18446744073709549568:W:18446744073709551615` parses successfully, then the first query at elapsed zero panics at `at + hold` with `overflow when adding durations`. The parent skips that three-field entry. `now.checked_sub(at).is_some_and(|age| age < hold)` would implement the same half-open check without adding the durations. [Synthetic fixture](https://github.com/passerbyyhx/VIctory/commit/0b8e9bb4cb1ef88774aedf429752ba3aec48d1ba) AI-assisted with Codex.
Jackster commented 2026-11-26 22:34:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:34:10Z.


Windows 11, 63bcca4 + this PR, diagnostics build:

  • cargo test -p victory-hle --features diagnostics gameinput::: 10 passed / 0 failed.
  • cargo clippy -p victory-hle --features diagnostics --all-targets -- -D warnings: clean.

No new test: the change is in the VICTORY_KEYS parser (<seconds>:<key>[:<hold ms>]) and its doc comment, so this is compile/regression coverage only. I did not exercise a scripted run with an explicit hold — that needs the title. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204794894 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3392#issuecomment-7204794894). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:34:10Z. --- Windows 11, `63bcca4` + this PR, diagnostics build: - `cargo test -p victory-hle --features diagnostics gameinput::`: 10 passed / 0 failed. - `cargo clippy -p victory-hle --features diagnostics --all-targets -- -D warnings`: clean. No new test: the change is in the `VICTORY_KEYS` parser (`<seconds>:<key>[:<hold ms>]`) and its doc comment, so this is compile/regression coverage only. I did not exercise a scripted run with an explicit hold — that needs the title. Synthetic only. AI-assisted.
passerbyyhx commented 2026-11-27 09:12:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-27T09:12:14Z.


I sent a follow-up against this PR's branch for the unrepresentable end time reported above. It uses elapsed time since the start and retains the half-open interval. The original controlled-clock matrix passed, as did a fresh process reading the schedule through the production diagnostics entry point. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7214400866 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3392#issuecomment-7214400866). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-27T09:12:14Z. --- I sent a [follow-up against this PR's branch](https://github.com/pes7/VIctory/pull/2) for the unrepresentable end time reported above. It uses elapsed time since the start and retains the half-open interval. The original controlled-clock matrix passed, as did a fresh process reading the schedule through the production diagnostics entry point. AI-assisted with Codex.
pes7 commented 2026-11-27 12:44:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pes7 on 2026-11-27T12:44:50Z.


Thanks @passerbyyhx, @Jackster.

Pushed 72d5370:

  • 2ef06ae — @passerbyyhx's fix for the overflow at at + hold (from pes7/VIctory#2, authorship kept): the check is now now.checked_sub(at).is_some_and(|elapsed| elapsed < hold), same half-open interval, with a test near Duration::MAX.
  • 72d5370 — the README row for the optional hold field, which had been left out of the first commit.

Local, Windows 11, on 63bcca4: cargo clippy -p victory-hle --all-targets -- -D warnings clean, and the same with --all-features; cargo test -p victory-hle --features diagnostics 153 passed / 0 failed, including scripted_hold_ends_are_exclusive_even_near_duration_max. No title run for this push (the change is the parser's interval check only).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7218624361 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3392#issuecomment-7218624361). Originally posted by [pes7](https://github.com/pes7) on 2026-11-27T12:44:50Z. --- Thanks @passerbyyhx, @Jackster. Pushed `72d5370`: - `2ef06ae` — @passerbyyhx's fix for the overflow at `at + hold` (from pes7/VIctory#2, authorship kept): the check is now `now.checked_sub(at).is_some_and(|elapsed| elapsed < hold)`, same half-open interval, with a test near `Duration::MAX`. - `72d5370` — the README row for the optional hold field, which had been left out of the first commit. Local, Windows 11, on `63bcca4`: `cargo clippy -p victory-hle --all-targets -- -D warnings` clean, and the same with `--all-features`; `cargo test -p victory-hle --features diagnostics` 153 passed / 0 failed, including `scripted_hold_ends_are_exclusive_even_near_duration_max`. No title run for this push (the change is the parser's interval check only).
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/3392:upstream-pr/3392'
git switch 'upstream-pr/3392'

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/3392'
git switch 'upstream-pr/3392'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3392'
git switch 'upstream-pr/3392'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3392'
git switch 'main'
git merge --squash 'upstream-pr/3392'
git switch 'main'
git merge --ff-only 'upstream-pr/3392'
git switch 'main'
git merge 'upstream-pr/3392'
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!3392
No description provided.