gameinput: keyboard pad input scripts of any length (RT-INPUT-SCRIPT-LENGTH) #1074

Manually merged
github merged 1 commit from gh-pr/1074/head into gh-pr/1074/base 2026-11-26 09:36:44 +00:00
Owner

@⁠Moriz82 on GitHub · 2026-11-24 17:52 UTC · original
split/rt-input-script-length → main · +115 −11 · 4 files · 1 commits · merged 2026-11-24 20:44 UTC

Claimed in the coordination issue as: RT-INPUT-SCRIPT-LENGTH (claim).

Part of the split of #984 into small pull requests.

Depends on: none
Overlaps: #984 contains the integration. #955 changes physical
right-stick keys and controller hotplug in the same shim.

What and why

Main had no scheduler for keyboard pad input scripts. This change reads
LEONIDA_INPUT_SCRIPT and schedules comma-separated button@seconds
entries. The shared environment reader now reads every LEONIDA_*
setting used by this shim at full length. Previously, values of 64
characters or more read as unset.

The first keyboard pad update reads the script and starts its clock.
Each scheduled press lasts 300 ms and works with or without focus. A
physical key or another active scheduled press can keep a button held.
reload_config() leaves the startup script in effect.

Spaces around an entry are allowed. Empty entries, unknown buttons and
missing, malformed, negative or non-finite times are ignored. The shim
logs the accepted and rejected counts for each nonempty script. Leave
the variable unset to disable scheduling.

Tested

Release cross-build with clang-cl 23.1.5 and an xwin SDK on CachyOS,
kernel 7.3.5. The tests used Proton Experimental (Wine 11), a Ryzen 5
5600X, 16 GB RAM and SDL virtual joysticks. The host had an RTX 4070
12 GB with NVIDIA 620.73.04. CMake omitted the optional XMA2 decoder
because the Rust Windows target was unavailable.

build=runtime/build/boot
for target in gameinput_test gta6rt; do
  cmake --build "$build" --target "$target" -j6
done
wine "$build/gameinput_test.exe"
wine "$build/gameinput_test.exe" --input-script
python3 -I tests/test_docs_env_vars.py
python3 -I scripts/run_semantic_tests.py tests/semantic -j 2
python3 -I scripts/check_no_game_data.py
git diff --check HEAD^ HEAD

The 135-byte fixture places X at byte offset 67, padded with whitespace,
and schedules X again later. It supplies an unknown button, missing and
invalid times, empty items and a whitespace-only item. Physical B and
scripted X are held on the first reading. After losing focus and
reloading with a different script, only X is held. Once the original
press expires and focus returns, only B is held.

The default run passed 364/364 checks. The focused run passed 10/10 and
reported eight scheduled entries and eleven rejected entries.

Both controls used the same test object and link settings. For the
reader control, restore only env() from the commit's parent. For the
parser control, restore only the pre-review parsing loop with its
unchecked time conversion. Run each control with --input-script.

Build Default Focused Result
Amended child 364/364 10/10 Only the scheduled X and physical B
Old reader — 8/10 Scripted X missing, exit 1
Old parser — 7/10 Padded X missed, unintended A held, exit 1

Each fraction counts passing checks. Only the child ran the default
suite. The old parser counted 14 entries as valid.

cmake -S runtime -B "$build" -DLEONIDA_SDL3=OFF
ctest --test-dir "$build" -N -R '^gameinput(_script)?$'
cmake -S runtime -B "$build" -DLEONIDA_SDL3=ON

Both gameinput and gameinput_script appeared disabled without SDL3
and enabled again after restoring SDL3. The documentation suite passed
4/4 tests. The semantic suite passed 6,168 tests in 470 files. The
content and whitespace checks passed.

A contributor tested the pre-review scheduler on native Windows 11.
All 14/14 runs passed at lengths from 63 to 4,096 bytes. With only the
old reader restored, both 63-byte runs passed and all 12/12 longer runs
missed the scheduled presses. Native Windows has not been rerun on this
revision. AMD, Intel, a physical controller and a game boot were not
tested on this revision.

GPUs tested: none. The GameInput tests use synthetic input.
AI-assisted: yes

Checklist

  • One commit on bd8d72bb2, verified to merge cleanly into 955d9be34.
  • One topic with its regression test and documented setting.
  • No game data. The content guard passed.
  • No translator rule changes.

🤖 Generated with Claude Code

**@⁠Moriz82** on GitHub · 2026-11-24 17:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1074) `split/rt-input-script-length` → `main` · +115 −11 · 4 files · 1 commits · merged 2026-11-24 20:44 UTC Claimed in the coordination issue as: RT-INPUT-SCRIPT-LENGTH ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). Part of the split of #984 into small pull requests. Depends on: none Overlaps: #984 contains the integration. #955 changes physical right-stick keys and controller hotplug in the same shim. ### What and why Main had no scheduler for keyboard pad input scripts. This change reads `LEONIDA_INPUT_SCRIPT` and schedules comma-separated `button@seconds` entries. The shared environment reader now reads every `LEONIDA_*` setting used by this shim at full length. Previously, values of 64 characters or more read as unset. The first keyboard pad update reads the script and starts its clock. Each scheduled press lasts 300 ms and works with or without focus. A physical key or another active scheduled press can keep a button held. `reload_config()` leaves the startup script in effect. Spaces around an entry are allowed. Empty entries, unknown buttons and missing, malformed, negative or non-finite times are ignored. The shim logs the accepted and rejected counts for each nonempty script. Leave the variable unset to disable scheduling. ### Tested Release cross-build with clang-cl 23.1.5 and an xwin SDK on CachyOS, kernel 7.3.5. The tests used Proton Experimental (Wine 11), a Ryzen 5 5600X, 16 GB RAM and SDL virtual joysticks. The host had an RTX 4070 12 GB with NVIDIA 620.73.04. CMake omitted the optional XMA2 decoder because the Rust Windows target was unavailable. ```sh build=runtime/build/boot for target in gameinput_test gta6rt; do cmake --build "$build" --target "$target" -j6 done wine "$build/gameinput_test.exe" wine "$build/gameinput_test.exe" --input-script python3 -I tests/test_docs_env_vars.py python3 -I scripts/run_semantic_tests.py tests/semantic -j 2 python3 -I scripts/check_no_game_data.py git diff --check HEAD^ HEAD ``` The 135-byte fixture places X at byte offset 67, padded with whitespace, and schedules X again later. It supplies an unknown button, missing and invalid times, empty items and a whitespace-only item. Physical B and scripted X are held on the first reading. After losing focus and reloading with a different script, only X is held. Once the original press expires and focus returns, only B is held. The default run passed 364/364 checks. The focused run passed 10/10 and reported eight scheduled entries and eleven rejected entries. Both controls used the same test object and link settings. For the reader control, restore only `env()` from the commit's parent. For the parser control, restore only the pre-review parsing loop with its unchecked time conversion. Run each control with `--input-script`. | Build | Default | Focused | Result | |---|---:|---:|---| | Amended child | 364/364 | 10/10 | Only the scheduled X and physical B | | Old reader | — | 8/10 | Scripted X missing, exit 1 | | Old parser | — | 7/10 | Padded X missed, unintended A held, exit 1 | Each fraction counts passing checks. Only the child ran the default suite. The old parser counted 14 entries as valid. ```sh cmake -S runtime -B "$build" -DLEONIDA_SDL3=OFF ctest --test-dir "$build" -N -R '^gameinput(_script)?$' cmake -S runtime -B "$build" -DLEONIDA_SDL3=ON ``` Both `gameinput` and `gameinput_script` appeared disabled without SDL3 and enabled again after restoring SDL3. The documentation suite passed 4/4 tests. The semantic suite passed 6,168 tests in 470 files. The content and whitespace checks passed. A contributor tested the pre-review scheduler on native Windows 11. All 14/14 runs passed at lengths from 63 to 4,096 bytes. With only the old reader restored, both 63-byte runs passed and all 12/12 longer runs missed the scheduled presses. Native Windows has not been rerun on this revision. AMD, Intel, a physical controller and a game boot were not tested on this revision. GPUs tested: none. The GameInput tests use synthetic input. AI-assisted: yes ### Checklist - [x] One commit on `bd8d72bb2`, verified to merge cleanly into `955d9be34`. - [x] One topic with its regression test and documented setting. - [x] No game data. The content guard passed. - [x] No translator rule changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Main had no keyboard pad script scheduler. Add timed button presses with
a full-length environment reader so entries beyond byte 63 reach the pad.
Combine scheduled and physical presses. Reject malformed entries and
report their count when the script is read on the first pad update.

Build gta6rt and gameinput_test. Exercise a long script, rejected items,
focus loss, configuration reload and release under Wine. Restore only the
old environment reader to reproduce the missing presses.

Co-authored-by: Plaaasma <[email protected]>


AI-assisted (Codex and Claude Code agents).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:36:41 +00:00
github manually merged commit f9ba70b4de into gh-pr/1074/base 2026-11-26 09:36:44 +00:00
Author
Owner

@⁠sodove on GitHub · 2026-11-24 18:02 UTC · original

Confirmed on native Windows 11 (26100.7623) at 5e86f4a3, using MSVC 19.44, RelWithDebInfo and the pinned SDL3. Both the final scripted X press and its release reached IGameInput::GetCurrentReading.

I held B through the test keyboard source, scheduled X once at startup and again as the last entry at 0.70 s, and sampled the virtual pad through both press windows. At script lengths of 63, 64, 65, 69, 70, 76 and 4,096 ASCII bytes, GameInput reported B+X → B → B+X → B every time (14/14 runs, two per length). The final X was visible for 294–311 ms. In the longest case its entry started at byte offset 4,090. Releasing the held key afterward cleared B as well.

For a control I kept the same probe, scheduler and libraries and restored only the parent commit’s 64-byte environment reader. Both 63-byte runs still saw both X presses. At every tested length from 64 bytes up, only B was visible (12/12 control runs). The unmodified PR tests also passed here: gameinput 364/364 and gameinput_script 8/8.

SDL virtual pad and synthetic keyboard input only. No game files or GPU needed. AI-assisted: yes (OpenAI Codex).

**@⁠sodove** on GitHub · 2026-11-24 18:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1074#issuecomment-7140082800) Confirmed on native Windows 11 (26100.7623) at `5e86f4a3`, using MSVC 19.44, RelWithDebInfo and the pinned SDL3. Both the final scripted X press and its release reached `IGameInput::GetCurrentReading`. I held B through the test keyboard source, scheduled X once at startup and again as the **last entry** at 0.70 s, and sampled the virtual pad through both press windows. At script lengths of 63, 64, 65, 69, 70, 76 and 4,096 ASCII bytes, GameInput reported `B+X → B → B+X → B` every time (14/14 runs, two per length). The final X was visible for 294–311 ms. In the longest case its entry started at byte offset 4,090. Releasing the held key afterward cleared B as well. For a control I kept the same probe, scheduler and libraries and restored only the parent commit’s 64-byte environment reader. Both 63-byte runs still saw both X presses. At every tested length from 64 bytes up, only B was visible (12/12 control runs). The unmodified PR tests also passed here: `gameinput` 364/364 and `gameinput_script` 8/8. SDL virtual pad and synthetic keyboard input only. No game files or GPU needed. AI-assisted: yes (OpenAI Codex).
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-24 18:11 UTC · original

Review of #1074, "gameinput: read full-length keyboard pad scripts (RT-INPUT-SCRIPT-LENGTH)"

Head: 5e86f4a3f21793a798ed460b59c0c2eed6f7a72b (one commit on bd8d72bb2). Claim on #14 (comment 7139824543, Moriz82) matches the change.

Environment: Windows 11 Pro 26300, MSVC 19.50 (VS 18 Build Tools), CMake with the "Visual Studio 18 2026" generator. No SDL3 is installed on this machine and none is on the drive, so gameinput_test cannot be built here. I did not download SDL3. No GPU was used.

What I ran

  • git merge-tree --write-tree origin/main HEAD against origin/main 3aa975421: clean (tree 96d20b5e3). git diff --check origin/main...HEAD: clean.
  • cmake -S runtime -B runtime/build -G "Visual Studio 18 2026" -DBUILD_TESTING=ON in the PR worktree: "GameInput shim not built: no installed SDL3 found". ctest -N -R gameinput lists only gameinput_host and gameinput (Disabled). The new gameinput_script test is not registered, which is expected without SDL3.
  • python -I tests/test_docs_env_vars.py: 4 tests, OK.
  • gameinput_test itself: not built or run. It needs SDL3. Because of that I could not run it on the merge base, and I could not do the mutation inside the real target. On the merge base the --input-script mode does not exist at all: main() ignores argv and the shim has no scheduler. So the new test would fail there because the feature is missing, not only because of the length limit.
  • As a substitute I built a standalone harness with cl /std:c++20 /EHsc /W4 /DNOMINMAX. It holds a verbatim copy of the new env(), the old 64-byte env() (under -DOLD), and the script parser lambda, with the SDL enums replaced by ints. Results:
    • New env(): the PR's 76-character test script gives 8 entries. A 65-character value gives 1 entry. A 32,000-character value (8,000 entries) parses fully. An empty value and a value with no @ give 0 entries. 0 failures.
    • Old env() (the mutation): the 76-, 65- and 32,000-character values all read as unset and give 0 entries. 3 failures. So reintroducing the old limit makes the length cases fail, as the PR's control run also reports (7/8 under Wine).

