Diagnostics: VICTORY_KEYS can hold a key longer than 0.2 s #2203

Open
fiestorra wants to merge 2 commits from upstream-pr/2205 into main
fiestorra commented 2026-11-25 07:58:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-25T07:58:04Z.


VICTORY_KEYS could not hold a key for longer than 0.2 s, and that ambiguity cost me a morning

The scripted keys held every key for 0.2 s, hardcoded:

.filter(|&&(at, _)| (at..at + Duration::from_millis(200)).contains(&now))

That is fine for the screens it was written for — it advanced the conditions page and the notices — but it makes one particular failure impossible to tell apart from another: a screen that samples its input slower than the hold behaves exactly like a screen that takes no input. I spent this morning concluding the second about the setup wizard, and it was wrong: the operator advanced that same screen by hand with the keyboard.

An entry may now say how long to hold it:

VICTORY_KEYS=60:Enter:0.8,66:Down,70:Up:0.5

at:key[:hold], the hold in seconds, 0.2 s when omitted, so every existing string behaves exactly as it did. The parse moved into parse_scripted — a function of its own, testable without touching the environment — and the test pins three things: the default, an explicit hold, and a hold that does not parse, which falls back to the default rather than dropping the key, because a run that loses one press is worse than one that presses slightly wrong.

cargo test -p victory-hle --features diagnostics --lib → 143 passed, with the one failure main also has in a session with no desktop; clippy with and without --all-features clean under -D warnings; rustfmt --check shows the same four hunks the file already had on main.

What this does not do is prove that a longer hold gets past the wizard. That is the next run, and it will say either way — the point of the change is that the answer becomes a measurement instead of a guess. If the wizard still ignores a 0.8 s hold, then it genuinely does not take keyboard input, and the next place to look is the pad it might be waiting for, not the length of the press.

No game data is involved: an environment variable and a test.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5487428812 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-25T07:58:04Z. --- **`VICTORY_KEYS` could not hold a key for longer than 0.2 s, and that ambiguity cost me a morning** The scripted keys held every key for 0.2 s, hardcoded: ```rust .filter(|&&(at, _)| (at..at + Duration::from_millis(200)).contains(&now)) ``` That is fine for the screens it was written for — it advanced the conditions page and the notices — but it makes one particular failure impossible to tell apart from another: **a screen that samples its input slower than the hold** behaves exactly like **a screen that takes no input**. I spent this morning concluding the second about the setup wizard, and it was wrong: the operator advanced that same screen by hand with the keyboard. An entry may now say how long to hold it: ``` VICTORY_KEYS=60:Enter:0.8,66:Down,70:Up:0.5 ``` `at:key[:hold]`, the hold in seconds, **0.2 s when omitted**, so every existing string behaves exactly as it did. The parse moved into `parse_scripted` — a function of its own, testable without touching the environment — and the test pins three things: the default, an explicit hold, and **a hold that does not parse**, which falls back to the default rather than dropping the key, because a run that loses one press is worse than one that presses slightly wrong. `cargo test -p victory-hle --features diagnostics --lib` → 143 passed, with the one failure `main` also has in a session with no desktop; clippy with and without `--all-features` clean under `-D warnings`; `rustfmt --check` shows the same four hunks the file already had on `main`. What this does **not** do is prove that a longer hold gets past the wizard. That is the next run, and it will say either way — the point of the change is that the answer becomes a measurement instead of a guess. If the wizard still ignores a 0.8 s hold, then it genuinely does not take keyboard input, and the next place to look is the pad it might be waiting for, not the length of the press. No game data is involved: an environment variable and a test. Written with an AI assistant.
catminou4 commented 2026-11-25 08:03:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:03:10Z.

Review: COMMENTED


Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.

VICTORY_KEYS can hold a key longer than 0.2s — input-timing fix for diagnostics; relates to #2114's stand-in pad.

<!-- greyfinch-sync:Marvisak/VIctory:review:6053837312 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205#pullrequestreview-6053837312). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T08:03:10Z. **Review:** COMMENTED --- Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff. VICTORY_KEYS can hold a key longer than 0.2s — input-timing fix for diagnostics; relates to #2114's stand-in pad.
Dathinel commented 2026-11-25 09:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dathinel on 2026-11-25T08:09:34Z.


Windows validation on c26291a with diagnostics enabled. All 9 GameInput unit tests passed. I also ran a local probe using the production scripted-key source, a synthetic connected pad holding B in slot 1, and the GameInput current-reading interface. Each row ran in a fresh process.

