Return an error if both mouse relative mode and mouse warping are unavailable, instead of asserting.
authorSam Lantinga <slouken@libsdl.org>
Thu, 23 May 2019 11:32:36 -0700
changeset 12753ba1a66b57385
parent 12752 53a3b17a1c08
child 12754 aec84759c57e
Return an error if both mouse relative mode and mouse warping are unavailable, instead of asserting.
src/events/SDL_mouse.c
     1.1 --- a/src/events/SDL_mouse.c	Thu May 23 11:05:43 2019 -0700
     1.2 +++ b/src/events/SDL_mouse.c	Thu May 23 11:32:36 2019 -0700
     1.3 @@ -765,9 +765,9 @@
     1.4  static SDL_bool
     1.5  ShouldUseRelativeModeWarp(SDL_Mouse *mouse)
     1.6  {
     1.7 -    if (!mouse->SetRelativeMouseMode) {
     1.8 -        SDL_assert(mouse->WarpMouse);   /* Need this functionality for relative mode warp implementation */
     1.9 -        return SDL_TRUE;
    1.10 +    if (!mouse->WarpMouse) {
    1.11 +        /* Need this functionality for relative mode warp implementation */
    1.12 +        return SDL_FALSE;
    1.13      }
    1.14  
    1.15      return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE);
    1.16 @@ -796,7 +796,7 @@
    1.17          mouse->relative_mode_warp = SDL_FALSE;
    1.18      } else if (enabled && ShouldUseRelativeModeWarp(mouse)) {
    1.19          mouse->relative_mode_warp = SDL_TRUE;
    1.20 -    } else if (mouse->SetRelativeMouseMode(enabled) < 0) {
    1.21 +    } else if (!mouse->SetRelativeMouseMode || mouse->SetRelativeMouseMode(enabled) < 0) {
    1.22          if (enabled) {
    1.23              /* Fall back to warp mode if native relative mode failed */
    1.24              if (!mouse->WarpMouse) {