Findings

  1. The length fix is correct (runtime/shims/gameinput.cpp:135-146). It uses the two-call GetEnvironmentVariableA pattern: first the size including the terminator, then a read into std::string(need), then n >= need is rejected and the string is resized to n. Nothing overflows. The allocation is bounded by the Windows limit of 32,767 characters per variable, so this adds no unbounded allocation. An empty but set variable gives need = 1 and n = 0, so it reads as unset, as before. A value that grows between the two calls also reads as unset. That race is harmless and the old code had the same outcome.
  2. The env() change affects every LEONIDA_* setting the shim reads, not only the script (gameinput.cpp:150-192). A value of 64 characters or more used to read as unset and is now parsed. All those parsers already accept arbitrary strings, so I see no risk. It is a behaviour change worth one line in the description.
  3. Scope. The title says "read full-length scripts", but main has no LEONIDA_INPUT_SCRIPT at all (git grep INPUT_SCRIPT origin/main is empty). This PR adds the whole scheduler: parser, 300 ms presses, per-button OR with physical keys, and stderr logging (gameinput.cpp:1898-1946). The body says this, but the title could say "add keyboard pad input script" so the change log is accurate.
  4. Malformed input is accepted silently (gameinput.cpp:1912-1921). Button names match exactly after lowercasing, so zz@1 and @2 are dropped. Leading spaces are also dropped: " a@1" is ignored, while the docs example has no spaces. The time is parsed with std::atof with no check, so a@, a@x and a@abc all schedule a press at 0 s. a@1@2 gives a press at 1 s, a@-1 never fires, a@nan never fires and a@1e999 (inf) never fires. None of this is unsafe: everything is bounds-checked, and press.button is always one of the 12 table values, so named[] and scripted[] cannot be indexed out of range. But a typo like a@ producing a press at start-up is surprising. Suggestion: use strtod with an end-pointer check, skip entries with a non-finite or negative time, and optionally log the count of rejected entries next to the existing "N scripted press(es)" line.
  5. The test does not cover malformed input (runtime/test/gameinput_test.cpp:1719-1739). It covers a 76-character script, a press after byte 63, a later entry for the same button that must not cancel the earlier one, a held physical key, and release after 300 ms. Those are the right core cases. Nothing tests an unknown name, a missing or garbage time, or empty items (,,). One extra entry such as zz@0,a@, that asserts nothing extra is held would pin the parser behaviour. That check would currently fail for a@, because of finding 4.
  6. Scripted presses ignore focus (gameinput.cpp:1871 and 1937). With LEONIDA_KEYBOARD_PAD=1 and the window unfocused, down[] is all false, but the scripted buttons are still pressed. The comment at 1869 says out of focus "every button ... is released". For unattended runs this is probably what is wanted. The docs row should say so, or the code should gate on active.
  7. The script is read once per process, on the first keyboard-pad update (the function-local static at gameinput.cpp:1903). reload_config() does not re-read it. The docs row says "set before starting", which is consistent, but "read once at start-up" would be clearer, since other rows in that table are re-read by reload_config. The test works around this by using a separate process mode.
  8. The per-frame cost is O(number of entries) on each poll. That is fine even for the 8,000-entry worst case.
  9. CMakeLists (runtime/CMakeLists.txt:1331): gameinput_script is added only inside if(WIN32 AND TARGET gameinput_test). Builds without SDL3 are unchanged: they still list one gameinput (Disabled) placeholder, which I confirmed above. A matching disabled gameinput_script placeholder would make the skipped test visible, but that is optional.
  10. Test timing: the press at 0 s is checked on the first poll, and release after Sleep(350) against a 300 ms window. GetTickCount64 resolution is about 16 ms, so the margin is enough.

