Report overlapping VICTORY_KEYS holds as one active key #2716

Open
VlREX wants to merge 2 commits from upstream-pr/2718 into main
VlREX commented 2026-11-25 18:46:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by VlREX on 2026-11-25T18:46:49Z.


With VICTORY_KEYS=0:W,0.05:A,0.1:W the diagnostics keyboard reported W, A, W at 100 ms. Report each active virtual key once, releasing it only after its last hold expires. A deterministic regression test exercises overlapping intervals, another simultaneously held key, and the release boundary. It failed before the fix and passed afterward, alongside seven existing fake-host input tests in an isolated Windows GNU run. No game assets or physical keyboard required.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5497173460 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2718). Originally posted by [VlREX](https://github.com/VlREX) on 2026-11-25T18:46:49Z. --- With VICTORY_KEYS=0:W,0.05:A,0.1:W the diagnostics keyboard reported W, A, W at 100 ms. Report each active virtual key once, releasing it only after its last hold expires. A deterministic regression test exercises overlapping intervals, another simultaneously held key, and the release boundary. It failed before the fix and passed afterward, alongside seven existing fake-host input tests in an isolated Windows GNU run. No game assets or physical keyboard required.
DrDarkDK commented 2026-11-25 19:06:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:50:17Z.


The .len() check at 249 ms misses an order change in this fixture. active_scripted_keys returns WA at 199 ms and AW at 200 ms. The first W interval expires, but the second still holds W, so neither key was released or pressed at that boundary.

Could the test assert WA at 249 ms? The earlier #2499 covers the same overlap and preserves the order by merging holds before polling.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171469522 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2718#issuecomment-7171469522). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T18:50:17Z. --- The `.len()` check at 249 ms misses an order change in this fixture. `active_scripted_keys` returns `WA` at 199 ms and `AW` at 200 ms. The first W interval expires, but the second still holds W, so neither key was released or pressed at that boundary. Could the test assert `WA` at 249 ms? The earlier #2499 covers the same overlap and preserves the order by merging holds before polling. *AI-assisted with Codex.*
kotekompotek commented 2026-11-25 19:06:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:51:45Z.


Correct - dedupe keeps first-occurrence order and a key survives until its last overlapping hold expires; checked_sub also avoids the subtraction-underflow the old window check would hit before t=0. Boundary tests at exactly 200/250ms pin the half-open interval.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171504452 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2718#issuecomment-7171504452). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:51:45Z. --- Correct - dedupe keeps first-occurrence order and a key survives until its last overlapping hold expires; checked_sub also avoids the subtraction-underflow the old window check would hit before t=0. Boundary tests at exactly 200/250ms pin the half-open interval.
Marvisak commented 2026-11-26 00:03:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:18:58Z.


Automated triage for the maintainers.

This PR merges overlapping holds of the same key in the diagnostics-only VICTORY_KEYS path (scripted() in crates/victory-hle/src/modules/gameinput.rs, via scheduled_key_holds / active_scripted_keys). The merge logic reads correctly. However, #2499 made the same change and was closed on review today. Duplicates only appear when a script schedules the same key twice within 0.2 s, and the title ORs key states into its table, so a repeated key changes nothing it sees. This PR also rewrites the same scripted() as the open #2205 (per-entry hold lengths) and would need to be redone on top of it. To change this, show a case where the duplicate or the order change alters what the title does.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177398155 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2718#issuecomment-7177398155). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:18:58Z. --- <!-- victory-triage v1 head=ee868cd01b7be2518309458013bbdc743f984bcd verdict=proposed-close at=2026-11-25T23:18:48Z --> Automated triage for the maintainers. This PR merges overlapping holds of the same key in the diagnostics-only `VICTORY_KEYS` path (`scripted()` in `crates/victory-hle/src/modules/gameinput.rs`, via `scheduled_key_holds` / `active_scripted_keys`). The merge logic reads correctly. However, #2499 made the same change and was closed on review today. Duplicates only appear when a script schedules the same key twice within 0.2 s, and the title ORs key states into its table, so a repeated key changes nothing it sees. This PR also rewrites the same `scripted()` as the open #2205 (per-entry hold lengths) and would need to be redone on top of it. To change this, show a case where the duplicate or the order change alters what the title does. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
cloph-dsp commented 2026-11-27 00:34:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T00:34:34Z.


Independent local verification (Windows 11, Rust 1.100.0/MSVC, head ee868cd, no game data):

  • cargo test --locked -p victory-hle --lib -- scripted_ → 4 passed, 0 failed, 145 filtered, exit 0. This includes the three new overlapping-VICTORY_KEYS hold tests (overlapping_scripted_presses_hold_one_key_until_both_end, scripted_holds_sort_stably_merge_touching_and_keep_gaps, scripted_hold_at_max_duration_does_not_overflow).
  • Negative control: the new test names are absent from origin/main (git grep → 0 hits), so they are genuinely added by this PR.
  • git diff --check <merge-base 13f91ca> HEAD → clean. (Checking against current origin/main flags an unrelated blank line at EOF in crates/victory-formats/src/xma/tables.rs, not part of this PR.)
  • Worktree-local CARGO_TARGET_DIR used throughout.

The named scenario was exercised through the synthetic scheduled_key_holds / active_scripted_keys inputs only; no real title, environment variable beyond the test fixtures, or GPU was involved. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only HLE arithmetic). No game data used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7206574852 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2718#issuecomment-7206574852). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-27T00:34:34Z. --- Independent local verification (Windows 11, Rust 1.100.0/MSVC, head `ee868cd`, no game data): - `cargo test --locked -p victory-hle --lib -- scripted_` → **4 passed, 0 failed, 145 filtered**, exit 0. This includes the three new overlapping-VICTORY_KEYS hold tests (`overlapping_scripted_presses_hold_one_key_until_both_end`, `scripted_holds_sort_stably_merge_touching_and_keep_gaps`, `scripted_hold_at_max_duration_does_not_overflow`). - Negative control: the new test names are absent from `origin/main` (`git grep` → 0 hits), so they are genuinely added by this PR. - `git diff --check <merge-base 13f91ca> HEAD` → clean. (Checking against current `origin/main` flags an unrelated blank line at EOF in `crates/victory-formats/src/xma/tables.rs`, not part of this PR.) - Worktree-local `CARGO_TARGET_DIR` used throughout. The named scenario was exercised through the synthetic `scheduled_key_holds` / `active_scripted_keys` inputs only; no real title, environment variable beyond the test fixtures, or GPU was involved. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only HLE arithmetic). No game data used.
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/2718:upstream-pr/2718'
git switch 'upstream-pr/2718'

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