diff options
| author | klikso <204526810+klikso@users.noreply.github.com> | 2026-11-26 01:00:51 +0000 |
|---|---|---|
| committer | klikso <204526810+klikso@users.noreply.github.com> | 2026-11-26 04:58:19 +0000 |
| commit | 1ce60558c72770e881a4ef458e125f587b66022e (patch) | |
| tree | fa483e2119927221f12a87bcb1c54a4ec639f901 /runtime/shims/gameinput.cpp | |
| parent | f0e79141a41b63e737560fbd4a051e3ab34dad7d (diff) | |
gameinput: the SDL keyboard pad honours a scripted hold too
#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 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/gameinput.cpp')
| -rw-r--r-- | runtime/shims/gameinput.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/shims/gameinput.cpp b/runtime/shims/gameinput.cpp index fa5889d6a..3a66fd2fa 100644 --- a/runtime/shims/gameinput.cpp +++ b/runtime/shims/gameinput.cpp | |||
| @@ -1887,7 +1887,9 @@ void update_keyboard_pad() { | |||
| 1887 | clip_cursor(active && g_raw_ready && g_cursor_pos.load() == system_cursor_pos && foreground_is_ours()); | 1887 | clip_cursor(active && g_raw_ready && g_cursor_pos.load() == system_cursor_pos && foreground_is_ours()); |
| 1888 | for (const auto& b : kKeyBindings) SDL_SetJoystickVirtualButton(g_keyboard.js, b.sdl_button, down[b.sdl_button]); | 1888 | for (const auto& b : kKeyBindings) SDL_SetJoystickVirtualButton(g_keyboard.js, b.sdl_button, down[b.sdl_button]); |
| 1889 | // LEONIDA_INPUT_SCRIPT="a@70,a@85,start@120" (with LEONIDA_KEYBOARD_PAD=always): timed presses on the keyboard | 1889 | // LEONIDA_INPUT_SCRIPT="a@70,a@85,start@120" (with LEONIDA_KEYBOARD_PAD=always): timed presses on the keyboard |
| 1890 | // pad, in seconds since the pad's first update, each held 300 ms. For unattended boots: the title's first prompt | 1890 | // pad, in seconds since the pad's first update, each held 300 ms or its own button@seconds:hold, and then until the |
| 1891 | // title has read the pads kReads times since it began (never past kMaxHold seconds, or the hold if it is longer, so | ||
| 1892 | // a title that stops reading does not keep the button). For unattended boots: the title's first prompt | ||
| 1891 | // waits for a button with no timeout (docs/re/notes/firstframe.md, step 5). The parser, the timeline and the | 1893 | // waits for a button with no timeout (docs/re/notes/firstframe.md, step 5). The parser, the timeline and the |
| 1892 | // button names are gameinput_script.h's, shared with the scripted pad of a build without SDL3. | 1894 | // button names are gameinput_script.h's, shared with the scripted pad of a build without SDL3. |
| 1893 | namespace script = rt::gameinput::script; | 1895 | namespace script = rt::gameinput::script; |
| @@ -1911,12 +1913,12 @@ void update_keyboard_pad() { | |||
| 1911 | for (std::size_t i = 0; i < scripted.presses.size(); ++i) { | 1913 | for (std::size_t i = 0; i < scripted.presses.size(); ++i) { |
| 1912 | const auto& press = scripted.presses[i]; | 1914 | const auto& press = scripted.presses[i]; |
| 1913 | bool active = false; | 1915 | bool active = false; |
| 1914 | if (now >= press.at && now < press.at + kMaxHold) { | 1916 | if (now >= press.at && now < press.at + std::max(press.hold, kMaxHold)) { |
| 1915 | if (!started[i]) { | 1917 | if (!started[i]) { |
| 1916 | started[i] = 1; | 1918 | started[i] = 1; |
| 1917 | began[i] = calls; | 1919 | began[i] = calls; |
| 1918 | } | 1920 | } |
| 1919 | active = now < press.at + 0.3 || calls - began[i] < kReads; | 1921 | active = now < press.at + press.hold || calls - began[i] < kReads; |
| 1920 | } | 1922 | } |
| 1921 | if (!active) continue; | 1923 | if (!active) continue; |
| 1922 | if (press.stick) held.stick = press.stick; | 1924 | if (press.stick) held.stick = press.stick; |