Verdict: the length fix is correct and bounded, the merge is clean, and the docs table row is present and passes the docs test. I could not run the real test here (no SDL3). The standalone harness confirms the new reader handles long values, and that the old reader drops them. I would approve after the title or description reflects that this adds the scheduler. Rejecting malformed times (finding 4) plus a malformed-input test case (finding 5) are recommended but not blocking. Findings 6 and 7 are doc clarifications.

AI-assisted.

**@⁠kawaii-shakal** on GitHub · 2026-11-24 18:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1074#issuecomment-7140277887) Review of #1074, "gameinput: read full-length keyboard pad scripts (RT-INPUT-SCRIPT-LENGTH)" Head: 5e86f4a3f21793a798ed460b59c0c2eed6f7a72b (one commit on bd8d72bb2). Claim on #14 (comment 7139824543, Moriz82) matches the change. Environment: Windows 11 Pro 26300, MSVC 19.50 (VS 18 Build Tools), CMake with the "Visual Studio 18 2026" generator. No SDL3 is installed on this machine and none is on the drive, so `gameinput_test` cannot be built here. I did not download SDL3. No GPU was used. What I ran - `git merge-tree --write-tree origin/main HEAD` against origin/main 3aa975421: clean (tree 96d20b5e3). `git diff --check origin/main...HEAD`: clean. - `cmake -S runtime -B runtime/build -G "Visual Studio 18 2026" -DBUILD_TESTING=ON` in the PR worktree: "GameInput shim not built: no installed SDL3 found". `ctest -N -R gameinput` lists only `gameinput_host` and `gameinput (Disabled)`. The new `gameinput_script` test is not registered, which is expected without SDL3. - `python -I tests/test_docs_env_vars.py`: 4 tests, OK. - `gameinput_test` itself: not built or run. It needs SDL3. Because of that I could not run it on the merge base, and I could not do the mutation inside the real target. On the merge base the `--input-script` mode does not exist at all: `main()` ignores argv and the shim has no scheduler. So the new test would fail there because the feature is missing, not only because of the length limit. - As a substitute I built a standalone harness with `cl /std:c++20 /EHsc /W4 /DNOMINMAX`. It holds a verbatim copy of the new `env()`, the old 64-byte `env()` (under `-DOLD`), and the script parser lambda, with the SDL enums replaced by ints. Results: - New `env()`: the PR's 76-character test script gives 8 entries. A 65-character value gives 1 entry. A 32,000-character value (8,000 entries) parses fully. An empty value and a value with no `@` give 0 entries. 0 failures. - Old `env()` (the mutation): the 76-, 65- and 32,000-character values all read as unset and give 0 entries. 3 failures. So reintroducing the old limit makes the length cases fail, as the PR's control run also reports (7/8 under Wine). Findings 1. The length fix is correct (runtime/shims/gameinput.cpp:135-146). It uses the two-call `GetEnvironmentVariableA` pattern: first the size including the terminator, then a read into `std::string(need)`, then `n >= need` is rejected and the string is resized to `n`. Nothing overflows. The allocation is bounded by the Windows limit of 32,767 characters per variable, so this adds no unbounded allocation. An empty but set variable gives need = 1 and n = 0, so it reads as unset, as before. A value that grows between the two calls also reads as unset. That race is harmless and the old code had the same outcome. 2. The `env()` change affects every `LEONIDA_*` setting the shim reads, not only the script (gameinput.cpp:150-192). A value of 64 characters or more used to read as unset and is now parsed. All those parsers already accept arbitrary strings, so I see no risk. It is a behaviour change worth one line in the description. 3. Scope. The title says "read full-length scripts", but main has no `LEONIDA_INPUT_SCRIPT` at all (`git grep INPUT_SCRIPT origin/main` is empty). This PR adds the whole scheduler: parser, 300 ms presses, per-button OR with physical keys, and stderr logging (gameinput.cpp:1898-1946). The body says this, but the title could say "add keyboard pad input script" so the change log is accurate. 4. Malformed input is accepted silently (gameinput.cpp:1912-1921). Button names match exactly after lowercasing, so `zz@1` and `@2` are dropped. Leading spaces are also dropped: `" a@1"` is ignored, while the docs example has no spaces. The time is parsed with `std::atof` with no check, so `a@`, `a@x` and `a@abc` all schedule a press at 0 s. `a@1@2` gives a press at 1 s, `a@-1` never fires, `a@nan` never fires and `a@1e999` (inf) never fires. None of this is unsafe: everything is bounds-checked, and `press.button` is always one of the 12 table values, so `named[]` and `scripted[]` cannot be indexed out of range. But a typo like `a@` producing a press at start-up is surprising. Suggestion: use `strtod` with an end-pointer check, skip entries with a non-finite or negative time, and optionally log the count of rejected entries next to the existing "N scripted press(es)" line. 5. The test does not cover malformed input (runtime/test/gameinput_test.cpp:1719-1739). It covers a 76-character script, a press after byte 63, a later entry for the same button that must not cancel the earlier one, a held physical key, and release after 300 ms. Those are the right core cases. Nothing tests an unknown name, a missing or garbage time, or empty items (`,,`). One extra entry such as `zz@0,a@,` that asserts nothing extra is held would pin the parser behaviour. That check would currently fail for `a@`, because of finding 4. 6. Scripted presses ignore focus (gameinput.cpp:1871 and 1937). With `LEONIDA_KEYBOARD_PAD=1` and the window unfocused, `down[]` is all false, but the scripted buttons are still pressed. The comment at 1869 says out of focus "every button ... is released". For unattended runs this is probably what is wanted. The docs row should say so, or the code should gate on `active`. 7. The script is read once per process, on the first keyboard-pad update (the function-local static at gameinput.cpp:1903). `reload_config()` does not re-read it. The docs row says "set before starting", which is consistent, but "read once at start-up" would be clearer, since other rows in that table are re-read by `reload_config`. The test works around this by using a separate process mode. 8. The per-frame cost is O(number of entries) on each poll. That is fine even for the 8,000-entry worst case. 9. CMakeLists (runtime/CMakeLists.txt:1331): `gameinput_script` is added only inside `if(WIN32 AND TARGET gameinput_test)`. Builds without SDL3 are unchanged: they still list one `gameinput (Disabled)` placeholder, which I confirmed above. A matching disabled `gameinput_script` placeholder would make the skipped test visible, but that is optional. 10. Test timing: the press at 0 s is checked on the first poll, and release after `Sleep(350)` against a 300 ms window. `GetTickCount64` resolution is about 16 ms, so the margin is enough. Verdict: the length fix is correct and bounded, the merge is clean, and the docs table row is present and passes the docs test. I could not run the real test here (no SDL3). The standalone harness confirms the new reader handles long values, and that the old reader drops them. I would approve after the title or description reflects that this adds the scheduler. Rejecting malformed times (finding 4) plus a malformed-input test case (finding 5) are recommended but not blocking. Findings 6 and 7 are doc clarifications. AI-assisted.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 18:50 UTC · original · approved these changes

