Skip to content

[upstream #1765] GameInput: scripted presses stay down until the title has read them - #367

Open
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1765
Open

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1765

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner

A scripted press (XCL_PRESS_AT / XCL_PRESS_A_AT) is a fixed 200 ms window of host uptime. A title whose reading thread stalls reads its pad less often than that, and the press falls between two reads: in a retail title's run at 4-22 fps (first GetCurrentReading at 16.2 s), the presses at 24, 26, 32 and 120 s were never seen. Now a press stays down until the title has read it: at least 200 ms and two readings, then up for 100 ms and two readings before the next press of the same button, so two presses never merge.

Related: xcl-dev#609 (XCL_PRESS_HOLD=s, a longer fixed hold) fixes the same symptom with a hold the user has to pick. In the run below the reads came up to 12.4 s after a press was due, and the same script has presses 2 s apart (11 and 13 s): a hold long enough for the late ones (≥ 12.4 s) holds the early ones together as one press (xcl-dev#609's test: "presses that overlap are held together"). With the latch neither has to be chosen. If xcl-dev#609 lands first, I will rebase and keep XCL_PRESS_HOLD as the minimum hold. xcl-dev#565 (reading history) and xcl-dev#893 (scripted sticks) touch the same file but not scripted presses; xcl-dev#565 changes the poller thread, so one of the two will need a rebase.

What is in it

  • crates/xcl/src/hle/gameinput.rs, one commit:
    • PressLatch (pure over time and reading): advance(t) moves each press Pending → Down → Up → Done; read(t) is a reading the title is handed and counts it.
    • poll() (what GetCurrentReading and the readings hand the title) counts a reading; the 250 Hz poller only peeks (poll_peek), and a state it pushes to the reading callbacks counts as two readings (scripted_delivered), since a callback is not skipped by a slow reader.
    • Each press logs once when a reading first sees it: GameInput: scripted press 5 (A at 32 s) seen at 42.73 s.
    • Button names in one table (BUTTON_NAMES) for the parser and the log line.
    • Tests: slow_readings_still_see_every_press_and_presses_do_not_merge (reads 500 ms apart), a_press_between_two_distant_readings_is_seen_by_the_next_ones (a 15 s stall), fast_readings_hold_a_press_for_200_ms_and_a_second_press_follows_after_a_gap (1 ms reads). With read() put back to main's 200 ms window, the first two fail on the buttons down.

Tested

  • NVIDIA GeForce RTX 5090 (driver 621.14, 32-lane waves), AMD Ryzen 7 9800X3D, Windows 11 10.0.22631, Rust 1.96.0 MSVC, debug; DXC 1.8.2502 (Windows SDK 10.0.26100).
  • cargo build --workspace && cargo test --workspace -- --test-threads=4:
    • this PR (8cd2f03 on main 85e3826): 878 passed, 0 failed, 42 ignored;
    • main 85e3826: 875 passed, 0 failed, 42 ignored.
    • SKIPPED on both: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • Retail title, 150 s, XCL_PRESS_AT=11:A,13:A,24:A,26:A,32:A,120:A, on our integration branch (main + other PRs) with this commit: all six presses logged as seen, at 11.03, 13.03, 24.03, 26.03, 42.73 and 132.37 s (the title did not read its pad between 32 and 42.7 s, nor between 120 and 132.4 s). The run before it, same branch and script without this commit: the title first asked for a reading at 16.2 s, and no A was seen at any scripted time (the log's first A is at 73.7 s).

Regression run
.\scripts\smoke.ps1 -Game <retail title> -Seconds 60, no input (both runs stay on the start screen), main first, same machine:

xcl-smoke v1
commit: 85e38262ff94aecd75d6f83fa8156a8b7697bd13
gpu: NVIDIA GeForce RTX 5090
title: retail
seconds: 60
exit: 0x0
frames shown: 1638 (PresentX 1638)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16114 MB
xcl-smoke v1
commit: 8cd2f03cef50471556c97398fae289ead61a7980
gpu: NVIDIA GeForce RTX 5090
title: retail
seconds: 60
exit: 0x0
frames shown: 1657 (PresentX 1657)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15802 MB

Not tested

  • The title run above was not on main + this PR alone, but on our integration branch. The regression pair sends no input, so it does not reach the latch.
  • AMD / Intel GPUs (the change is CPU-only), a physical controller together with scripted presses, the e2e title with scripted presses.

AI use

  • omp with Claude Sonnet 5.5 wrote the change and the tests; omp with Claude Opus 5.5 checked the tests against main's window, ran the suite and wrote this description. The title runs are ours, on the hardware above.

Mirror of xcl-dev#1765 (auto-synced, do not edit).

A scripted press (XCL_PRESS_AT / XCL_PRESS_A_AT) was a fixed 200 ms window
of host uptime. When the title's reading thread stalls, the window falls
between two reads and the press is never seen: in a retail title's run at
4-22 fps (first GetCurrentReading at 16.2 s), the presses at 24, 26, 32
and 120 s were lost.

Presses are now a latch (PressLatch, pure over time and read): down at their
time, held until 200 ms have passed AND two readings saw them, then up for
100 ms and two readings before the next press of the same button, so presses
cannot merge. The 250 Hz poller peeks without counting; a state it pushes to
reading callbacks counts as enough readings, as a callback is not skipped.
Each press logs once when first seen by a reading. With the latch, a run of
the same title with presses at 11, 13, 24, 26, 32 and 120 s logged all six
as seen, the last two 10.7 s and 12.4 s after they were due.

Tests drive the latch with 500 ms, stalled and 1 ms read sequences; the
500 ms and stalled ones fail with the old 200 ms window.

Assisted-by: omp (Claude Sonnet 5.5)
Assisted-by: omp (Claude Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants