Skip to content

Commit

Permalink
Return an error if both mouse relative mode and mouse warping are una…
Browse files Browse the repository at this point in the history
…vailable, instead of asserting.
  • Loading branch information
slouken committed May 23, 2019
1 parent 8b57331 commit e401b95
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/events/SDL_mouse.c
Expand Up @@ -765,9 +765,9 @@ SDL_WarpMouseGlobal(int x, int y)
static SDL_bool
ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
{
if (!mouse->SetRelativeMouseMode) {
SDL_assert(mouse->WarpMouse); /* Need this functionality for relative mode warp implementation */
return SDL_TRUE;
if (!mouse->WarpMouse) {
/* Need this functionality for relative mode warp implementation */
return SDL_FALSE;
}

return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE);
Expand Down Expand Up @@ -796,7 +796,7 @@ SDL_SetRelativeMouseMode(SDL_bool enabled)
mouse->relative_mode_warp = SDL_FALSE;
} else if (enabled && ShouldUseRelativeModeWarp(mouse)) {
mouse->relative_mode_warp = SDL_TRUE;
} else if (mouse->SetRelativeMouseMode(enabled) < 0) {
} else if (!mouse->SetRelativeMouseMode || mouse->SetRelativeMouseMode(enabled) < 0) {
if (enabled) {
/* Fall back to warp mode if native relative mode failed */
if (!mouse->WarpMouse) {
Expand Down

0 comments on commit e401b95

Please sign in to comment.