From 75c12dbe7d091856872da26abb01547cc3a4a0e0 Mon Sep 17 00:00:00 2001 From: Sjoerd de Bruin Date: Sun, 13 Sep 2026 15:21:11 +0200 Subject: [PATCH] Fix #27070: Gate polled input on window focus (#27078) --- distribution/changelog.txt | 1 + src/openrct2-ui/input/InputManager.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 94bfb2535f..92b36913fd 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -12,6 +12,7 @@ - Fix: [#26754] Switching window tabs by touch could crash the game on some Linux builds. - Fix: [#27052] Unnamed rides in RCT2 base and Wacky Worlds scenarios have hardcoded English names. - Fix: [#27056] [Plugin] Loading water palettes from plugin does not update the palette correctly. +- Fix: [#27070] The game keeps responding to input while the window is not focused (primarily gamepads). - Fix: [#27084] [Plugin] `PermissionType` for `drag_path_area` is missing. - Fix: [#27087] The ‘Update available’ widget is offset incorrectly. - Fix: [#27093] Pause and fast forward buttons are shown in multiplayer. diff --git a/src/openrct2-ui/input/InputManager.cpp b/src/openrct2-ui/input/InputManager.cpp index 4ce8f86d99..a87e5f2b31 100644 --- a/src/openrct2-ui/input/InputManager.cpp +++ b/src/openrct2-ui/input/InputManager.cpp @@ -141,6 +141,9 @@ void InputManager::processAnalogueInput() _analogueScroll.x = 0; _analogueScroll.y = 0; + if (!ContextHasFocus()) + return; + const int32_t deadzone = Config::Get().general.gamepadDeadzone; const float sensitivity = Config::Get().general.gamepadSensitivity; @@ -448,6 +451,11 @@ void InputManager::processChat(const InputEvent& e) void InputManager::processHoldEvents() { + _viewScroll = { 0, 0 }; + + if (!ContextHasFocus()) + return; + // Get mouse state _mouseState = SDL_GetMouseState(nullptr, nullptr); @@ -458,9 +466,6 @@ void InputManager::processHoldEvents() std::memcpy(_keyboardState.data(), keys, numkeys); // Check view scroll shortcuts - _viewScroll.x = 0; - _viewScroll.y = 0; - if (!hasTextInputFocus()) { auto& shortcutManager = GetShortcutManager();