src/core/android/SDL_android.c
changeset 11931 d479188e0155
parent 11921 88a2982221ec
child 11932 a05a909eeddb
equal deleted inserted replaced
11930:c808a74c019e 11931:d479188e0155
   221 static jmethodID midClipboardGetText;
   221 static jmethodID midClipboardGetText;
   222 static jmethodID midClipboardHasText;
   222 static jmethodID midClipboardHasText;
   223 static jmethodID midOpenAPKExpansionInputStream;
   223 static jmethodID midOpenAPKExpansionInputStream;
   224 static jmethodID midGetManifestEnvironmentVariables;
   224 static jmethodID midGetManifestEnvironmentVariables;
   225 static jmethodID midGetDisplayDPI;
   225 static jmethodID midGetDisplayDPI;
       
   226 static jmethodID midCreateCustomCursor;
       
   227 static jmethodID midSetCustomCursor;
       
   228 static jmethodID midSetSystemCursor;
   226 
   229 
   227 /* audio manager */
   230 /* audio manager */
   228 static jclass mAudioManagerClass;
   231 static jclass mAudioManagerClass;
   229 
   232 
   230 /* method signatures */
   233 /* method signatures */
   330 
   333 
   331     midGetManifestEnvironmentVariables = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   334     midGetManifestEnvironmentVariables = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass,
   332                                 "getManifestEnvironmentVariables", "()Z");
   335                                 "getManifestEnvironmentVariables", "()Z");
   333 
   336 
   334     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   337     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   335     midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;");
   338 
       
   339     /* Custom cursor implementation is only available on API 24 and above */
       
   340     midCreateCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "createCustomCursor", "([IIIII)I");
       
   341     midSetCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setCustomCursor", "(I)V");
       
   342     midSetSystemCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setSystemCursor", "(I)V");
   336 
   343 
   337     if (!midGetNativeSurface ||
   344     if (!midGetNativeSurface ||
   338        !midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
   345        !midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsAndroidTV || !midInputGetInputDeviceIds ||
   339        !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
   346        !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown ||
   340        !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
   347        !midClipboardSetText || !midClipboardGetText || !midClipboardHasText ||
  2165             bHasEnvironmentVariables = SDL_TRUE;
  2172             bHasEnvironmentVariables = SDL_TRUE;
  2166         }
  2173         }
  2167     }
  2174     }
  2168 }
  2175 }
  2169 
  2176 
       
  2177 int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y)
       
  2178 {
       
  2179     JNIEnv *mEnv = Android_JNI_GetEnv();
       
  2180     int custom_cursor = 0;
       
  2181     if (midCreateCustomCursor) {
       
  2182         jintArray pixels;
       
  2183         pixels = (*mEnv)->NewIntArray(mEnv, surface->w * surface->h);
       
  2184         if (!pixels) {
       
  2185             return 0;
       
  2186         }
       
  2187         (*mEnv)->SetIntArrayRegion(mEnv, pixels, 0, surface->w * surface->h, (int *)surface->pixels);
       
  2188         custom_cursor = (*mEnv)->CallStaticIntMethod(mEnv, mActivityClass, midCreateCustomCursor, pixels, surface->w, surface->h, hot_x, hot_y);
       
  2189         (*mEnv)->DeleteLocalRef(mEnv, pixels);
       
  2190     }
       
  2191     return custom_cursor;
       
  2192 }
       
  2193 
       
  2194 
       
  2195 void Android_JNI_SetCustomCursor(int cursorID)
       
  2196 {
       
  2197     JNIEnv *mEnv = Android_JNI_GetEnv();
       
  2198     if (midSetCustomCursor) {
       
  2199         (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetCustomCursor, cursorID);
       
  2200     }
       
  2201 }
       
  2202 
       
  2203 void Android_JNI_SetSystemCursor(int cursorID)
       
  2204 {
       
  2205     JNIEnv *mEnv = Android_JNI_GetEnv();
       
  2206     if (midSetSystemCursor) {
       
  2207         (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetSystemCursor, cursorID);
       
  2208     }
       
  2209 }
       
  2210 
  2170 #endif /* __ANDROID__ */
  2211 #endif /* __ANDROID__ */
  2171 
  2212 
  2172 /* vi: set ts=4 sw=4 expandtab: */
  2213 /* vi: set ts=4 sw=4 expandtab: */