gameinput: a scripted press can be held longer, button@seconds:hold (INPUT-SCRIPT-HOLD) #2144

Manually merged
github merged 3 commits from github-bot/gh-2144 into main 2026-11-26 14:53:20 +00:00 AGit
Owner

@⁠klikso on GitHub · 2026-11-25 23:09 UTC · original
klikso:input/script-hold → main · +58 −31 · 7 files · 3 commits · merged 2026-11-26 14:41 UTC

Claimed in the coordination issue as: INPUT-SCRIPT-HOLD (claim)

What and why

A LEONIDA_INPUT_SCRIPT press is held for 0.3 s. The retail title reads its pad once a frame, and from the world start on a frame takes seconds here, so a 0.3 s press can start and end between two reads and never arrive. On an RTX 3060 Ti the title shows a "Couldn't autosave" prompt (Retry A / Got it B) about 1,000 s into a boot from a save:

  • three b presses at 1080, 1140 and 1200 s did nothing in 30 minutes (run r11);
  • 120 presses 0.5 s apart dismissed it (run r12).

An entry can now give its own hold, button@seconds:hold: b@1100:4 holds B for 4 s. Without :hold a press stays 0.3 s, so every existing script means what it did.

A hold of 0 or less, more than 600 s, or one that isn't a number (a@0:, a@0:x, a@0:inf, a@0:1tail) rejects the entry and is counted like any other rejected entry. The 600 s cap keeps a typo such as b@10:1100 from holding a button for the rest of the run. Right-stick throws (rsup, rsdown) take the same suffix. The parser is shared, so the SDL3 keyboard pad and the scripted pad of a build without SDL3 both get it. Since #2098 the SDL3 keyboard pad has its own loop: a press is held for 0.3 s, then until the title has read the pads six times, and never past 5 s. That loop now uses the entry's hold in place of the 0.3 s, and its 5 s limit becomes the hold when the hold is longer. Without :hold it behaves exactly as before. (Found by AndreiKocherzhinskiiA on #1608.)

Tested

Windows 11 26200, MSVC 19.44, main a73a57e13 plus the two commits.

  • gameinput_test --input-script (SDL3 build): 12 checks, 0 failures. New: y@0:0.6 is held with X at the first poll. Past 0.3 s, X is still held because the title has read the pads fewer than six times. After six more reads X ends while Y is still held for its 0.6 s. Y is released 0.4 s later. Seven malformed holds hold nothing. With the SDL3 loop in gameinput.cpp reverted to main's, 1 of these checks fails (Y ends with X).
  • gameinput_no_sdl_test --input-script (build without SDL3): 0 failures. New: b@3:0.8 holds B at 3.05 s and 3.7 s and releases it by 3.85 s; four malformed holds are rejected. With the header reverted, 2 fail.
  • gameinput_test and gameinput_no_sdl_test without the script argument: 364 checks and 0 failures respectively, unchanged.
  • Retail boot with this branch's runtime (run r13, my own 1.0.2.1, RTX 3060 Ti 8 GB, NVIDIA 621.14, scripts/windows-boot/boot.ps1 from a save, script a@120:2,a@150:2,a@180:2,b@1100:4,b@1130:4,b@1160:4):
    • all 6 entries are parsed (0 rejected);
    • the prompt is on screen at 1,075 s and gone by 1,145 s;
    • the run continues into the prologue at about one frame every 25 s.
      Three 4 s presses do what took 120 short ones.
  • python -I scripts/check_no_game_data.py on the 6 changed files: no hits. git diff --check: clean.

GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Windows 11 26200.

AI-assisted: yes (Claude Code; run and measured on the machine above)

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 (input shim, no translator change).

🤖 Generated with Claude Code

**@⁠klikso** on GitHub · 2026-11-25 23:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2144) `klikso:input/script-hold` → `main` · +58 −31 · 7 files · 3 commits · merged 2026-11-26 14:41 UTC Claimed in the coordination issue as: INPUT-SCRIPT-HOLD ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608)) ### What and why A `LEONIDA_INPUT_SCRIPT` press is held for 0.3 s. The retail title reads its pad once a frame, and from the world start on a frame takes seconds here, so a 0.3 s press can start and end between two reads and never arrive. On an RTX 3060 Ti the title shows a "Couldn't autosave" prompt (Retry A / Got it B) about 1,000 s into a boot from a save: - three `b` presses at 1080, 1140 and 1200 s did nothing in 30 minutes (run r11); - 120 presses 0.5 s apart dismissed it (run r12). An entry can now give its own hold, `button@seconds:hold`: `b@1100:4` holds B for 4 s. Without `:hold` a press stays 0.3 s, so every existing script means what it did. A hold of 0 or less, more than 600 s, or one that isn't a number (`a@0:`, `a@0:x`, `a@0:inf`, `a@0:1tail`) rejects the entry and is counted like any other rejected entry. The 600 s cap keeps a typo such as `b@10:1100` from holding a button for the rest of the run. Right-stick throws (`rsup`, `rsdown`) take the same suffix. The parser is shared, so the SDL3 keyboard pad and the scripted pad of a build without SDL3 both get it. Since #2098 the SDL3 keyboard pad has its own loop: a press is held for 0.3 s, then until the title has read the pads six times, and never past 5 s. That loop now uses the entry's hold in place of the 0.3 s, and its 5 s limit becomes the hold when the hold is longer. Without `:hold` it behaves exactly as before. (Found by AndreiKocherzhinskiiA on #1608.) ### Tested Windows 11 26200, MSVC 19.44, `main` `a73a57e13` plus the two commits. - `gameinput_test --input-script` (SDL3 build): 12 checks, 0 failures. New: `y@0:0.6` is held with X at the first poll. Past 0.3 s, X is still held because the title has read the pads fewer than six times. After six more reads X ends while Y is still held for its 0.6 s. Y is released 0.4 s later. Seven malformed holds hold nothing. With the SDL3 loop in `gameinput.cpp` reverted to main's, 1 of these checks fails (Y ends with X). - `gameinput_no_sdl_test --input-script` (build without SDL3): 0 failures. New: `b@3:0.8` holds B at 3.05 s and 3.7 s and releases it by 3.85 s; four malformed holds are rejected. With the header reverted, 2 fail. - `gameinput_test` and `gameinput_no_sdl_test` without the script argument: 364 checks and 0 failures respectively, unchanged. - **Retail boot with this branch's runtime** (run r13, my own 1.0.2.1, RTX 3060 Ti 8 GB, NVIDIA 621.14, `scripts/windows-boot/boot.ps1` from a save, script `a@120:2,a@150:2,a@180:2,b@1100:4,b@1130:4,b@1160:4`): - all 6 entries are parsed (0 rejected); - the prompt is on screen at 1,075 s and gone by 1,145 s; - the run continues into the prologue at about one frame every 25 s. Three 4 s presses do what took 120 short ones. - `python -I scripts/check_no_game_data.py` on the 6 changed files: no hits. `git diff --check`: clean. GPUs tested: NVIDIA GeForce RTX 3060 Ti (Ampere), driver 621.14, Windows 11 26200. AI-assisted: yes (Claude Code; run and measured on the machine above) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed: n/a (input shim, no translator change). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
At world-start frame rates the retail title reads its pad every few seconds,
so a 0.3 s scripted press falls between two reads and never arrives. An
entry may now give its own hold time; without one the press stays 0.3 s.
Holds of 0 or less, over 600 s or that are not a number reject the entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#2098 gave the SDL path its own loop (held 300 ms, then until the title
has read the pads six times, at most 5 s), which ignored button@seconds:hold.
A press now lasts its own hold, then the read latch, and never past 5 s or
its hold if longer. The long-script test checks both: X kept past 300 ms
until six reads, Y kept for its 0.6 s after them. It fails on the old loop.

