From 9ea22eaf446b50f03d600bc2f5f1e6c4afb09788 Mon Sep 17 00:00:00 2001 From: quartz-heron-58 <245169279+quartz-heron-58@users.noreply.github.com> Date: Thu, 26 Nov 2026 08:28:59 +0800 Subject: [PATCH] gameinput test: read the pad before expecting a scripted press to end (TEST-GAMEINPUT-SCRIPT-READS) Since #2098 a scripted press lasts its 300 ms and then until the title has made six GetCurrentReading calls since it began. gameinput_test --input-script still expected the press to be over after 350 ms and three reads, so ctest gameinput_script failed on main in every build with SDL3 (it is disabled without SDL3, so CI did not show it). The test now checks that the press is still held at that point, reads the pad six more times and then expects the release. Test only. Co-Authored-By: Claude Fable 5.2 --- runtime/test/gameinput_test.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp index b6658f51cd..be9dc53984 100644 --- a/runtime/test/gameinput_test.cpp +++ b/runtime/test/gameinput_test.cpp @@ -1742,8 +1742,15 @@ int main(int argc, char** argv) { Sleep(350); g_focus = true; rt::gameinput::poll(); + // A scripted press lasts its 300 ms and then until the title has read the pads six times since it began + // (update_keyboard_pad: kReads, at most kMaxHold seconds), so a title that polls slowly still sees it. Each + // pad_state() is one GetCurrentReading, and this is the third since the X began. + check(pad_state(input, nullptr).buttons == (GameInputGamepadX | GameInputGamepadB), + "long script: past its 300 ms the press is still held while the title has read the pads fewer than six times"); + for (int i = 0; i < 6; ++i) pad_state(input, nullptr); + rt::gameinput::poll(); check(pad_state(input, nullptr).buttons == GameInputGamepadB, - "long script: the timed press ends while the physical key stays held"); + "long script: the timed press ends once the title has read it, while the physical key stays held"); input->Release(); std::printf("%d checks, %d failures\n", g_checks, g_failures); return g_failures ? 1 : 0;