You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
windows-boot: input scripts are absolute-time, so a press lands in a different game state across runs (BOOT-INPUT-STATE-RELATIVE) #1900
LEONIDA_INPUT_SCRIPT (-InputScript) schedules presses at absolute seconds since the keyboard pad's first update (a@45,a@60,a@75,a@90). The title reaches the same states at different times from run to run, so the same script lands presses in different game states. In A/B runs an A at 75/90 s can advance to gameplay in one build and back out to the menu (session d -> 0) in another, which changes the presents, PSO counts and even the game path being compared.
Evidence
Same 200 s boot, a@45,a@60,a@75,a@90, RTX 3080 Ti / Windows 11 / NVIDIA 616.64:
The state arrival differs by 15-20 s; the script does not.
Proposal
Add a state-relative form while keeping name@seconds:
Harness side (preferred, no runtime change):boot.ps1 already parses the LEONIDA_PEEK states (0x7446510 game, low dword of 0x98f828c session; runtime/src/main.cpp prints them). Add an -InputScript form such as a@session=d+5 / a@game=3+5: the harness waits for the peek to match, then injects the key (SendInput) into the focused window with LEONIDA_KEYBOARD_PAD=1 (the focus mode from windows-boot: the keyboard pad in focus mode with an input script (BOOT-PAD-FOCUS) #1790).
Runtime side: extend rt::gameinput::script (runtime/shims/gameinput_script.h) so a press can name a state (a@session=d+5) and update_keyboard_pad gates it on the same peek RVAs; the peek thread in runtime/src/main.cpp already reads them.
Either way the absolute form stays for compatibility.
Needs
A full test needs the retail package (the states come from the title). The parser/state matcher can be unit-tested without game files or a GPU (runtime/test/gameinput_test.cpp / a synthetic state watcher test).
Related: #1790 (focus mode; this is about timing, not the live-key leak), #1612 (first-run pad focus), scripts/windows-boot/README.md.
Data from a second machine for the design here: presses are not only landing in the wrong state, but most never reach the title at all once frames get slow. A state-relative form helps only if the press also lasts until the title reads it.
Setup: RTX 4070 SUPER, NVIDIA 621.01. A build without SDL3, so the script drives the scripted pad of runtime/shims/gameinput_no_sdl.cpp. Four 1,200 s boots of the same tree (with and without other PRs that do not touch input), a 21-press script from 150 s to 435 s, and a fresh save folder each run.
What happened: 3 of 21 presses were logged in each of the four runs, and which 3 differed:
run
presses that reached the pad
A
a@150, a@215, a@245
B
a@150, down@265, down@285
C
a@150, down@285, a@435
D
a@150, a@215, down@285
All four runs went through the same states at the same times (peek: game 3 / session 3 from ~55 s, session d at 155 s, session 0 from 170 s to the end).
Why: the scripted pad takes a reading only when the title calls GetCurrentReading or GetNextReading (update(now_us()) at gameinput_no_sdl.cpp:505 and :548). held_at() (gameinput_script.h:102) holds a press only for kHoldSeconds = 0.3 from its scheduled time. So a press exists for the title only if the title polls inside that 0.3 s window. Presents per minute in the same runs:
from
0-60 s
60-180 s
180-240 s
240-300 s
300 s on
PresentX per minute
~700-900
~2,000
~260-310
~65-70
0-30
From about 200 s the frame interval is several seconds. A 0.3 s window then catches a poll about one time in seven, which matches 3 of 21. (Line numbers are for main3abb99c. I did not check the SDL3 path on current main.) On this machine, the slow frames are the runtime's own (pipeline builds and stalls), not the title's.
Suggestion for the state-relative form: keep a press held until the title has read it at least once, or for at least N polls, as well as for 0.3 s. Otherwise a@session=d+5 still loses the press whenever the frame interval is longer than the hold. Testing the timing needs the retail package. The rule can be unit-tested on held_at() with a fake poll clock.
The current shim already accepts a per-event hold that makes the missed-poll case testable without a title. I compiled the exact gameinput_script.h at d1dff7949be62b6609c3c2ca937df7f50fbf1305. With synthetic poll times 0.9, 2.3 and 3.6 s, a@1 is observed zero times and a@1:2.5 exactly once. Parser and hold logic. This extends Tyrannys's timing report on the current code.
For the state-relative patch, one useful acceptance test is to move those same polls across the state transition and verify the first eligible sparse poll still gets the input. KLBF's clock-by-world-frame version missed a one-frame event with zero polls, so changing the clock alone can leave an equivalent problem. The longer hold is a control, and could span more than one poll at higher frame rates. PortBridge · AI-assisted synthetic test report.
Activity
Tyrannys commentedon Nov 26, 2026
Data from a second machine for the design here: presses are not only landing in the wrong state, but most never reach the title at all once frames get slow. A state-relative form helps only if the press also lasts until the title reads it.
Setup: RTX 4070 SUPER, NVIDIA 621.01. A build without SDL3, so the script drives the scripted pad of
runtime/shims/gameinput_no_sdl.cpp. Four 1,200 s boots of the same tree (with and without other PRs that do not touch input), a 21-press script from 150 s to 435 s, and a fresh save folder each run.What happened: 3 of 21 presses were logged in each of the four runs, and which 3 differed:
All four runs went through the same states at the same times (peek: game 3 / session 3 from ~55 s, session
dat 155 s, session0from 170 s to the end).Why: the scripted pad takes a reading only when the title calls
GetCurrentReadingorGetNextReading(update(now_us())atgameinput_no_sdl.cpp:505and:548).held_at()(gameinput_script.h:102) holds a press only forkHoldSeconds = 0.3from its scheduled time. So a press exists for the title only if the title polls inside that 0.3 s window. Presents per minute in the same runs:From about 200 s the frame interval is several seconds. A 0.3 s window then catches a poll about one time in seven, which matches 3 of 21. (Line numbers are for
main3abb99c. I did not check the SDL3 path on currentmain.) On this machine, the slow frames are the runtime's own (pipeline builds and stalls), not the title's.Suggestion for the state-relative form: keep a press held until the title has read it at least once, or for at least N polls, as well as for 0.3 s. Otherwise
a@session=d+5still loses the press whenever the frame interval is longer than the hold. Testing the timing needs the retail package. The rule can be unit-tested onheld_at()with a fake poll clock.AI-assisted (Claude Code).
akimfomin commentedon Nov 26, 2026
The current shim already accepts a per-event hold that makes the missed-poll case testable without a title. I compiled the exact
gameinput_script.hatd1dff7949be62b6609c3c2ca937df7f50fbf1305. With synthetic poll times 0.9, 2.3 and 3.6 s,a@1is observed zero times anda@1:2.5exactly once. Parser and hold logic. This extends Tyrannys's timing report on the current code.For the state-relative patch, one useful acceptance test is to move those same polls across the state transition and verify the first eligible sparse poll still gets the input. KLBF's clock-by-world-frame version missed a one-frame event with zero polls, so changing the clock alone can leave an equivalent problem. The longer hold is a control, and could span more than one poll at higher frame rates. PortBridge · AI-assisted synthetic test report.