Found by AndreiKocherzhinskiiA on #1608.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:20:02 +00:00
Author
Owner

@⁠JordanWebDev on GitHub · 2026-11-25 23:41 UTC · original · approved these changes

**@⁠JordanWebDev** on GitHub · 2026-11-25 23:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2144#pullrequestreview-6066538279) · **approved these changes**
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-26 07:24 UTC · original

Useful and mergeable, with two small documentation points. It is still needed after #2098 for any build without SDL3, and it adds a longer hold for SDL3 builds too. Its no-SDL3 test fails on main's source and passes with it. The SDL3 half of the PR was not built or run here.

Independent test report for this PR at head 1ce60558c. Main a73a57e13 is already an ancestor of the head (the author merged it), so the local merge was a no-op: no conflicts, no rebase, merge SHA = head. I fetched pull/2144/head again before concluding. It is still open, 2 commits, 6 files, no comments. The one review is an approval, given on an earlier commit (c85ed709), before the current head.

Configuration: Windows 11 Pro 10.0.26300, MSVC 19.44 (VS 2022), CMake + Ninja, RelWithDebInfo. Only the gameinput_no_sdl_test target was built. The build has no SDL3, so gameinput_test (ctest gameinput and gameinput_script) does not exist here and both are listed as Disabled. The game was not run.

