Skip to content

Report overlapping VICTORY_KEYS holds as one active key - #2718

Open
VlREX wants to merge 2 commits into
Marvisak:mainfrom
VlREX:fix/duplicate-scripted-keys
Open

VlREX wants to merge 2 commits into
Marvisak:mainfrom
VlREX:fix/duplicate-scripted-keys

Conversation

@VlREX

@VlREX VlREX commented Nov 25, 2026

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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.

Merge continuous holds during schedule initialization, including touching intervals. Preserve chronological order with stable ties and avoid Duration overflow. Addresses DrDarkDK's review on Marvisak#2718; overlaps with the approach in Marvisak#2499.

Copy link
Copy Markdown
Owner

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

@cloph-dsp

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants