windows-boot: state-relative input presses (BOOT-INPUT-STATE-RELATIVE) #1917

Open
github-bot wants to merge 1 commit from github-bot/gh-1917 into main AGit
Owner

@⁠BubsMcgee on GitHub · 2026-11-25 15:47 UTC · original
BubsMcgee:boot-input-state → main · +391 −9 · 4 files · 1 commits · open

Claimed in the coordination issue as: BOOT-INPUT-STATE-RELATIVE (#1608). No dependencies; this is the harness side and reads keys through the keyboard pad (GetAsyncKeyState), so #1790's focus mode is orthogonal.

Fixes: #1900

What and why

-InputScript was absolute-time only (a@45,a@60,...). 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 in one build and back out to the menu (session d -> 0) in another, changing presents, PSO counts and the path being compared.

This adds button@game=<hex>+<delay> / button@session=<hex>+<delay>: the harness watches the existing LEONIDA_PEEK values (0x7446510 game, low dword of 0x98f828c session) and injects the key once that state has been seen for the delay. Absolute entries still go to the runtime unchanged.

Files

  • tools/boot_input_script.py: parse and due matcher (stdlib only).
  • scripts/windows-boot/boot.ps1: split the script, watch the log, inject through the keyboard pad (SendInput, LEONIDA_KEYBOARD_PAD=always; no focus needed), and read the log in the digest with a share that tolerates the redirect handle.
  • scripts/windows-boot/README.md and --help: the new form and an example.
  • tests/test_boot_input_script.py: synthetic parse/due cases.

Tested

  • python -I tests/test_boot_input_script.py: 12/12.
  • python -I scripts/check_no_game_data.py on the changed files: OK.
  • -DryRun with a@session=3+5,a@session=d+5: absolute='' state=2.
  • 200 s boot on RTX 3080 Ti / Windows 11 / NVIDIA 616.64 with a@session=3+5,a@session=d+5: the harness injected a at session=3 (55.8 s) and session=d (70.9 s); the keyboard pad logged press [email protected]/69.0/69.9; -DigestOnly reads states session=3 @55 s, session=d @70 s, and the known world-start device loss (lib_cs_03426...).

AI-assisted.

**@⁠BubsMcgee** on GitHub · 2026-11-25 15:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1917) `BubsMcgee:boot-input-state` → `main` · +391 −9 · 4 files · 1 commits · open Claimed in the coordination issue as: BOOT-INPUT-STATE-RELATIVE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608). No dependencies; this is the harness side and reads keys through the keyboard pad (`GetAsyncKeyState`), so #1790's focus mode is orthogonal. Fixes: #1900 ### What and why `-InputScript` was absolute-time only (`a@45,a@60,...`). 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 in one build and back out to the menu (`session d -> 0`) in another, changing presents, PSO counts and the path being compared. This adds `button@game=<hex>+<delay>` / `button@session=<hex>+<delay>`: the harness watches the existing `LEONIDA_PEEK` values (`0x7446510` game, low dword of `0x98f828c` session) and injects the key once that state has been seen for the delay. Absolute entries still go to the runtime unchanged. ### Files - `tools/boot_input_script.py`: parse and due matcher (stdlib only). - `scripts/windows-boot/boot.ps1`: split the script, watch the log, inject through the keyboard pad (`SendInput`, `LEONIDA_KEYBOARD_PAD=always`; no focus needed), and read the log in the digest with a share that tolerates the redirect handle. - `scripts/windows-boot/README.md` and `--help`: the new form and an example. - `tests/test_boot_input_script.py`: synthetic parse/due cases. ### Tested - `python -I tests/test_boot_input_script.py`: 12/12. - `python -I scripts/check_no_game_data.py` on the changed files: OK. - `-DryRun` with `a@session=3+5,a@session=d+5`: `absolute='' state=2`. - 200 s boot on RTX 3080 Ti / Windows 11 / NVIDIA 616.64 with `a@session=3+5,a@session=d+5`: the harness injected `a` at session=3 (55.8 s) and session=d (70.9 s); the keyboard pad logged `press [email protected]/69.0/69.9`; `-DigestOnly` reads states `session=3 @55 s`, `session=d @70 s`, and the known world-start device loss (`lib_cs_03426...`). AI-assisted.
Absolute `button@seconds` entries still go to the runtime. `button@game=3+5` and
`button@session=d+5` are matched by the harness against LEONIDA_PEEK and injected as keys once the
state has been seen for the delay, so an A/B boot presses in the same game state when startup timing
shifts. The parser/state matcher is tools/boot_input_script.py (unit-tested); boot.ps1 watches the log,
injects through the keyboard pad (SendInput; LEONIDA_KEYBOARD_PAD=always, no focus needed), and now
reads the log with a share that tolerates the redirect handle.

