mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 21:01:37 +00:00
window: hide mouse cursor on controller input for windowed mode
This commit is contained in:
parent
e3f7eba9a6
commit
ff79eae6c4
1 changed files with 18 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue