src/core/android/SDL_android.c
changeset 12007 ecfb6a793c30
parent 11932 a05a909eeddb
child 12008 91f9b8f22b17
     1.1 --- a/src/core/android/SDL_android.c	Tue Jun 05 12:46:09 2018 -0700
     1.2 +++ b/src/core/android/SDL_android.c	Tue Jun 05 12:46:11 2018 -0700
     1.3 @@ -102,7 +102,7 @@
     1.4  
     1.5  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
     1.6          JNIEnv* env, jclass jcls,
     1.7 -        jint button, jint action, jfloat x, jfloat y);
     1.8 +        jint button, jint action, jfloat x, jfloat y, jboolean relative);
     1.9  
    1.10  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
    1.11          JNIEnv* env, jclass jcls,
    1.12 @@ -226,6 +226,8 @@
    1.13  static jmethodID midCreateCustomCursor;
    1.14  static jmethodID midSetCustomCursor;
    1.15  static jmethodID midSetSystemCursor;
    1.16 +static jmethodID midSupportsRelativeMouse;
    1.17 +static jmethodID midSetRelativeMouseEnabled;
    1.18  
    1.19  /* audio manager */
    1.20  static jclass mAudioManagerClass;
    1.21 @@ -339,12 +341,15 @@
    1.22      midSetCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setCustomCursor", "(I)Z");
    1.23      midSetSystemCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setSystemCursor", "(I)Z");
    1.24  
    1.25 +    midSupportsRelativeMouse = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "supportsRelativeMouse", "()Z");
    1.26 +    midSetRelativeMouseEnabled = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
    1.27 +
    1.28      if (!midGetNativeSurface ||
    1.29         !midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
    1.30         !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
    1.31         !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
    1.32         !midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
    1.33 -       !midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor) {
    1.34 +       !midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled) {
    1.35          __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
    1.36      }
    1.37  
    1.38 @@ -682,9 +687,9 @@
    1.39  /* Mouse */
    1.40  JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
    1.41                                      JNIEnv* env, jclass jcls,
    1.42 -                                    jint button, jint action, jfloat x, jfloat y)
    1.43 +                                    jint button, jint action, jfloat x, jfloat y, jboolean relative)
    1.44  {
    1.45 -    Android_OnMouse(button, action, x, y);
    1.46 +    Android_OnMouse(button, action, x, y, relative);
    1.47  }
    1.48  
    1.49  /* Accelerometer */
    1.50 @@ -2202,6 +2207,19 @@
    1.51      return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetSystemCursor, cursorID);
    1.52  }
    1.53  
    1.54 +SDL_bool Android_JNI_SupportsRelativeMouse()
    1.55 +{
    1.56 +    JNIEnv *mEnv = Android_JNI_GetEnv();
    1.57 +    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSupportsRelativeMouse);
    1.58 +}
    1.59 +
    1.60 +SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled)
    1.61 +{
    1.62 +    JNIEnv *mEnv = Android_JNI_GetEnv();
    1.63 +    return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
    1.64 +}
    1.65 +
    1.66 +
    1.67  #endif /* __ANDROID__ */
    1.68  
    1.69  /* vi: set ts=4 sw=4 expandtab: */