Revision VICTORY_KEYS At 0 ms At 350 ms At 1000 ms
Parent 940d32f 0:Enter A+B B B
Parent 940d32f 0:Enter:0.8 B stopped at first mismatch —
PR c26291a 0:Enter:0.8 A+B A+B B

The extended hold reached the consumer past the old 200 ms default, then released while preserving B. Synthetic input only. AI-assisted validation.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156677534 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205#issuecomment-7156677534). Originally posted by [Dathinel](https://github.com/Dathinel) on 2026-11-25T08:09:34Z. --- Windows validation on c26291a with diagnostics enabled. All 9 GameInput unit tests passed. I also ran a local probe using the production scripted-key source, a synthetic connected pad holding B in slot 1, and the GameInput current-reading interface. Each row ran in a fresh process. | Revision | VICTORY_KEYS | At 0 ms | At 350 ms | At 1000 ms | |---|---|---|---|---| | Parent 940d32f | 0:Enter | A+B | B | B | | Parent 940d32f | 0:Enter:0.8 | B | stopped at first mismatch | — | | PR c26291a | 0:Enter:0.8 | A+B | A+B | B | The extended hold reached the consumer past the old 200 ms default, then released while preserving B. Synthetic input only. AI-assisted validation.
Marvisak commented 2026-11-25 14:07:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:29:07Z.


Automated triage for the maintainers.

This lets the diagnostics-only VICTORY_KEYS script give each key an optional hold (at:key[:hold], still 0.2 s by default). It moves the parser out of host::scripted into a testable parse_scripted in gameinput.rs, with a unit test covering the default, a bad hold and malformed entries. I checked that the key table and the default behaviour match main and that the change is only compiled under test/diagnostics. CI passes.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163844237 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205#issuecomment-7163844237). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T13:29:07Z. --- <!-- victory-triage v1 head=c26291a329d5a3ac588bb8f1680ec1aa1a5f322f verdict=merge-candidate at=2026-11-25T13:29:20Z --> Automated triage for the maintainers. This lets the diagnostics-only `VICTORY_KEYS` script give each key an optional hold (`at:key[:hold]`, still 0.2 s by default). It moves the parser out of `host::scripted` into a testable `parse_scripted` in `gameinput.rs`, with a unit test covering the default, a bad hold and malformed entries. I checked that the key table and the default behaviour match `main` and that the change is only compiled under `test`/`diagnostics`. CI passes. --- _Generated by [Claude Code](https://claude.ai/code)_
fuzeofficlal commented 2026-11-26 01:04:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T00:56:26Z.


Code review and Windows 11 verification at head c26291a329d5 merged cleanly onto main (63bcca43c6a0):

  • Code review (crates/victory-hle/src/modules/gameinput.rs:276-308, 1322-1331):
    • Properly gated behind #[cfg(any(test, feature = "diagnostics"))] / #[cfg(feature = "diagnostics")] (zero default-build impact). parse_scripted drops malformed/negative/NaN/Inf at entries cleanly, falls back to DEFAULT_HOLD = 200 ms on omitted or invalid hold, and treats hold == 0.0 as an empty range.
    • Minor non-blocking note (gameinput.rs:1331): (at..at + hold).contains(&now) can panic with Duration addition overflow if someone passes two very large values in VICTORY_KEYS (e.g. 1e19:Enter:1e19); using at.saturating_add(hold) avoids that cleanly.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy --locked -p victory-hle --tests -- -D warnings (default + --features diagnostics): 0 warnings
    • cargo test --locked -p victory-hle -- gameinput: 11/11 passed on both default and --features diagnostics.

LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179266038 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205#issuecomment-7179266038). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T00:56:26Z. --- Code review and Windows 11 verification at head `c26291a329d5` merged cleanly onto `main` (`63bcca43c6a0`): - **Code review (`crates/victory-hle/src/modules/gameinput.rs:276-308, 1322-1331`)**: - Properly gated behind `#[cfg(any(test, feature = "diagnostics"))]` / `#[cfg(feature = "diagnostics")]` (zero default-build impact). `parse_scripted` drops malformed/negative/NaN/Inf `at` entries cleanly, falls back to `DEFAULT_HOLD = 200 ms` on omitted or invalid `hold`, and treats `hold == 0.0` as an empty range. - Minor non-blocking note (`gameinput.rs:1331`): `(at..at + hold).contains(&now)` can panic with `Duration` addition overflow if someone passes two very large values in `VICTORY_KEYS` (e.g. `1e19:Enter:1e19`); using `at.saturating_add(hold)` avoids that cleanly. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy --locked -p victory-hle --tests -- -D warnings` (default + `--features diagnostics`): 0 warnings - `cargo test --locked -p victory-hle -- gameinput`: **11/11 passed** on both default and `--features diagnostics`. LGTM.
UwUCammie commented 2026-11-26 02:07:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by UwUCammie on 2026-11-26T01:23:17Z.


Tried the hold syntax on the fxceless fork. With 50:Enter:4.4 the first room was visible by 80 seconds on the RX 7900 XT. Ordinary taps still showed the cutscene at 100 seconds in the control run. I kept your commit credit in the port.

One edge case I found while adding the boundary test: checking now.checked_sub(at) against hold also handles a valid start and hold whose sum is outside Duration’s range. Port and tests

<!-- greyfinch-sync:Marvisak/VIctory:comment:7179722675 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205#issuecomment-7179722675). Originally posted by [UwUCammie](https://github.com/UwUCammie) on 2026-11-26T01:23:17Z. --- Tried the hold syntax on the fxceless fork. With `50:Enter:4.4` the first room was visible by 80 seconds on the RX 7900 XT. Ordinary taps still showed the cutscene at 100 seconds in the control run. I kept your commit credit in the port. One edge case I found while adding the boundary test: checking `now.checked_sub(at)` against `hold` also handles a valid start and hold whose sum is outside `Duration`’s range. [Port and tests](https://github.com/fxceless/victory-fork/pull/1236)
fiestorra commented 2026-11-26 13:04:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-26T12:37:32Z.


The window is what gets tested now, and the two edge cases are fixed

Head 6c9548f0, rebased onto 63bcca43 first.

  • The overflow: the window no longer adds. held(keys, now) compares now.checked_sub(at) with the hold, so a pair whose sum leaves Duration's range cannot panic — and at in the future is simply not held. That is the shape @UwUCammie suggested, taken rather than my own saturating_add.
  • A hold of zero falls back to the 0.2 s default instead of producing an empty window and silently dropping the key, which is the failure this switch exists to rule out.
  • The window, not just the parse, is tested: a_scripted_key_is_held_exactly_its_window asserts down at +0.35 s and up at +0.8 s for a 0.8 s hold, the zero-hold default at +0.1 s and released at +0.25 s, and no panic on a 1e19 hold. scripted() now just calls held, so the tested function is the one the runtime uses.
  • README: the VICTORY_KEYS row shows 30:Enter,35:X:0.8 and says the time after the second colon is the hold, 0.2 s when omitted.

Measured here: cargo test -p victory-hle --features diagnostics --lib → 153 passed, 1 failed; the failure is lifecycle::tests::showing_a_title_window_shows_its_stand_in, which fails the same way on a clean 63bcca43 in this desktop-less session. cargo clippy -p victory-hle --features diagnostics --all-targets -- -D warnings is clean.

Not verified: a run of the title with a long hold — this machine's session 0 cannot present, so the click that motivated the change has not been re-shot through the menu.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7192245396 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205#issuecomment-7192245396). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-26T12:37:32Z. --- **The window is what gets tested now, and the two edge cases are fixed** Head `6c9548f0`, rebased onto `63bcca43` first. - **The overflow**: the window no longer adds. `held(keys, now)` compares `now.checked_sub(at)` with the hold, so a pair whose sum leaves `Duration`'s range cannot panic — and `at` in the future is simply not held. That is the shape @UwUCammie suggested, taken rather than my own `saturating_add`. - **A hold of zero** falls back to the 0.2 s default instead of producing an empty window and silently dropping the key, which is the failure this switch exists to rule out. - **The window, not just the parse**, is tested: `a_scripted_key_is_held_exactly_its_window` asserts down at +0.35 s and up at +0.8 s for a 0.8 s hold, the zero-hold default at +0.1 s and released at +0.25 s, and no panic on a `1e19` hold. `scripted()` now just calls `held`, so the tested function is the one the runtime uses. - **README**: the `VICTORY_KEYS` row shows `30:Enter,35:X:0.8` and says the time after the second colon is the hold, 0.2 s when omitted. Measured here: `cargo test -p victory-hle --features diagnostics --lib` → 153 passed, 1 failed; the failure is `lifecycle::tests::showing_a_title_window_shows_its_stand_in`, which fails the same way on a clean `63bcca43` in this desktop-less session. `cargo clippy -p victory-hle --features diagnostics --all-targets -- -D warnings` is clean. Not verified: a run of the title with a long hold — this machine's session 0 cannot present, so the click that motivated the change has not been re-shot through the menu. Written with an AI assistant.
fuzeofficlal commented 2026-11-27 02:58:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:58:07Z.

Review: APPROVED


Reviewed at 6c9548f06f6ad9acbf9e1b4d34b0245090d540ad — APPROVE.

