Commit e401b950258065d810033d24877d1ed7731982b6

Sam Lantinga 2019-05-23T11:32:36

Return an error if both mouse relative mode and mouse warping are unavailable, instead of asserting.

diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c
index 259fd2e..c8c4494 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) {