From 2150faed2e4851dfd162706ff5d5a56ad964cccb Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Fri, 7 Feb 2025 20:42:02 +0000 Subject: [PATCH] game_window: fix mouse cursor flickering after controller input --- UnleashedRecomp/hid/driver/sdl_hid.cpp | 10 ++++++++++ UnleashedRecomp/ui/game_window.cpp | 14 -------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/UnleashedRecomp/hid/driver/sdl_hid.cpp b/UnleashedRecomp/hid/driver/sdl_hid.cpp index 5032642..85e6793 100644 --- a/UnleashedRecomp/hid/driver/sdl_hid.cpp +++ b/UnleashedRecomp/hid/driver/sdl_hid.cpp @@ -239,12 +239,16 @@ int HID_OnSDLEvent(void*, SDL_Event* event) if (event->type == SDL_CONTROLLERAXISMOTION) { if (abs(event->caxis.value) > 8000) + { + SDL_ShowCursor(SDL_DISABLE); SetControllerInputDevice(controller); + } controller->PollAxis(); } else { + SDL_ShowCursor(SDL_DISABLE); SetControllerInputDevice(controller); controller->Poll(); @@ -261,8 +265,14 @@ int HID_OnSDLEvent(void*, SDL_Event* event) case SDL_MOUSEMOTION: case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: + { + if (!GameWindow::IsFullscreen() || GameWindow::s_isFullscreenCursorVisible) + SDL_ShowCursor(SDL_ENABLE); + hid::g_inputDevice = hid::EInputDevice::Mouse; + break; + } case SDL_WINDOWEVENT: { diff --git a/UnleashedRecomp/ui/game_window.cpp b/UnleashedRecomp/ui/game_window.cpp index a6704e6..a8983e3 100644 --- a/UnleashedRecomp/ui/game_window.cpp +++ b/UnleashedRecomp/ui/game_window.cpp @@ -146,20 +146,6 @@ int Window_OnSDLEvent(void*, SDL_Event* event) break; } - if (!GameWindow::IsFullscreen()) - { - if (event->type == SDL_CONTROLLERBUTTONDOWN || event->type == SDL_CONTROLLERBUTTONUP || event->type == SDL_CONTROLLERAXISMOTION) - { - // Hide mouse cursor when controller input is detected. - SDL_ShowCursor(SDL_DISABLE); - } - else if (event->type == SDL_MOUSEMOTION) - { - // Restore mouse cursor when mouse input is detected. - SDL_ShowCursor(SDL_ENABLE); - } - } - return 0; }