Reviewed and verified. Resolves truncation of LEONIDA_INPUT_SCRIPT environment variables exceeding 64 characters by querying actual length dynamically from the OS. Successfully schedules multi-stage button sequences with 300ms press duration. Validated with focused test cases in gameinput_test.cpp and docs/env_vars. 100% clean-room.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 18:50 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1074#pullrequestreview-6045347455) · **approved these changes** Reviewed and verified. Resolves truncation of LEONIDA_INPUT_SCRIPT environment variables exceeding 64 characters by querying actual length dynamically from the OS. Successfully schedules multi-stage button sequences with 300ms press duration. Validated with focused test cases in gameinput_test.cpp and docs/env_vars. 100% clean-room.
Author
Owner

@⁠Moriz82 on GitHub · 2026-11-24 18:57 UTC · original

Thank you for testing the script on native Windows. The 14/14 passing
runs and the 12/12 old-reader failures at longer lengths confirm the
boundary independently. Thank you also for reviewing the parser and
checking the build without SDL3.

  1. The size query and bounded second read are unchanged.
  2. The description now says the shared reader handles full-length values
    for every GameInput environment setting.
  3. The subject and body now describe the scheduler this commit adds to
    main, along with the full-length reader.
  4. The parser uses strtod, checks the end pointer and accepts only
    finite, nonnegative times. It trims whitespace around items and logs
    how many it accepted and rejected.
  5. The focused fixture includes an unknown button, empty items, missing
    and malformed times, non-finite and negative times, and a valid entry
    with padding. It checks the exact buttons held.
  6. The docs and code comment distinguish physical focus handling from
    scripted presses. The focused test checks that only X survives focus
    loss while the physical B key is still down.
  7. The docs identify the first keyboard pad update as the one-time read.
    The test checks that the original schedule survives an environment
    change and a call to reload_config().
  8. The per-poll traversal is unchanged.
  9. A Windows build without SDL3 lists both GameInput tests as disabled.
  10. The release check retains the 350 ms wait for the 300 ms press.

