upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/test/gameinput_test.cpp
diff options
context:
space:
mode:
authorklikso <204526810+klikso@users.noreply.github.com>2026-11-26 01:00:51 +0000
committerklikso <204526810+klikso@users.noreply.github.com>2026-11-26 04:58:19 +0000
commit1ce60558c72770e881a4ef458e125f587b66022e (patch)
treefa483e2119927221f12a87bcb1c54a4ec639f901 /runtime/test/gameinput_test.cpp
parentf0e79141a41b63e737560fbd4a051e3ab34dad7d (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/test/gameinput_test.cpp')
-rw-r--r--runtime/test/gameinput_test.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp
index 42a59e764..09d959f34 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -1745,11 +1745,19 @@ int main(int argc, char** argv) {
1745 Sleep(350); 1745 Sleep(350);
1746 g_focus = true; 1746 g_focus = true;
1747 rt::gameinput::poll(); 1747 rt::gameinput::poll();
1748 // A scripted press lasts its hold (300 ms, or button@seconds:hold) and then until the title has read the pads
1749 // six times since it began (update_keyboard_pad: kReads), so a title that polls slowly still sees it. Each
1750 // pad_state() is one GetCurrentReading, and this is the third since X and Y began.
1751 check(pad_state(input, nullptr).buttons == (GameInputGamepadX | GameInputGamepadB | GameInputGamepadY),
1752 "long script: past its 300 ms X is still held while the title has read the pads fewer than six times");
1753 for (int i = 0; i < 6; ++i) pad_state(input, nullptr);
1754 rt::gameinput::poll();
1748 check(pad_state(input, nullptr).buttons == (GameInputGamepadB | GameInputGamepadY), 1755 check(pad_state(input, nullptr).buttons == (GameInputGamepadB | GameInputGamepadY),
1749 "long script: X's 0.3 s press ends, y@0:0.6 is still held, the physical key stays held"); 1756 "long script: X ends once the title has read it, y@0:0.6 is still held for its time, the key stays held");
1750 Sleep(400); 1757 Sleep(400);
1751 rt::gameinput::poll(); 1758 rt::gameinput::poll();
1752 check(pad_state(input, nullptr).buttons == GameInputGamepadB, "long script: Y is released after its 0.6 s hold"); 1759 check(pad_state(input, nullptr).buttons == GameInputGamepadB,
1760 "long script: Y is released after its 0.6 s hold, the title having read it six times");
1753 input->Release(); 1761 input->Release();
1754 std::printf("%d checks, %d failures\n", g_checks, g_failures); 1762 std::printf("%d checks, %d failures\n", g_checks, g_failures);
1755 return g_failures ? 1 : 0; 1763 return g_failures ? 1 : 0;