Skip to content

Commit

Permalink
sdl: workaround for not setting relative mouse location on some Andro…
Browse files Browse the repository at this point in the history
…id Phones.
  • Loading branch information
rafal1137 committed Oct 4, 2019
1 parent 056b0ab commit bcd93ed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sdl/sdl_input.c
Expand Up @@ -583,11 +583,16 @@ static void IN_GobbleMotionEvents(void)
static void IN_GrabMouse(qboolean grab, qboolean relative) static void IN_GrabMouse(qboolean grab, qboolean relative)
{ {
static qboolean mouse_grabbed = qfalse, mouse_relative = qfalse; static qboolean mouse_grabbed = qfalse, mouse_relative = qfalse;
#ifndef __ANDROID__
int relative_result = 0; int relative_result = 0;
#endif


if (relative == !mouse_relative) if (relative == !mouse_relative)
{ {
SDL_ShowCursor(!relative); SDL_ShowCursor(!relative);
#ifndef __ANDROID__
// On Android Phones with API <= 23 this is causing to App to close since it could not
// set relative mouse location (Mouse location is always at top left side of screen)
if ((relative_result = SDL_SetRelativeMouseMode((SDL_bool)relative)) != 0) if ((relative_result = SDL_SetRelativeMouseMode((SDL_bool)relative)) != 0)
{ {
// FIXME: this happens on some systems (IR4) // FIXME: this happens on some systems (IR4)
Expand All @@ -600,6 +605,7 @@ static void IN_GrabMouse(qboolean grab, qboolean relative)
Com_Error(ERR_FATAL, "Setting relative mouse location fails: %s\n", SDL_GetError()); Com_Error(ERR_FATAL, "Setting relative mouse location fails: %s\n", SDL_GetError());
} }
} }
#endif
mouse_relative = relative; mouse_relative = relative;
} }


Expand Down

0 comments on commit bcd93ed

Please sign in to comment.