Tested: 12/12 unit tests; dry run; 200 s boot on RTX 3080 Ti / Windows 11 / NVIDIA 616.64 with
-InputScript "a@session=3+5,a@session=d+5": the harness injected a at session=3 (55.8 s) and
session=d (70.9 s), the keyboard pad logged press [email protected]/69.0/69.9, and the run reached session d and
the known world-start device loss (lib_cs_03426...).

Claimed in the coordination issue as: BOOT-INPUT-STATE-RELATIVE.
AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:11:02 +00:00
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 19:28 UTC · original · reviewed

Independent Windows check at 34da84a13: the 12 Python tests pass. Synthetic state transitions and two PowerShell 5.1 dry runs reproduce the timing and plan-file issues below. No game process was launched and no system input was sent.

AI-assisted.

**@⁠lixonik** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1917#pullrequestreview-6063713410) · **reviewed** Independent Windows check at `34da84a13`: the 12 Python tests pass. Synthetic state transitions and two PowerShell 5.1 dry runs reproduce the timing and plan-file issues below. No game process was launched and no system input was sent. AI-assisted.
@ -347,0 +435,4 @@
if ($null -eq $game -and $null -eq $session) { continue }
$now = ((Get-Date) - $watchStart).TotalSeconds
if ($null -ne $game -and $null -eq $seen.game) { $seen.game = $now }
if ($null -ne $session -and $null -eq $seen.session) { $seen.session = $now }
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 19:28 UTC · original

[P2] Start the delay when the observed value changes

The timer is set on the first report for the field and is never reset if its value changes. With a synthetic first report of session 0 at t=0 and the first d at t=10, the watcher code supplies seen-session=0 and button@session=d+5 is due immediately. It should first be eligible at t=15. Track the current value and its entry time for both fields, and add a transition case to the tests.

**@⁠lixonik** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1917#discussion_r4699836309) [P2] Start the delay when the observed value changes The timer is set on the first report for the field and is never reset if its value changes. With a synthetic first report of session `0` at t=0 and the first `d` at t=10, the watcher code supplies `seen-session=0` and `button@session=d+5` is due immediately. It should first be eligible at t=15. Track the current value and its entry time for both fields, and add a transition case to the tests.
@ -227,0 +232,4 @@
# for the delay. The parser/state matcher is tools/boot_input_script.py (unit-tested separately).
$absoluteScript = $InputScript
$statePlan = @()
$InputPlanFile = Join-Path ([System.IO.Path]::GetTempPath()) ("leonida-input-plan-" + $Name + ".json")
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 19:28 UTC · original

[P2] Keep the input plan local to the run

This path is keyed only by -Name and is written before the -DryRun exit and before the run lock. Two dry runs using different output directories and the same name created and then replaced the same temporary plan. The second run can also replace a live run's plan, since the watcher opens it on each poll. Keep the plan in memory or use a unique per-run file written after validation and dry-run handling.

**@⁠lixonik** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1917#discussion_r4699836316) [P2] Keep the input plan local to the run This path is keyed only by `-Name` and is written before the `-DryRun` exit and before the run lock. Two dry runs using different output directories and the same name created and then replaced the same temporary plan. The second run can also replace a live run's plan, since the watcher opens it on each poll. Keep the plan in memory or use a unique per-run file written after validation and dry-run handling.
@ -347,0 +404,4 @@
input[0].type = 1; // INPUT_KEYBOARD
input[0].ki.wVk = vk;
input[0].ki.dwFlags = down ? 0u : 2u; // KEYEVENTF_KEYUP
SendInput(1, input, Marshal.SizeOf(typeof(INPUT)));
Author
Owner

@⁠lixonik on GitHub · 2026-11-25 19:28 UTC · original

[P2] Keep unattended input out of the system keyboard stream

SendInput enters the system keyboard stream. LEONIDA_KEYBOARD_PAD=always lets the game observe it in the background, and the foreground app can still receive the synthesized Enter, Backspace or Escape. This makes unattended runs affect other apps. Route scripted presses through the runtime's virtual pad. Win32 SendInput docs.

**@⁠lixonik** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1917#discussion_r4699836327) [P2] Keep unattended input out of the system keyboard stream `SendInput` enters the system keyboard stream. `LEONIDA_KEYBOARD_PAD=always` lets the game observe it in the background, and the foreground app can still receive the synthesized Enter, Backspace or Escape. This makes unattended runs affect other apps. Route scripted presses through the runtime's virtual pad. [Win32 SendInput docs](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput).
This pull request has changes conflicting with the target branch.
  • scripts/windows-boot/boot.ps1
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1917/head:github-bot/gh-1917'
git switch 'github-bot/gh-1917'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1917'
git switch 'github-bot/gh-1917'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1917'
git switch 'github-bot/gh-1917'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1917'
git switch 'main'
git merge --squash 'github-bot/gh-1917'
git switch 'main'
git merge --ff-only 'github-bot/gh-1917'
git switch 'main'
git merge 'github-bot/gh-1917'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.