Skip to content

windows-boot: the keyboard pad in focus mode with an input script (BOOT-PAD-FOCUS) - #1790

Open
Coderlord wants to merge 1 commit into
ProjectLeonida:mainfrom
Coderlord:boot-pad-focus
Open

Coderlord wants to merge 1 commit into
ProjectLeonida:mainfrom
Coderlord:boot-pad-focus

Conversation

@Coderlord

Copy link
Copy Markdown

Claimed in the coordination issue as: BOOT-PAD-FOCUS (#1608 (comment))

What and why

scripts/windows-boot/boot.ps1 set LEONIDA_KEYBOARD_PAD=always whenever it passed an input script, so that the
scripted presses would arrive while the game window is not focused. Scripted presses already run with or without
focus in every keyboard-pad mode (docs/gameinput.md: "Scripted presses run with or without focus for unattended
runs"; update_keyboard_pad applies them outside the focus gate), so always only added the machine's physical
keyboard and mouse from any window.

On a native boot left running while the PC was in use, that fed the person's own mouse moves (right stick), clicks
(RB) and Backspace (B) into the title: it went back a page in the first-run flow and changed the UI text size. With
LEONIDA_KEYBOARD_PAD=1 the script works the same and physical input counts only through the focused game window,
which is also how docs/gameinput.md describes playing by hand.

Also updated: the -InputScript help, the harness README's table and the comment over the script reader in
gameinput.cpp (which said the script needed always). scripts/run_guest_scene.py keeps always (a console
tool has no window of its own).

Tested

Windows 11, RTX 5080, native, retail package, ubiq main + this harness setting (set from the shell):

  • A 480 s boot with an 84-press input script under LEONIDA_KEYBOARD_PAD=1 logged exactly the 84 scripted presses
    (gameinput: press ...) and walked the first-run pages to the legal pages.
  • An earlier 600 s boot under always logged its 13 scripted presses plus 80+ unscripted ones (rsup, rsdown,
    rb, b, y) from the person using the PC, after which the title was back on the UI text size page.
  • boot.ps1 -DryRun lists LEONIDA_KEYBOARD_PAD=1 with the default script; the script parses under Windows
    PowerShell 5.1.

GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 Pro 26300

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

@PierreEbele

Copy link
Copy Markdown
Contributor

Reviewed 4e38cbe: checked statically (the shim builds only on Windows, no repo test covers boot.ps1, no pwsh here). LEONIDA_KEYBOARD_PAD=1 is a valid Focused value; scripted presses are written outside the focus-gated block of update_keyboard_pad on the PR base and on main's c68f494 refactor, so a script keeps arriving unfocused, while "always" is what let RIDEV_INPUTSINK raw input reach an unfocused boot - the new default closes a real exposure and is a no-op for no-SDL3 builds (they ignore LEONIDA_KEYBOARD_PAD). One blocker for merging as is: git merge-tree reports gameinput.cpp changed in both, because the comment hunk conflicts with main's RT-INPUT-SCRIPT-NO-SDL3 rewrite (boot.ps1 and README.md apply cleanly) - please rebase and keep the corrected comment.

AI-assisted review.

Recommendation: Fix first

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 26, 2026
…OT-PAD-FOCUS)

boot.ps1 set LEONIDA_KEYBOARD_PAD=always whenever it passed an input script, so that the scripted presses arrive
while the game window is not focused. Scripted presses run with or without focus in every keyboard-pad mode
(docs/gameinput.md, update_keyboard_pad), so `always` only added the machine's physical keyboard and mouse from any
window: on a native Windows boot left running while the PC was in use, the person's mouse moves (right stick),
clicks (RB) and Backspace (B) reached the title and sent the first-run pages back a page. With
LEONIDA_KEYBOARD_PAD=1 the script works as before and physical input counts only through the focused game window.

The InputScript help, the harness README's table, runtime/README.md's LEONIDA_INPUT_SCRIPT row and the comment over
the script reader say the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Coderlord

Copy link
Copy Markdown
Author

@PierreEbele thanks for the review. Rebased onto main 63185f4 (now f550566):

  • gameinput.cpp: main's RT-INPUT-SCRIPT-NO-SDL3 comment kept as it is, with only the corrected parenthetical ("with the keyboard pad on, 1 or always").
  • boot.ps1: main's :hold help text and its LEONIDA_PEEK block kept; the input-script default is LEONIDA_KEYBOARD_PAD=1, and the help says why.
  • Also runtime/README.md's LEONIDA_INPUT_SCRIPT row, which still said the keyboard pad needs always.

Checked: git diff main touches only those four lines of text plus the default, and boot.ps1 parses with no errors (PowerShell 5.1 parser). Not booted again since the rebase. AI-assisted (Claude Code).

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Nov 27, 2026
@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Windows 11 Native Verification Report (f5505665c7 merged onto origin/main adfb3821a2)

  • Merge Status: Clean merge onto origin/main (adfb3821a2) and clean 3-way runtime/shims/gameinput.cpp merge alongside #1528 and #1831.
  • Environment: Windows 11 (10.0.26200, x64), PowerShell 5.1, MSVC 19.44.35228, prebuilt SDL 3.4.20 (SDL3-static.lib), Python 3.12.10 (-DryRun + synthetic virtual-pad CTest only; zero game binaries launched).

Diff Audit (4 files, +10/-7)

  • scripts/windows-boot/boot.ps1: switches $defaults["LEONIDA_KEYBOARD_PAD"] when $InputScript is active from "always" to "1" (KeyboardPadMode::Focused) and documents why in .PARAMETER InputScript.
  • runtime/shims/gameinput.cpp, runtime/README.md, scripts/windows-boot/README.md: aligns comments and environment-variable tables with update_keyboard_pad(), where LEONIDA_INPUT_SCRIPT presses already fire unconditionally whenever g_keyboard.pad is attached (1 or always), while physical GetAsyncKeyState keys and cursor capture remain gated on foreground_is_ours() under 1.

Red -> Green Verification

  1. Red (origin/main adfb3821a2):
    • powershell -NoProfile -ExecutionPolicy Bypass -File scripts/windows-boot/boot.ps1 -Out <empty_stub_dir> -DryRun emitted [boot] env LEONIDA_KEYBOARD_PAD=always alongside [boot] env LEONIDA_INPUT_SCRIPT=a@45,a@60,a@75,a@90 ([boot] dry run: nothing launched, rc=0), exposing unattended boots to physical host keyboard/mouse input from unrelated foreground windows.
  2. Green (#1790 + origin/main):
    • boot.ps1 -Out <empty_stub_dir> -DryRun: emitted [boot] env LEONIDA_KEYBOARD_PAD=1 and [boot] env LEONIDA_INPUT_SCRIPT=a@45,a@60,a@75,a@90 ([boot] dry run: nothing launched, rc=0).
    • boot.ps1 -Out <empty_stub_dir> -NoInput -DryRun: omitted both LEONIDA_INPUT_SCRIPT and LEONIDA_KEYBOARD_PAD (rc=0).
    • gameinput_test.exe (/O2 /MD /EHsc /W4 /permissive- /utf-8, linked against SDL 3.4.20): 389 checks, 0 failures (4.06 s, rc=0), confirming scripted presses arrive unfocused with LEONIDA_KEYBOARD_PAD=1 while physical keys require focus.
    • Combined merge (#1790 + #1528 + #1831 + origin/main) gameinput_test.exe: 393 checks, 0 failures (4.06 s, rc=0).
    • Documentation gates: tests/test_docs_env_vars.py, tests/test_docs_links.py, tests/test_docs_repo_paths.py, tests/test_docs_table_rows.py, and tests/test_docs_encoding.py all passed (OK, rc=0).

Verdict: PASS — ready to merge.

AI-assisted.

@TheGeogeo

Copy link
Copy Markdown
Contributor

Tested f5505665c merged (no commit) with main 53b77df14. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), Ninja, RelWithDebInfo. check_no_game_data.py is clean.

  • No test in the PR, so there is no red/green to show. On the shim side, runtime/shims/gameinput.cpp changes a comment only.
  • The boot.ps1 change (LEONIDA_KEYBOARD_PAD=1 instead of always with an input script) matches main: gameinput.cpp:1916 and docs/gameinput.md:174 already say that scripted presses run while the window is unfocused in mode 1. So unattended boots keep their script, and the keyboard and mouse of whoever uses the machine reach the title only through its focused window.
  • I did not run scripts/windows-boot/boot.ps1, since it starts the title.
  • No regression: the merge rebuilds 180 executables. Of their 294 tests, only xbox_present fails, as on plain main here.
  • LINK: gta6rt.exe links without ws2_32.lib with nothing new over main.
  • A test that would fail without the change: a check that boot.ps1 -InputScript ... sets LEONIDA_KEYBOARD_PAD to 1, not always.

No blocker from my side. AI-assisted (Claude Code).

@OreoFR

OreoFR commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Verified by OreoFR — NO RED (no test; the runtime change is a comment)

Game A/B (values only: no captures, logs or game paths leave this machine). The same gta6rt.exe in both arms, built from main c8bf0e7b6 without the XMA decoder: this PR's gameinput.cpp change is a comment. A = main's boot.ps1, which sets LEONIDA_KEYBOARD_PAD=always. B = this PR's boot.ps1, which sets LEONIDA_KEYBOARD_PAD=1. Recipe: boot.ps1 -Seconds 210 -GameDir -Runtime -Shaders -OutDir, otherwise the defaults (input script a@45,a@60,a@75,a@90). The seed was a precompiled compute journal beside gta6rt.exe, the same for every boot. Order: A1, B1, (two #1681 boots), A2, (one #1681 boot), B2. The game window was left unfocused and nobody used the machine.

Prediction (written before the first boot): B logs the same 4 scripted presses as A, so none are lost with 1 while unfocused. Neither arm has unscripted presses. First frame and frames/s stay within run-to-run noise.

RUN w18-1790-A1 | 2026-11-29 UTC | OreoFR | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        c8bf0e7b6 (boot.ps1 of main) | gta6rt built from c8bf0e7b6
MACHINE:     RTX 4070 Laptop 8 GB (ReBAR), laptop | NVIDIA 621.40 | Windows 11 | 40 GB
RECIPE:      documented (scripts/windows-boot/README.md, boot.ps1 defaults) + DEVIATIONS: -Seconds 210 | seed: precompiled compute journal
OS/DRIVER:   defaults; boot.ps1-set LEONIDA_KEYBOARD_PAD=always
TARGET:      scripted presses logged / unscripted presses; first frame | PREDICTED: 4 / 0
MEASURED:    presses a@45 a@60 a@75 a@90 (4), unscripted 0 | rendering from t=25 s, median 22.1 frames/s (37 windows, 0 under 5) | PresentX ok 4266
END:         time limit (212 s); no device loss, no fault records
CACHES:      boot's pipeline cache fresh (own folder); seed read-only; NVIDIA driver cache not cleared | RUN 1 of 2 for A
VERDICT:     prediction held
RUN w18-1790-B1 | 2026-11-29 UTC | OreoFR | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        c8bf0e7b6 + #1790 (f5505665c), local merge | gta6rt built from c8bf0e7b6 (runtime identical except a comment)
MACHINE:     RTX 4070 Laptop 8 GB (ReBAR), laptop | NVIDIA 621.40 | Windows 11 | 40 GB
RECIPE:      as A1
OS/DRIVER:   defaults; boot.ps1-set LEONIDA_KEYBOARD_PAD=1
TARGET:      scripted presses logged / unscripted presses; first frame | PREDICTED: 4 / 0, as A
MEASURED:    presses a@45 a@60 a@75 a@90 (4), unscripted 0 | rendering from t=25 s, median 14.4 frames/s (29 windows, 6 under 5) | PresentX ok 1944
END:         time limit (216 s); no device loss, no fault records
CACHES:      as A1 | RUN 1 of 2 for B
VERDICT:     prediction held
RUN w18-1790-A2 | 2026-11-29 UTC | OreoFR | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        as A1
MACHINE:     RTX 4070 Laptop 8 GB (ReBAR), laptop | NVIDIA 621.40 | Windows 11 | 40 GB
RECIPE:      as A1
OS/DRIVER:   defaults; boot.ps1-set LEONIDA_KEYBOARD_PAD=always
TARGET:      as A1 | PREDICTED: 4 / 0
MEASURED:    presses a@45 a@60 a@75 a@90 (4), unscripted 0 | rendering from t=23 s, median 14.4 frames/s (36 windows, 5 under 5) | PresentX ok 2552
END:         time limit (213 s); no device loss, no fault records
CACHES:      as A1 | RUN 2 of 2 for A
VERDICT:     prediction held
RUN w18-1790-B2 | 2026-11-29 UTC | OreoFR | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        as B1
MACHINE:     RTX 4070 Laptop 8 GB (ReBAR), laptop | NVIDIA 621.40 | Windows 11 | 40 GB
RECIPE:      as A1
OS/DRIVER:   defaults; boot.ps1-set LEONIDA_KEYBOARD_PAD=1
TARGET:      as B1 | PREDICTED: 4 / 0, as A
MEASURED:    presses a@45 a@60 a@75 a@90 (4), unscripted 0 | rendering from t=23 s, median 24.0 frames/s (37 windows, 0 under 5) | PresentX ok 4897
END:         time limit (211 s); no device loss, no fault records
CACHES:      as A1 | RUN 2 of 2 for B
VERDICT:     prediction held

Result: scripted input works the same with 1 as with always (4/4 presses in all four boots, unfocused). The frame rate splits about 22-24 vs 14-15 frames/s in both arms, depending on which screen a boot sits on at the end, not on the arm. What the PR changes, keeping the user's own keyboard and mouse out of an unfocused boot, can't be shown without someone using the machine. Nobody did, so neither arm logged an unscripted press.

AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.

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

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants