[GH-ISSUE #1900] windows-boot: input scripts are absolute-time, so a press lands in a different game state across runs (BOOT-INPUT-STATE-RELATIVE) #50

Open
opened 2026-11-26 20:16:03 +01:00 by 4ld0 · 1 comment
Owner

Originally created by @BubsMcgee on GitHub (Nov 25, 2026).
Original GitHub issue: https://github.com/ubiquitarianism/leonida/issues/1900

What

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:

run session d session 0 presents
baseline so-statistics-on-1236 80 s never 6052
ports-only 65 s 85 s 1842
ports + #1759 80 s 100 s 2355
ports + live keys 80 s 160 s 3973

The state arrival differs by 15-20 s; the script does not.

Proposal

Add a state-relative form while keeping name@seconds:

  1. 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 #1790).
  2. 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.

AI-assisted.

Originally created by @BubsMcgee on GitHub (Nov 25, 2026). Original GitHub issue: https://github.com/ubiquitarianism/leonida/issues/1900 ## What `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: | run | session `d` | session `0` | presents | |---|---|---|---| | baseline `so-statistics-on-1236` | 80 s | never | 6052 | | ports-only | 65 s | 85 s | 1842 | | ports + #1759 | 80 s | 100 s | 2355 | | ports + live keys | 80 s | 160 s | 3973 | The state arrival differs by 15-20 s; the script does not. ## Proposal Add a state-relative form while keeping `name@seconds`: 1. **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 #1790). 2. **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`. AI-assisted.
Author
Owner

@Tyrannys commented on GitHub (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:

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 main 3abb99cad. 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.

AI-assisted (Claude Code).

<!-- gh-comment-id:7180707841 --> @Tyrannys commented on GitHub (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: | 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 `main` 3abb99cad. 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. AI-assisted (Claude Code).
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#50
No description provided.