src/video/android/SDL_androidmouse.c
changeset 12007 ecfb6a793c30
parent 11932 a05a909eeddb
child 12025 39a92b19f99e
     1.1 --- a/src/video/android/SDL_androidmouse.c	Tue Jun 05 12:46:09 2018 -0700
     1.2 +++ b/src/video/android/SDL_androidmouse.c	Tue Jun 05 12:46:11 2018 -0700
     1.3 @@ -137,6 +137,20 @@
     1.4      return 0;
     1.5  }
     1.6  
     1.7 +static int
     1.8 +Android_SetRelativeMouseMode(SDL_bool enabled)
     1.9 +{
    1.10 +    if (!Android_JNI_SupportsRelativeMouse()) {
    1.11 +        return SDL_Unsupported();
    1.12 +    }
    1.13 +
    1.14 +    if (!Android_JNI_SetRelativeMouseEnabled(enabled)) {
    1.15 +        return SDL_Unsupported();
    1.16 +    }
    1.17 +
    1.18 +    return 0;
    1.19 +}
    1.20 +
    1.21  void
    1.22  Android_InitMouse(void)
    1.23  {
    1.24 @@ -146,6 +160,7 @@
    1.25      mouse->CreateSystemCursor = Android_CreateSystemCursor;
    1.26      mouse->ShowCursor = Android_ShowCursor;
    1.27      mouse->FreeCursor = Android_FreeCursor;
    1.28 +    mouse->SetRelativeMouseMode = Android_SetRelativeMouseMode;
    1.29  
    1.30      SDL_SetDefaultCursor(Android_CreateDefaultCursor());
    1.31  
    1.32 @@ -172,7 +187,7 @@
    1.33  }
    1.34  
    1.35  void
    1.36 -Android_OnMouse(int state, int action, float x, float y)
    1.37 +Android_OnMouse(int state, int action, float x, float y, SDL_bool relative)
    1.38  {
    1.39      int changes;
    1.40      Uint8 button;
    1.41 @@ -186,7 +201,7 @@
    1.42              changes = state & ~last_state;
    1.43              button = TranslateButton(changes);
    1.44              last_state = state;
    1.45 -            SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
    1.46 +            SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
    1.47              SDL_SendMouseButton(Android_Window, 0, SDL_PRESSED, button);
    1.48              break;
    1.49  
    1.50 @@ -194,13 +209,13 @@
    1.51              changes = last_state & ~state;
    1.52              button = TranslateButton(changes);
    1.53              last_state = state;
    1.54 -            SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
    1.55 +            SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
    1.56              SDL_SendMouseButton(Android_Window, 0, SDL_RELEASED, button);
    1.57              break;
    1.58  
    1.59          case ACTION_MOVE:
    1.60          case ACTION_HOVER_MOVE:
    1.61 -            SDL_SendMouseMotion(Android_Window, 0, 0, x, y);
    1.62 +            SDL_SendMouseMotion(Android_Window, 0, relative, x, y);
    1.63              break;
    1.64  
    1.65          case ACTION_SCROLL: