diff --git a/UnleashedRecomp/ui/window.cpp b/UnleashedRecomp/ui/window.cpp index 7e660ffe..420b81e8 100644 --- a/UnleashedRecomp/ui/window.cpp +++ b/UnleashedRecomp/ui/window.cpp @@ -81,7 +81,7 @@ int Window_OnSDLEvent(void*, SDL_Event* event) case SDL_WINDOWEVENT_FOCUS_GAINED: Window::s_isFocused = true; - SDL_ShowCursor(SDL_DISABLE); + SDL_ShowCursor(Window::IsFullscreen() ? SDL_DISABLE : SDL_ENABLE); break; case SDL_WINDOWEVENT_RESTORED: @@ -114,6 +114,20 @@ int Window_OnSDLEvent(void*, SDL_Event* event) } } + if (!Window::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); + } + } + for (auto listener : Window::s_eventListeners) listener->OnSDLEvent(event); @@ -150,6 +164,9 @@ void Window::Init() s_pWindow = SDL_CreateWindow("SWA", s_x, s_y, s_width, s_height, GetWindowFlags()); + if (IsFullscreen()) + SDL_ShowCursor(SDL_DISABLE); + SetIcon(); SetTitle(); SDL_SetWindowMinimumSize(s_pWindow, 640, 480);