Fixed bug 4707 - SDL_SetRelativeMouseMode fails on Vivante
authorSam Lantinga <slouken@libsdl.org>
Wed, 03 Jul 2019 15:57:55 -0700
changeset 12927abb47c384db3
parent 12926 b5cd5e1e4440
child 12928 3c4a4b1077cd
Fixed bug 4707 - SDL_SetRelativeMouseMode fails on Vivante

Cameron Gutman

The bugfix in https://hg.libsdl.org/SDL/rev/ba1a66b57385 caused SDL_SetRelativeMouseMode() to begin failing on Vivante (Steam Link). Even though Vivante doesn't have a SetRelativeMouseMode() or WarpMouse() function, it's in relative mode already (because it uses evdev) so the function was actually working as intended.

I think providing a no-op SetRelativeMouseMode() function for Vivante is a reasonable fix. Since it's already getting relative events through evdev, it really is a no-op to "enter relative mode".

In fact, this is probably the right thing to do for all backends that use evdev (vivante, raspberry, and kmsdrm). Raspberry and kmsdrm both have WarpMouse() implementations so SDL_SetRelativeMouseMode() isn't failing there, but it still seems to make sense not to have to do the fake warping if they're evdev-based anyway.
Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
src/core/linux/SDL_evdev.c
     1.1 --- a/src/core/linux/SDL_evdev.c	Wed Jul 03 13:37:54 2019 +0200
     1.2 +++ b/src/core/linux/SDL_evdev.c	Wed Jul 03 15:57:55 2019 -0700
     1.3 @@ -129,6 +129,14 @@
     1.4      SDL_BUTTON_X2 + 3           /*  BTN_TASK        0x117 */
     1.5  };
     1.6  
     1.7 +static int
     1.8 +SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled)
     1.9 +{
    1.10 +    /* Mice already send relative events through this interface */
    1.11 +    return 0;
    1.12 +}
    1.13 +
    1.14 +
    1.15  int
    1.16  SDL_EVDEV_Init(void)
    1.17  {
    1.18 @@ -162,6 +170,8 @@
    1.19          _this->kbd = SDL_EVDEV_kbd_init();
    1.20      }
    1.21  
    1.22 +    SDL_GetMouse()->SetRelativeMouseMode = SDL_EVDEV_SetRelativeMouseMode;
    1.23 +
    1.24      _this->ref_count += 1;
    1.25  
    1.26      return 0;