upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/gameinput.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-26 09:17:34 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-26 09:17:34 -0500
commit6d3904860e1b017fb95d44390fc8215f0da52110 (patch)
tree5118d8bb24b46f4c8c52617279a7b8c25184fd40 /runtime/shims/gameinput.cpp
parentcb825bb786b4db6dd5f6119de024c50f118e5b73 (diff)
parent7bd4cec0262e3cb4268f8b8b14299bae4d47b039 (diff)
Merge #2144 from klikso: a scripted press can be held longer, button@seconds:hold (INPUT-SCRIPT-HOLD)
Head 7bd4cec02. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/gameinput.cpp')
-rw-r--r--runtime/shims/gameinput.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/shims/gameinput.cpp b/runtime/shims/gameinput.cpp
index 454923457..5abb2a2fe 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;
@@ -1961,12 +1963,12 @@ void update_keyboard_pad() {
1961 for (std::size_t i = 0; i < scripted.presses.size(); ++i) { 1963 for (std::size_t i = 0; i < scripted.presses.size(); ++i) {
1962 const auto& press = scripted.presses[i]; 1964 const auto& press = scripted.presses[i];
1963 bool active = false; 1965 bool active = false;
1964 if (now >= press.at && now < press.at + kMaxHold) { 1966 if (now >= press.at && now < press.at + std::max(press.hold, kMaxHold)) {
1965 if (!started[i]) { 1967 if (!started[i]) {
1966 started[i] = 1; 1968 started[i] = 1;
1967 began[i] = calls; 1969 began[i] = calls;
1968 } 1970 }
1969 active = now < press.at + 0.3 || calls - began[i] < kReads; 1971 active = now < press.at + press.hold || calls - began[i] < kReads;
1970 } 1972 }
1971 if (!active) continue; 1973 if (!active) continue;
1972 if (press.stick) held.stick = press.stick; 1974 if (press.stick) held.stick = press.stick;