Counts

  • Merge of the PR head with main: no conflicts.
  • ctest -R gameinput_no_sdl: 2/2 passed (gameinput_no_sdl and gameinput_no_sdl_script), 0 failures in each.
  • The script test now logs "5 scripted press(es), 7 rejected", as the test's comment says.
  • Not run: gameinput and gameinput_script (SDL3 keyboard pad). The PR's changes to gameinput_test.cpp, including the Y held 0.6 s, the malformed holds and the std::max(hold, kMaxHold) window, were read but never compiled or run.
  • check_no_game_data.py on the 6 modified files: exit 0.

Mutation (the PR's tests against main's source)

  • I put main's shims/gameinput_script.h back under the PR's gameinput_no_sdl_test.cpp and rebuilt. --input-script then reports 2 failures (the test prints the check names; the line numbers are where they sit in the source):
    • line 206, "b@3:0.8 holds B at 3.05 s".
    • lines 207-208, "B is still held at 3.7 s, past the 0.3 s default".
  • Main's parser rejects b@3:0.8 as trailing text, which gives 4 presses and 8 rejected.
  • The release check at line 209 passes on main by accident, because B is never pressed. It does not discriminate on its own.
  • I restored the file and rebuilt: 0 failures.

Reading

  • Still useful after #2098? Yes.
    • #2098 (kReads, kMaxHold) lives only in update_keyboard_pad() in gameinput.cpp, the SDL3 path.
    • The scripted pad without SDL3 (gameinput_no_sdl.cpp:379) is purely time-based, via held_at(). It has no read counting.
    • It also takes a reading only when a title asks for one and the state has changed. A 300 ms press that falls between two reads is therefore lost. On this machine, on a build without SDL3 averaging about 7 frames a second with longer stalls, single 300 ms presses did not always register and I had to double each press. I did not measure the gaps between reads, so the cause is inferred from the code.
    • On a build without SDL3, :hold is the only remedy. With SDL3, it adds a floor, so a long :hold also covers a title that stops reading.
  • Syntax:
    • button@seconds[:hold] is accepted, and : is parsed only right after the time.
    • Rejected: a@2:, a@2:x, a@2:0, a@2:-1, a@2:601, a@2:1tail, and a@2 :3 (space before the colon).
    • Accepted: trailing spaces and a@2:0.0001.
    • The bound is 0 < hold <= kMaxHoldSeconds (600), and nan/inf are rejected through isfinite.
    • Hex such as a@2:0x10 parses as 16, same as the existing time field. This is not a regression.
  • Overlap of two presses of the same button: held_at ORs the presses, so the button stays down until the later press ends. This is covered by the existing a@1 and [email protected] test. In the SDL path each press has its own started[i] and began[i], so they are independent.
  • Interaction with #2098: the SDL window becomes max(hold, kMaxHold).
    • For a default press the hold is 0.3, so the window stays at 5 s and behaviour is unchanged.
    • For :hold longer than 5 s the press is held at least that long. The PR documents this.
    • During its hold the press is down whatever the title reads. After it, the kReads rule still applies until kMaxHold.

