src/core/android/SDL_android.c
changeset 12007 ecfb6a793c30
parent 11932 a05a909eeddb
child 12008 91f9b8f22b17
equal deleted inserted replaced
12006:1b7ed3438a7f 12007:ecfb6a793c30
   100         jint touch_device_id_in, jint pointer_finger_id_in,
   100         jint touch_device_id_in, jint pointer_finger_id_in,
   101         jint action, jfloat x, jfloat y, jfloat p);
   101         jint action, jfloat x, jfloat y, jfloat p);
   102 
   102 
   103 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
   103 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
   104         JNIEnv* env, jclass jcls,
   104         JNIEnv* env, jclass jcls,
   105         jint button, jint action, jfloat x, jfloat y);
   105         jint button, jint action, jfloat x, jfloat y, jboolean relative);
   106 
   106 
   107 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
   107 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
   108         JNIEnv* env, jclass jcls,
   108         JNIEnv* env, jclass jcls,
   109         jfloat x, jfloat y, jfloat z);
   109         jfloat x, jfloat y, jfloat z);
   110 
   110 
   224 static jmethodID midGetManifestEnvironmentVariables;
   224 static jmethodID midGetManifestEnvironmentVariables;
   225 static jmethodID midGetDisplayDPI;
   225 static jmethodID midGetDisplayDPI;
   226 static jmethodID midCreateCustomCursor;
   226 static jmethodID midCreateCustomCursor;
   227 static jmethodID midSetCustomCursor;
   227 static jmethodID midSetCustomCursor;
   228 static jmethodID midSetSystemCursor;
   228 static jmethodID midSetSystemCursor;
       
   229 static jmethodID midSupportsRelativeMouse;
       
   230 static jmethodID midSetRelativeMouseEnabled;
   229 
   231 
   230 /* audio manager */
   232 /* audio manager */
   231 static jclass mAudioManagerClass;
   233 static jclass mAudioManagerClass;
   232 
   234 
   233 /* method signatures */
   235 /* method signatures */
   337     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   339     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   338     midCreateCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "createCustomCursor", "([IIIII)I");
   340     midCreateCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "createCustomCursor", "([IIIII)I");
   339     midSetCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setCustomCursor", "(I)Z");
   341     midSetCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setCustomCursor", "(I)Z");
   340     midSetSystemCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setSystemCursor", "(I)Z");
   342     midSetSystemCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setSystemCursor", "(I)Z");
   341 
   343 
       
   344     midSupportsRelativeMouse = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "supportsRelativeMouse", "()Z");
       
   345     midSetRelativeMouseEnabled = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setRelativeMouseEnabled", "(Z)Z");
       
   346 
   342     if (!midGetNativeSurface ||
   347     if (!midGetNativeSurface ||
   343        !midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
   348        !midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
   344        !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
   349        !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
   345        !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
   350        !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
   346        !midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
   351        !midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI ||
   347        !midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor) {
   352        !midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled) {
   348         __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
   353         __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?");
   349     }
   354     }
   350 
   355 
   351     fidSeparateMouseAndTouch = (*mEnv)->GetStaticFieldID(mEnv, mActivityClass, "mSeparateMouseAndTouch", "Z");
   356     fidSeparateMouseAndTouch = (*mEnv)->GetStaticFieldID(mEnv, mActivityClass, "mSeparateMouseAndTouch", "Z");
   352 
   357 
   680 }
   685 }
   681 
   686 
   682 /* Mouse */
   687 /* Mouse */
   683 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
   688 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
   684                                     JNIEnv* env, jclass jcls,
   689                                     JNIEnv* env, jclass jcls,
   685                                     jint button, jint action, jfloat x, jfloat y)
   690                                     jint button, jint action, jfloat x, jfloat y, jboolean relative)
   686 {
   691 {
   687     Android_OnMouse(button, action, x, y);
   692     Android_OnMouse(button, action, x, y, relative);
   688 }
   693 }
   689 
   694 
   690 /* Accelerometer */
   695 /* Accelerometer */
   691 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
   696 JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
   692                                     JNIEnv* env, jclass jcls,
   697                                     JNIEnv* env, jclass jcls,
  2200 {
  2205 {
  2201     JNIEnv *mEnv = Android_JNI_GetEnv();
  2206     JNIEnv *mEnv = Android_JNI_GetEnv();
  2202     return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetSystemCursor, cursorID);
  2207     return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetSystemCursor, cursorID);
  2203 }
  2208 }
  2204 
  2209 
       
  2210 SDL_bool Android_JNI_SupportsRelativeMouse()
       
  2211 {
       
  2212     JNIEnv *mEnv = Android_JNI_GetEnv();
       
  2213     return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSupportsRelativeMouse);
       
  2214 }
       
  2215 
       
  2216 SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled)
       
  2217 {
       
  2218     JNIEnv *mEnv = Android_JNI_GetEnv();
       
  2219     return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1));
       
  2220 }
       
  2221 
       
  2222 
  2205 #endif /* __ANDROID__ */
  2223 #endif /* __ANDROID__ */
  2206 
  2224 
  2207 /* vi: set ts=4 sw=4 expandtab: */
  2225 /* vi: set ts=4 sw=4 expandtab: */