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:
authorkawaii-shakal <deusex1998@gmail.com>2026-11-25 08:31:50 +0500
committerkawaii-shakal <deusex1998@gmail.com>2026-11-25 08:31:50 +0500
commitd4d969a1fdc4bf8026017ab52d0a5d03c7737be6 (patch)
tree68c4c8b47997166ee446b368bb60f8ce72ff5005 /runtime/test/gameinput_test.cpp
parent0bc810504aa44ba7e30f3c3352ebad697b9814d6 (diff)
make_game, gameinput: controller, keyboard and mouse input out of the box (INPUT-OUT-OF-THE-BOX)
A build made with make_game.py on Windows had no input at all. The runtime stage ran scripts/build_runtime.ps1 without -FetchSdl3, so on a machine without an installed SDL3 the GameInput shim was not built. gta6rt then logged "served without SDL3 (no devices)", and a connected DualSense or Xbox pad did nothing. - make_game.py: the Windows runtime stage passes -FetchSdl3 (the pinned SDL3 3.4.20, SHA-256 checked by CMake). --no-sdl3 leaves the download out. The docstring's "what it downloads" sentence names it. - gameinput: LEONIDA_KEYBOARD_PAD defaults to the focused mode, so a player without a pad still has the keyboard and mouse. Keys count only while the game window has focus. "off" or "0" removes the pad. - gameinput_test: the other cases set LEONIDA_KEYBOARD_PAD=off, as they count only their own virtual pads. The keyboard pad case checks the new default. - docs/gameinput.md: default and make_game behaviour. 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.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/runtime/test/gameinput_test.cpp b/runtime/test/gameinput_test.cpp
index b6658f51c..ea72970e3 100644
--- a/runtime/test/gameinput_test.cpp
+++ b/runtime/test/gameinput_test.cpp
@@ -812,10 +812,15 @@ void test_keyboard_pad(IGameInput* input) {
812 rt::gameinput::set_keyboard_source(fake_key_down, fake_focus); 812 rt::gameinput::set_keyboard_source(fake_key_down, fake_focus);
813 rt::gameinput::set_cursor_source(fake_cursor); 813 rt::gameinput::set_cursor_source(fake_cursor);
814 814
815 // On by default (focused): a player without a pad still has the keyboard and mouse.
815 set_env("LEONIDA_KEYBOARD_PAD", nullptr); 816 set_env("LEONIDA_KEYBOARD_PAD", nullptr);
816 rt::gameinput::reload_config(); 817 rt::gameinput::reload_config();
818 check(rt::gameinput::config().keyboard_pad == rt::gameinput::KeyboardPadMode::Focused,
819 "keyboard pad: the focused mode by default");
820 set_env("LEONIDA_KEYBOARD_PAD", "off");
821 rt::gameinput::reload_config();
817 rt::gameinput::poll(); 822 rt::gameinput::poll();
818 check(rt::gameinput::connected_count() == 0, "keyboard pad: off by default"); 823 check(rt::gameinput::connected_count() == 0, "keyboard pad: off with LEONIDA_KEYBOARD_PAD=off");
819 824
820 set_env("LEONIDA_KEYBOARD_PAD", "1"); 825 set_env("LEONIDA_KEYBOARD_PAD", "1");
821 rt::gameinput::reload_config(); 826 rt::gameinput::reload_config();
@@ -916,7 +921,7 @@ void test_keyboard_pad(IGameInput* input) {
916 (kb->GetDeviceStatus() & GameInputDeviceConnected), 921 (kb->GetDeviceStatus() & GameInputDeviceConnected),
917 "keyboard pad: on again is the same device object"); 922 "keyboard pad: on again is the same device object");
918 923
919 set_env("LEONIDA_KEYBOARD_PAD", nullptr); 924 set_env("LEONIDA_KEYBOARD_PAD", "off");
920 rt::gameinput::reload_config(); 925 rt::gameinput::reload_config();
921 rt::gameinput::poll(); 926 rt::gameinput::poll();
922 check(rt::gameinput::connected_count() == 0, "keyboard pad: removed at the end"); 927 check(rt::gameinput::connected_count() == 0, "keyboard pad: removed at the end");
@@ -1063,7 +1068,7 @@ void test_active_input() {
1063 // Clean up: everything off and unplugged. 1068 // Clean up: everything off and unplugged.
1064 set_env("LEONIDA_PROMPTS", nullptr); 1069 set_env("LEONIDA_PROMPTS", nullptr);
1065 set_env("LEONIDA_PROMPTS_SWITCH_MS", nullptr); 1070 set_env("LEONIDA_PROMPTS_SWITCH_MS", nullptr);
1066 set_env("LEONIDA_KEYBOARD_PAD", nullptr); 1071 set_env("LEONIDA_KEYBOARD_PAD", "off");
1067 rt::gameinput::reload_config(); 1072 rt::gameinput::reload_config();
1068 detach(ds); 1073 detach(ds);
1069 detach(ds4); 1074 detach(ds4);
@@ -1699,7 +1704,8 @@ int main(int argc, char** argv) {
1699 SDL_HINT_JOYSTICK_GAMEINPUT, SDL_HINT_XINPUT_ENABLED, SDL_HINT_JOYSTICK_DIRECTINPUT}) 1704 SDL_HINT_JOYSTICK_GAMEINPUT, SDL_HINT_XINPUT_ENABLED, SDL_HINT_JOYSTICK_DIRECTINPUT})
1700 SDL_SetHintWithPriority(hint, "0", SDL_HINT_OVERRIDE); 1705 SDL_SetHintWithPriority(hint, "0", SDL_HINT_OVERRIDE);
1701 set_env("LEONIDA_GAMEINPUT_THREAD", "0"); 1706 set_env("LEONIDA_GAMEINPUT_THREAD", "0");
1702 set_env("LEONIDA_KEYBOARD_PAD", nullptr); 1707 // The keyboard pad is on by default; the other tests count only their own virtual pads.
1708 set_env("LEONIDA_KEYBOARD_PAD", "off");
1703 set_env("LEONIDA_INPUT_SCRIPT", nullptr); 1709 set_env("LEONIDA_INPUT_SCRIPT", nullptr);
1704 set_env("LEONIDA_DS_TRIGGERS", nullptr); 1710 set_env("LEONIDA_DS_TRIGGERS", nullptr);
1705 set_env("LEONIDA_DS_LIGHTBAR", nullptr); 1711 set_env("LEONIDA_DS_LIGHTBAR", nullptr);