Suggestions (non-blocking)

  1. scripts/windows-boot/boot.ps1 (.PARAMETER InputScript, header lines 51-54) is not touched. It still describes only button@seconds. A one-line mention of :hold is missing there.
  2. The new comment in gameinput_script.h has one line of 180 characters, where the rest of the file wraps near 120. This is cosmetic.

Not covered: the SDL3 keyboard-pad path (see Counts). No retail boot with this PR, and no check that b@1100:3 clears the autosave prompt; the docs sentence "three 300 ms b presses did nothing" is the author's. No full suite and no sanitizers.

AI-assisted: yes (Claude Code, Claude Sonnet 5.5, built and ran the tests; a second agent checked this text)

**@⁠MoonEyes** on GitHub · 2026-11-26 07:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2144#issuecomment-7185420994) Useful and mergeable, with two small documentation points. It is still needed after #2098 for any build without SDL3, and it adds a longer hold for SDL3 builds too. Its no-SDL3 test fails on main's source and passes with it. The SDL3 half of the PR was not built or run here. Independent test report for this PR at head `1ce60558c`. Main `a73a57e13` is already an ancestor of the head (the author merged it), so the local merge was a no-op: no conflicts, no rebase, merge SHA = head. I fetched `pull/2144/head` again before concluding. It is still open, 2 commits, 6 files, no comments. The one review is an approval, given on an earlier commit (`c85ed709`), before the current head. **Configuration:** Windows 11 Pro 10.0.26300, MSVC 19.44 (VS 2022), CMake + Ninja, RelWithDebInfo. Only the `gameinput_no_sdl_test` target was built. The build has no SDL3, so `gameinput_test` (ctest `gameinput` and `gameinput_script`) does not exist here and both are listed as Disabled. The game was not run. **Counts** - Merge of the PR head with main: no conflicts. - `ctest -R gameinput_no_sdl`: 2/2 passed (`gameinput_no_sdl` and `gameinput_no_sdl_script`), 0 failures in each. - The script test now logs "5 scripted press(es), 7 rejected", as the test's comment says. - Not run: `gameinput` and `gameinput_script` (SDL3 keyboard pad). The PR's changes to `gameinput_test.cpp`, including the Y held 0.6 s, the malformed holds and the `std::max(hold, kMaxHold)` window, were read but never compiled or run. - `check_no_game_data.py` on the 6 modified files: exit 0. **Mutation (the PR's tests against main's source)** - I put main's `shims/gameinput_script.h` back under the PR's `gameinput_no_sdl_test.cpp` and rebuilt. `--input-script` then reports 2 failures (the test prints the check names; the line numbers are where they sit in the source): - line 206, "b@3:0.8 holds B at 3.05 s". - lines 207-208, "B is still held at 3.7 s, past the 0.3 s default". - Main's parser rejects `b@3:0.8` as trailing text, which gives 4 presses and 8 rejected. - The release check at line 209 passes on main by accident, because B is never pressed. It does not discriminate on its own. - I restored the file and rebuilt: 0 failures. **Reading** - **Still useful after #2098?** Yes. - #2098 (`kReads`, `kMaxHold`) lives only in `update_keyboard_pad()` in `gameinput.cpp`, the SDL3 path. - The scripted pad without SDL3 (`gameinput_no_sdl.cpp:379`) is purely time-based, via `held_at()`. It has no read counting. - It also takes a reading only when a title asks for one and the state has changed. A 300 ms press that falls between two reads is therefore lost. On this machine, on a build without SDL3 averaging about 7 frames a second with longer stalls, single 300 ms presses did not always register and I had to double each press. I did not measure the gaps between reads, so the cause is inferred from the code. - On a build without SDL3, `:hold` is the only remedy. With SDL3, it adds a floor, so a long `:hold` also covers a title that stops reading. - **Syntax:** - `button@seconds[:hold]` is accepted, and `:` is parsed only right after the time. - Rejected: `a@2:`, `a@2:x`, `a@2:0`, `a@2:-1`, `a@2:601`, `a@2:1tail`, and `a@2 :3` (space before the colon). - Accepted: trailing spaces and `a@2:0.0001`. - The bound is `0 < hold <= kMaxHoldSeconds` (600), and `nan`/`inf` are rejected through `isfinite`. - Hex such as `a@2:0x10` parses as 16, same as the existing time field. This is not a regression. - **Overlap of two presses of the same button:** `held_at` ORs the presses, so the button stays down until the later press ends. This is covered by the existing `a@1` and `[email protected]` test. In the SDL path each press has its own `started[i]` and `began[i]`, so they are independent. - **Interaction with #2098:** the SDL window becomes `max(hold, kMaxHold)`. - For a default press the hold is 0.3, so the window stays at 5 s and behaviour is unchanged. - For `:hold` longer than 5 s the press is held at least that long. The PR documents this. - During its hold the press is down whatever the title reads. After it, the `kReads` rule still applies until `kMaxHold`. **Suggestions (non-blocking)** 1. `scripts/windows-boot/boot.ps1` (`.PARAMETER InputScript`, header lines 51-54) is not touched. It still describes only `button@seconds`. A one-line mention of `:hold` is missing there. 2. The new comment in `gameinput_script.h` has one line of 180 characters, where the rest of the file wraps near 120. This is cosmetic. **Not covered:** the SDL3 keyboard-pad path (see Counts). No retail boot with this PR, and no check that `b@1100:3` clears the autosave prompt; the docs sentence "three 300 ms b presses did nothing" is the author's. No full suite and no sanitizers. AI-assisted: yes (Claude Code, Claude Sonnet 5.5, built and ran the tests; a second agent checked this text)
Review follow-up (MoonEyes): the InputScript help in boot.ps1 now says
each press is held 300 ms and that button@seconds:hold holds it longer.
The header comment in gameinput_script.h is wrapped at 120 like the rest
of the file. Comments only; no code change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠klikso on GitHub · 2026-11-26 13:09 UTC · original

