From 3147aea0edbbc5f1d01bef24bbf138afb9774cc7 Mon Sep 17 00:00:00 2001 From: Andrew Lanzone Date: Sat, 2 Aug 2025 09:00:59 -0700 Subject: [PATCH] Better dead zone handling --- apps/openmw/mwgui/race.cpp | 3 +-- apps/openmw/mwinput/controllermanager.cpp | 12 +++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index a4125cfbdd..193c409ab7 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -511,8 +511,7 @@ namespace MWGui { if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTX) { - if (arg.value < -1000 || arg.value > 1000) - onPreviewScroll(nullptr, arg.value < 0 ? 1 : -1); + onPreviewScroll(nullptr, arg.value < 0 ? 1 : -1); return true; } diff --git a/apps/openmw/mwinput/controllermanager.cpp b/apps/openmw/mwinput/controllermanager.cpp index c31fd0f3a5..f32bf741db 100644 --- a/apps/openmw/mwinput/controllermanager.cpp +++ b/apps/openmw/mwinput/controllermanager.cpp @@ -355,22 +355,25 @@ namespace MWInput MWGui::WindowBase* topWin = winMgr->getActiveControllerWindow(); if (topWin) { - bool isPastDeadzone = std::abs(arg.value) > 2000; // Update cursor state mGamepadGuiCursorEnabled = topWin->isGamepadCursorAllowed(); if (!mGamepadGuiCursorEnabled) winMgr->setCursorActive(false); + // Deadzone check + if (std::abs(arg.value) < 2000) + return !mGamepadGuiCursorEnabled; + if (mGamepadGuiCursorEnabled && (arg.axis == SDL_CONTROLLER_AXIS_LEFTX || arg.axis == SDL_CONTROLLER_AXIS_LEFTY)) { // Treat the left stick like a cursor, which is the default behavior. - if (isPastDeadzone && winMgr->getControllerTooltip()) + if (winMgr->getControllerTooltip()) { winMgr->setControllerTooltip(false); winMgr->setCursorVisible(true); } - else if (isPastDeadzone && mGamepadGuiCursorEnabled) + else if (mGamepadGuiCursorEnabled) { winMgr->setCursorVisible(true); } @@ -378,8 +381,7 @@ namespace MWInput } // Some windows have a specific widget to scroll with the right stick. Move the mouse there. - if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && isPastDeadzone - && topWin->getControllerScrollWidget() != nullptr) + if (arg.axis == SDL_CONTROLLER_AXIS_RIGHTY && topWin->getControllerScrollWidget() != nullptr) { mMouseManager->warpMouseToWidget(topWin->getControllerScrollWidget()); winMgr->setCursorVisible(false);