From 861f724d90c0bfbec373f4c6e5f9cd9a1f698c97 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 21 Jan 2024 15:49:16 -0800 Subject: [PATCH] Recompute textboxes on active input device change This fixes a bug where some text boxes wouldn't update the displayed button if the active input device changed from a keyboard to controller, or vice versa. Namely, the "Press ACTION to continue" text boxes. --- desktop_version/src/KeyPoll.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/KeyPoll.cpp b/desktop_version/src/KeyPoll.cpp index b1771fc8..d6f400ab 100644 --- a/desktop_version/src/KeyPoll.cpp +++ b/desktop_version/src/KeyPoll.cpp @@ -153,6 +153,9 @@ void KeyPoll::Poll(void) bool fullscreenkeybind = false; SDL_GameController *controller = NULL; SDL_Event evt; + bool should_recompute_textboxes = false; + bool active_input_device_changed = false; + bool keyboard_was_active = BUTTONGLYPHS_keyboard_is_active(); while (SDL_PollEvent(&evt)) { switch (evt.type) @@ -206,7 +209,7 @@ void KeyPoll::Poll(void) loc::loadtext(false); graphics.grphx.init_translations(); - recomputetextboxes(); + should_recompute_textboxes = true; } } else @@ -514,6 +517,13 @@ void KeyPoll::Poll(void) mousex = raw_mousex; mousey = raw_mousey; } + + active_input_device_changed = keyboard_was_active != BUTTONGLYPHS_keyboard_is_active(); + should_recompute_textboxes |= active_input_device_changed; + if (should_recompute_textboxes) + { + recomputetextboxes(); + } } bool KeyPoll::isDown(SDL_Keycode key)