Thanks @⁠MoonEyes for the independent run and the mutation check. Both suggestions are in 7bd4cec02 (comments only, no code change):

  1. boot.ps1's InputScript help now says each press is held 300 ms and that button@seconds:hold holds it longer (e.g. b@1100:3).
  2. The header comment in gameinput_script.h is rewrapped at 120 like the rest of the file.

The SDL3 path (gameinput and gameinput_script) was built and run here before the push: 12 checks, 0 failures, and 1 failure with main's loop.

AI-assisted (Claude Code).

**@⁠klikso** on GitHub · 2026-11-26 13:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2144#issuecomment-7192955744) Thanks @⁠MoonEyes for the independent run and the mutation check. Both suggestions are in 7bd4cec02 (comments only, no code change): 1. `boot.ps1`'s `InputScript` help now says each press is held 300 ms and that `button@seconds:hold` holds it longer (e.g. `b@1100:3`). 2. The header comment in `gameinput_script.h` is rewrapped at 120 like the rest of the file. The SDL3 path (`gameinput` and `gameinput_script`) was built and run here before the push: 12 checks, 0 failures, and 1 failure with main's loop. AI-assisted (Claude Code).
github manually merged commit 6d3904860e into main 2026-11-26 14:53:20 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-26 14:42 UTC · original

Thank you, @⁠klikso. This went into main through #2350 (RT-LINUX-AMD-WORLD), merged at your head 7bd4cec02 with your commits and authorship kept. GitHub shows this PR as merged for that reason, so nothing needs closing.

AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)

**@⁠aslan2142** on GitHub · 2026-11-26 14:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2144#issuecomment-7195198777) Thank you, @⁠klikso. This went into `main` through #2350 (RT-LINUX-AMD-WORLD), merged at your head `7bd4cec02` with your commits and authorship kept. GitHub shows this PR as merged for that reason, so nothing needs closing. AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)
This discussion has been locked. Commenting is limited to contributors.
No description provided.