diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-26 16:55:04 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-26 16:55:04 -0500 |
| commit | df92abca8ee2a8f9093efea7fcaa4dadc3ddaebc (patch) | |
| tree | 97ef8f95544fe263049d3f7360823f16100de209 /runtime/test/gameinput_test.cpp | |
| parent | 49a0b69fcdb80db1f2a44ce7ca0ab8dfdec1e403 (diff) | |
| parent | e5a7c8942678b323f655939c81f5d8855d20c248 (diff) | |
Merge main e5a7c8942 into shadow-aliased-guard (#1867)
One conflict, runtime/README.md: this branch rewrote the LEONIDA_SHADOW_ALIAS_MS
row, main (#2163) added the LEONIDA_SHADOW_KEEP row after it. Both rows kept;
the keep row's "aliased" now reads "aliased while they can't be guarded at every
address", since aliased pages are no longer copied without a sign of a write.
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.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp index be9dc5398..09d959f34 100644 --- a/runtime/test/gameinput_test.cpp +++ b/runtime/test/gameinput_test.cpp | |||
| @@ -1718,10 +1718,12 @@ int main(int argc, char** argv) { | |||
| 1718 | check(create(&input) == S_OK && input, "GameInputCreate returns an instance"); | 1718 | check(create(&input) == S_OK && input, "GameInputCreate returns an instance"); |
| 1719 | if (argc == 2 && std::strcmp(argv[1], "--input-script") == 0) { | 1719 | if (argc == 2 && std::strcmp(argv[1], "--input-script") == 0) { |
| 1720 | if (!input) return 1; | 1720 | if (!input) return 1; |
| 1721 | // Only the X after byte 63 is due now. Its later entry must not cancel it. | 1721 | // Only the X after byte 63 and the Y held 0.6 s are due now. X's later entry must not cancel it; the |
| 1722 | // malformed holds at the end hold nothing. | ||
| 1722 | set_env("LEONIDA_INPUT_SCRIPT", | 1723 | set_env("LEONIDA_INPUT_SCRIPT", |
| 1723 | "start@3600,start@3600,start@3600,start@3600,start@3600,start@3600, X@0 \t,x@3600," | 1724 | "start@3600,start@3600,start@3600,start@3600,start@3600,start@3600, X@0 \t,x@3600," |
| 1724 | "unknown@0,a@,a@x,,a@-0.1,a@nan,a@inf,a@1e999,a@0tail, ,"); | 1725 | "unknown@0,a@,a@x,,a@-0.1,a@nan,a@inf,a@1e999,a@0tail, ,y@0:0.6," |
| 1726 | "a@0:0,a@0:-1,a@0:,a@0:x,a@0:inf,a@0:601,a@0:1tail"); | ||
| 1725 | set_env("LEONIDA_KEYBOARD_PAD", "1"); | 1727 | set_env("LEONIDA_KEYBOARD_PAD", "1"); |
| 1726 | rt::gameinput::set_keyboard_source(fake_key_down, fake_focus); | 1728 | rt::gameinput::set_keyboard_source(fake_key_down, fake_focus); |
| 1727 | rt::gameinput::set_cursor_source(fake_cursor); | 1729 | rt::gameinput::set_cursor_source(fake_cursor); |
| @@ -1730,27 +1732,32 @@ int main(int argc, char** argv) { | |||
| 1730 | rt::gameinput::reload_config(); | 1732 | rt::gameinput::reload_config(); |
| 1731 | rt::gameinput::poll(); | 1733 | rt::gameinput::poll(); |
| 1732 | const auto buttons = pad_state(input, nullptr).buttons; | 1734 | const auto buttons = pad_state(input, nullptr).buttons; |
| 1733 | const auto expected = GameInputGamepadX | GameInputGamepadB; | 1735 | const auto expected = GameInputGamepadX | GameInputGamepadB | GameInputGamepadY; |
| 1734 | check((buttons & expected) == expected, "long script: the spaced X after byte 63 and the physical B are held"); | 1736 | check((buttons & expected) == expected, |
| 1737 | "long script: the spaced X after byte 63, the held Y and the physical B are held"); | ||
| 1735 | check((buttons & ~expected) == 0, "malformed script entries hold no extra buttons"); | 1738 | check((buttons & ~expected) == 0, "malformed script entries hold no extra buttons"); |
| 1736 | g_focus = false; | 1739 | g_focus = false; |
| 1737 | set_env("LEONIDA_INPUT_SCRIPT", "y@0"); | 1740 | set_env("LEONIDA_INPUT_SCRIPT", "y@0"); |
| 1738 | rt::gameinput::reload_config(); | 1741 | rt::gameinput::reload_config(); |
| 1739 | rt::gameinput::poll(); | 1742 | rt::gameinput::poll(); |
| 1740 | check(pad_state(input, nullptr).buttons == GameInputGamepadX, | 1743 | check(pad_state(input, nullptr).buttons == (GameInputGamepadX | GameInputGamepadY), |
| 1741 | "scripted X survives focus loss; reload does not replace it with Y"); | 1744 | "scripted X and Y survive focus loss; reload does not replace the script with y@0"); |
| 1742 | Sleep(350); | 1745 | Sleep(350); |
| 1743 | g_focus = true; | 1746 | g_focus = true; |
| 1744 | rt::gameinput::poll(); | 1747 | rt::gameinput::poll(); |
| 1745 | // A scripted press lasts its 300 ms and then until the title has read the pads six times since it began | 1748 | // A scripted press lasts its hold (300 ms, or button@seconds:hold) and then until the title has read the pads |
| 1746 | // (update_keyboard_pad: kReads, at most kMaxHold seconds), so a title that polls slowly still sees it. Each | 1749 | // six times since it began (update_keyboard_pad: kReads), so a title that polls slowly still sees it. Each |
| 1747 | // pad_state() is one GetCurrentReading, and this is the third since the X began. | 1750 | // pad_state() is one GetCurrentReading, and this is the third since X and Y began. |
| 1748 | check(pad_state(input, nullptr).buttons == (GameInputGamepadX | GameInputGamepadB), | 1751 | check(pad_state(input, nullptr).buttons == (GameInputGamepadX | GameInputGamepadB | GameInputGamepadY), |
| 1749 | "long script: past its 300 ms the press is still held while the title has read the pads fewer than six times"); | 1752 | "long script: past its 300 ms X is still held while the title has read the pads fewer than six times"); |
| 1750 | for (int i = 0; i < 6; ++i) pad_state(input, nullptr); | 1753 | for (int i = 0; i < 6; ++i) pad_state(input, nullptr); |
| 1751 | rt::gameinput::poll(); | 1754 | rt::gameinput::poll(); |
| 1755 | check(pad_state(input, nullptr).buttons == (GameInputGamepadB | GameInputGamepadY), | ||
| 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"); | ||
| 1757 | Sleep(400); | ||
| 1758 | rt::gameinput::poll(); | ||
| 1752 | check(pad_state(input, nullptr).buttons == GameInputGamepadB, | 1759 | check(pad_state(input, nullptr).buttons == GameInputGamepadB, |
| 1753 | "long script: the timed press ends once the title has read it, while the physical key stays held"); | 1760 | "long script: Y is released after its 0.6 s hold, the title having read it six times"); |
| 1754 | input->Release(); | 1761 | input->Release(); |
| 1755 | std::printf("%d checks, %d failures\n", g_checks, g_failures); | 1762 | std::printf("%d checks, %d failures\n", g_checks, g_failures); |
| 1756 | return g_failures ? 1 : 0; | 1763 | return g_failures ? 1 : 0; |