Verification

  • cargo xtask policy (191 files ok) and all four cargo clippy -p victory-hle targets (--lib, --tests, --all-targets, --all-features with -D warnings) passed cleanly with zero dead_code warnings in both default and diagnostics builds.
  • Verified backward compatibility for at:key (default 0.2 s), boundary handling of Duration::try_from_secs_f64 (negative, NaN, Inf, non-numeric, and overflowing values), zero-hold fallback to 0.2 s, and overflow-safe release checks via now.checked_sub(at) in held().
  • Passed cargo test -p victory-hle --lib modules::gameinput (12/12) under both default features and --features diagnostics.

Non-blocking notes

  • Extra colon-separated segments (e.g., 30:Enter:0.8:ms) are ignored after the third field (crates/victory-hle/src/modules/gameinput.rs:135); checking parts.next().is_some() would reject malformed entries.
  • README.md:200 could note that bare seconds are expected and invalid/zero holds fall back to 0.2 s (while host polling at 8 ms limits sub-poll hold durations).
  • Scripted, parse_scripted, and held (gameinput.rs:124) could use #[cfg(any(test, all(windows, feature = "diagnostics")))] to avoid unused warnings on non-Windows diagnostics builds, and plain backticks for `scripted` (gameinput.rs:127) avoid an unresolved intra-doc link.
  • gameinput.rs:1961 has extra trailing blank lines flagged by rustfmt --check, and a_scripted_key_is_held_exactly_its_window (gameinput.rs:1825) would hit an actual at + hold overflow case with both at and hold set to 1e19.
<!-- greyfinch-sync:Marvisak/VIctory:review:6082891360 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205#pullrequestreview-6082891360). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T02:58:07Z. **Review:** APPROVED --- Reviewed at `6c9548f06f6ad9acbf9e1b4d34b0245090d540ad` — **APPROVE**. ### Verification - `cargo xtask policy` (`191 files ok`) and all four `cargo clippy -p victory-hle` targets (`--lib`, `--tests`, `--all-targets`, `--all-features` with `-D warnings`) passed cleanly with zero `dead_code` warnings in both default and `diagnostics` builds. - Verified backward compatibility for `at:key` (default `0.2 s`), boundary handling of `Duration::try_from_secs_f64` (negative, `NaN`, `Inf`, non-numeric, and overflowing values), zero-hold fallback to `0.2 s`, and overflow-safe release checks via `now.checked_sub(at)` in `held()`. - Passed `cargo test -p victory-hle --lib modules::gameinput` (12/12) under both default features and `--features diagnostics`. ### Non-blocking notes - Extra colon-separated segments (e.g., `30:Enter:0.8:ms`) are ignored after the third field (`crates/victory-hle/src/modules/gameinput.rs:135`); checking `parts.next().is_some()` would reject malformed entries. - `README.md:200` could note that bare seconds are expected and invalid/zero holds fall back to `0.2 s` (while host polling at `8 ms` limits sub-poll hold durations). - `Scripted`, `parse_scripted`, and `held` (`gameinput.rs:124`) could use `#[cfg(any(test, all(windows, feature = "diagnostics")))]` to avoid unused warnings on non-Windows `diagnostics` builds, and plain backticks for `` `scripted` `` (`gameinput.rs:127`) avoid an unresolved intra-doc link. - `gameinput.rs:1961` has extra trailing blank lines flagged by `rustfmt --check`, and `a_scripted_key_is_held_exactly_its_window` (`gameinput.rs:1825`) would hit an actual `at + hold` overflow case with both `at` and `hold` set to `1e19`.
fiestorra commented 2026-11-27 07:49:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fiestorra on 2026-11-27T07:49:55Z.


Thanks — that is the approval I needed. For the record, the object-ordering case you asked about on the way in is the one the head actually implements: held(keys, now) compares now.checked_sub(at) with the hold, a zero hold falls back to the 0.2 s default, and a_scripted_key_is_held_exactly_its_window pins down-at-+0.35 s and up-at-+0.8 s for a 0.8 s hold. Nothing else changed after 6c9548f0.

Written with an AI assistant.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7212861918 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2205#issuecomment-7212861918). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-27T07:49:55Z. --- Thanks — that is the approval I needed. For the record, the object-ordering case you asked about on the way in is the one the head actually implements: `held(keys, now)` compares `now.checked_sub(at)` with the hold, a zero hold falls back to the 0.2 s default, and `a_scripted_key_is_held_exactly_its_window` pins down-at-+0.35 s and up-at-+0.8 s for a 0.8 s hold. Nothing else changed after `6c9548f0`. Written with an AI assistant.
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/2205:upstream-pr/2205'
git switch 'upstream-pr/2205'

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