On the amended branch, the default run passed 364/364 and the focused
run passed 10/10, with 8 entries accepted and 11 rejected. Restoring
only the old reader gave 8/10. Both failures were the missing scripted X
before and after focus loss. Restoring only the old parser gave 7/10. It
missed the padded X and scheduled A from invalid entries. Both controls
exited 1. The documentation tests passed 4/4.

🤖 Generated with Claude Code

**@⁠Moriz82** on GitHub · 2026-11-24 18:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1074#issuecomment-7141393441) Thank you for testing the script on native Windows. The 14/14 passing runs and the 12/12 old-reader failures at longer lengths confirm the boundary independently. Thank you also for reviewing the parser and checking the build without SDL3. 1. The size query and bounded second read are unchanged. 2. The description now says the shared reader handles full-length values for every GameInput environment setting. 3. The subject and body now describe the scheduler this commit adds to main, along with the full-length reader. 4. The parser uses `strtod`, checks the end pointer and accepts only finite, nonnegative times. It trims whitespace around items and logs how many it accepted and rejected. 5. The focused fixture includes an unknown button, empty items, missing and malformed times, non-finite and negative times, and a valid entry with padding. It checks the exact buttons held. 6. The docs and code comment distinguish physical focus handling from scripted presses. The focused test checks that only X survives focus loss while the physical B key is still down. 7. The docs identify the first keyboard pad update as the one-time read. The test checks that the original schedule survives an environment change and a call to `reload_config()`. 8. The per-poll traversal is unchanged. 9. A Windows build without SDL3 lists both GameInput tests as disabled. 10. The release check retains the 350 ms wait for the 300 ms press. On the amended branch, the default run passed 364/364 and the focused run passed 10/10, with 8 entries accepted and 11 rejected. Restoring only the old reader gave 8/10. Both failures were the missing scripted X before and after focus loss. Restoring only the old parser gave 7/10. It missed the padded X and scheduled A from invalid entries. Both controls exited 1. The documentation tests passed 4/4. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 20:44 UTC · original

Merging.

Why merged: RT-INPUT-SCRIPT-LENGTH: the shim's env() reader now handles values of any length (64 characters or more used to read as unset). The PR also adds the LEONIDA_INPUT_SCRIPT keyboard-pad scheduler (button@seconds, 300 ms presses), documented in docs/gameinput.md. That's a second topic, but the body says so, and both parts were reviewed. sodove checked 14/14 runs across lengths, with the control failing 12/12, and kawaii-shakal's harness follow-ups were addressed.

Why it's good: gameinput_host, gameinput and the new gameinput_script pass; with validation, gameinput_script passes and logs "8 accepted / 11 rejected". The parsing is bounded (strtod with end-pointer and finiteness checks) and reads only its own env var.

Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #517, #907, #927, #954 and #1074 merged onto main 32a5d9698 (after aslan2142's runtime merges). There the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The 2 failures are d3d12_depth_resolve (pre-existing) and d3d12_close_parity, which fails on plain 32a5d9698 too: a regression from #510, reported there, not from these PRs. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠QemmHD** on GitHub · 2026-11-24 20:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1074#issuecomment-7143998858) Merging. **Why merged:** RT-INPUT-SCRIPT-LENGTH: the shim's env() reader now handles values of any length (64 characters or more used to read as unset). The PR also adds the LEONIDA_INPUT_SCRIPT keyboard-pad scheduler (`button@seconds`, 300 ms presses), documented in docs/gameinput.md. That's a second topic, but the body says so, and both parts were reviewed. sodove checked 14/14 runs across lengths, with the control failing 12/12, and kawaii-shakal's harness follow-ups were addressed. **Why it's good:** gameinput_host, gameinput and the new gameinput_script pass; with validation, gameinput_script passes and logs "8 accepted / 11 rejected". The parsing is bounded (strtod with end-pointer and finiteness checks) and reads only its own env var. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative: #517, #907, #927, #954 and #1074 merged onto main 32a5d9698 (after aslan2142's runtime merges). There the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The 2 failures are d3d12_depth_resolve (pre-existing) and d3d12_close_parity, which fails on plain 32a5d9698 too: a regression from #510, reported there, not from these PRs. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.