From e401b950258065d810033d24877d1ed7731982b6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 23 May 2019 11:32:36 -0700 Subject: [PATCH] Return an error if both mouse relative mode and mouse warping are unavailable, instead of asserting. --- src/events/SDL_mouse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 259fd2e2a..c8c44947f 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -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); @@ -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) {