Android: preparation bug 4142, reduce usage of global variable Android_Window

This commit is contained in:
Sylvain Becker 2019-01-03 13:14:16 +01:00
parent a95f91bcea
commit 5dc25fef3b
10 changed files with 194 additions and 205 deletions

View File

@ -68,92 +68,92 @@
/* Java class SDLActivity */ /* Java class SDLActivity */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(
JNIEnv* mEnv, jclass cls); JNIEnv *mEnv, jclass cls);
JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)( JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring library, jstring function, jobject array); jstring library, jstring function, jobject array);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jstring filename); jstring filename);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint surfaceWidth, jint surfaceHeight, jint surfaceWidth, jint surfaceHeight,
jint deviceWidth, jint deviceHeight, jint format, jfloat rate); jint deviceWidth, jint deviceHeight, jint format, jfloat rate);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(
JNIEnv* env, jclass jcls); JNIEnv *env, jclass jcls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(
JNIEnv* env, jclass jcls); JNIEnv *env, jclass jcls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint keycode); jint keycode);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint keycode); jint keycode);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)(
JNIEnv* env, jclass jcls); JNIEnv *env, jclass jcls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint touch_device_id_in, jint pointer_finger_id_in, jint touch_device_id_in, jint pointer_finger_id_in,
jint action, jfloat x, jfloat y, jfloat p); jint action, jfloat x, jfloat y, jfloat p);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint button, jint action, jfloat x, jfloat y, jboolean relative); jint button, jint action, jfloat x, jfloat y, jboolean relative);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jfloat x, jfloat y, jfloat z); jfloat x, jfloat y, jfloat z);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)(
JNIEnv* env, jclass jcls); JNIEnv *env, jclass jcls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)(
JNIEnv* env, jclass cls); JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
JNIEnv* env, jclass cls); JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
JNIEnv* env, jclass cls); JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
JNIEnv* env, jclass cls); JNIEnv *env, jclass cls);
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)( JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring name); jstring name);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring name, jstring value); jstring name, jstring value);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeEnvironmentVariablesSet)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeEnvironmentVariablesSet)(
JNIEnv* env, jclass cls); JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jint orientation); jint orientation);
/* Java class SDLInputConnection */ /* Java class SDLInputConnection */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring text, jint newCursorPosition); jstring text, jint newCursorPosition);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jchar chUnicode); jchar chUnicode);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring text, jint newCursorPosition); jstring text, jint newCursorPosition);
/* Java class SDLAudioManager */ /* Java class SDLAudioManager */
@ -165,36 +165,36 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(
JNIEnv *env, jclass jcls); JNIEnv *env, jclass jcls);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jint keycode); jint device_id, jint keycode);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jint keycode); jint device_id, jint keycode);
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)( JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jint axis, jfloat value); jint device_id, jint axis, jfloat value);
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)( JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jint hat_id, jint x, jint y); jint device_id, jint hat_id, jint x, jint y);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id, jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id,
jboolean is_accelerometer, jint button_mask, jint naxes, jint nhats, jint nballs); jboolean is_accelerometer, jint button_mask, jint naxes, jint nhats, jint nballs);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id); jint device_id);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jstring device_name); jint device_id, jstring device_name);
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id); jint device_id);
@ -202,7 +202,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
/* Uncomment this to log messages entering and exiting methods in this file */ /* Uncomment this to log messages entering and exiting methods in this file */
/* #define DEBUG_JNI */ /* #define DEBUG_JNI */
static void Android_JNI_ThreadDestroyed(void*); static void Android_JNI_ThreadDestroyed(void *);
static void checkJNIReady(void); static void checkJNIReady(void);
/******************************************************************************* /*******************************************************************************
@ -215,7 +215,7 @@ static void checkJNIReady(void);
Globals Globals
*******************************************************************************/ *******************************************************************************/
static pthread_key_t mThreadKey; static pthread_key_t mThreadKey;
static JavaVM* mJavaVM; static JavaVM *mJavaVM;
/* Main activity */ /* Main activity */
static jclass mActivityClass; static jclass mActivityClass;
@ -286,12 +286,12 @@ static SDL_bool bHasEnvironmentVariables = SDL_FALSE;
*******************************************************************************/ *******************************************************************************/
/* Library init */ /* Library init */
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{ {
JNIEnv *env; JNIEnv *env;
mJavaVM = vm; mJavaVM = vm;
LOGI("JNI_OnLoad called"); LOGI("JNI_OnLoad called");
if ((*mJavaVM)->GetEnv(mJavaVM, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { if ((*mJavaVM)->GetEnv(mJavaVM, (void **) &env, JNI_VERSION_1_4) != JNI_OK) {
LOGE("Failed to get the environment using GetEnv()"); LOGE("Failed to get the environment using GetEnv()");
return -1; return -1;
} }
@ -318,7 +318,7 @@ void checkJNIReady()
} }
/* Activity initialization -- called before SDL_main() to initialize JNI bindings */ /* Activity initialization -- called before SDL_main() to initialize JNI bindings */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass cls) JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
{ {
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()"); __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()");
@ -397,7 +397,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass c
} }
/* Audio initialization -- called before SDL_main() to initialize JNI bindings */ /* Audio initialization -- called before SDL_main() to initialize JNI bindings */
JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass cls) JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
{ {
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "AUDIO nativeSetupJNI()"); __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "AUDIO nativeSetupJNI()");
@ -435,7 +435,7 @@ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jc
} }
/* Controller initialization -- called before SDL_main() to initialize JNI bindings */ /* Controller initialization -- called before SDL_main() to initialize JNI bindings */
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass cls) JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv *mEnv, jclass cls)
{ {
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "CONTROLLER nativeSetupJNI()"); __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "CONTROLLER nativeSetupJNI()");
@ -463,7 +463,7 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv* mEn
typedef int (*SDL_main_func)(int argc, char *argv[]); typedef int (*SDL_main_func)(int argc, char *argv[]);
/* Start up the SDL app */ /* Start up the SDL app */
JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv* env, jclass cls, jstring library, jstring function, jobject array) JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv *env, jclass cls, jstring library, jstring function, jobject array)
{ {
int status = -1; int status = -1;
const char *library_file; const char *library_file;
@ -488,15 +488,15 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv* env, jclass cls,
/* Prepare the arguments. */ /* Prepare the arguments. */
len = (*env)->GetArrayLength(env, array); len = (*env)->GetArrayLength(env, array);
argv = SDL_small_alloc(char*, 1 + len + 1, &isstack); /* !!! FIXME: check for NULL */ argv = SDL_small_alloc(char *, 1 + len + 1, &isstack); /* !!! FIXME: check for NULL */
argc = 0; argc = 0;
/* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works. /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works.
https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start
*/ */
argv[argc++] = SDL_strdup("app_process"); argv[argc++] = SDL_strdup("app_process");
for (i = 0; i < len; ++i) { for (i = 0; i < len; ++i) {
const char* utf; const char *utf;
char* arg = NULL; char *arg = NULL;
jstring string = (*env)->GetObjectArrayElement(env, array, i); jstring string = (*env)->GetObjectArrayElement(env, array, i);
if (string) { if (string) {
utf = (*env)->GetStringUTFChars(env, string, 0); utf = (*env)->GetStringUTFChars(env, string, 0);
@ -543,7 +543,7 @@ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv* env, jclass cls,
/* Drop file */ /* Drop file */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jstring filename) jstring filename)
{ {
const char *path = (*env)->GetStringUTFChars(env, filename, NULL); const char *path = (*env)->GetStringUTFChars(env, filename, NULL);
@ -554,11 +554,11 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)(
/* Resize */ /* Resize */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint surfaceWidth, jint surfaceHeight, jint surfaceWidth, jint surfaceHeight,
jint deviceWidth, jint deviceHeight, jint format, jfloat rate) jint deviceWidth, jint deviceHeight, jint format, jfloat rate)
{ {
Android_SetScreenResolution(surfaceWidth, surfaceHeight, deviceWidth, deviceHeight, format, rate); Android_SetScreenResolution(Android_Window, surfaceWidth, surfaceHeight, deviceWidth, deviceHeight, format, rate);
} }
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)(
@ -571,7 +571,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)(
/* Paddown */ /* Paddown */
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jint keycode) jint device_id, jint keycode)
{ {
return Android_OnPadDown(device_id, keycode); return Android_OnPadDown(device_id, keycode);
@ -579,7 +579,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)(
/* Padup */ /* Padup */
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jint keycode) jint device_id, jint keycode)
{ {
return Android_OnPadUp(device_id, keycode); return Android_OnPadUp(device_id, keycode);
@ -587,7 +587,7 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)(
/* Joy */ /* Joy */
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)( JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jint axis, jfloat value) jint device_id, jint axis, jfloat value)
{ {
Android_OnJoy(device_id, axis, value); Android_OnJoy(device_id, axis, value);
@ -595,7 +595,7 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)(
/* POV Hat */ /* POV Hat */
JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)( JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jint hat_id, jint x, jint y) jint device_id, jint hat_id, jint x, jint y)
{ {
Android_OnHat(device_id, hat_id, x, y); Android_OnHat(device_id, hat_id, x, y);
@ -603,7 +603,7 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)(
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id, jstring device_name, jstring device_desc, jint device_id, jstring device_name, jstring device_desc,
jint vendor_id, jint product_id, jboolean is_accelerometer, jint vendor_id, jint product_id, jboolean is_accelerometer,
jint button_mask, jint naxes, jint nhats, jint nballs) jint button_mask, jint naxes, jint nhats, jint nballs)
@ -621,14 +621,14 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)(
} }
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint device_id) jint device_id)
{ {
return Android_RemoveJoystick(device_id); return Android_RemoveJoystick(device_id);
} }
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
JNIEnv* env, jclass jcls, jint device_id, jstring device_name) JNIEnv *env, jclass jcls, jint device_id, jstring device_name)
{ {
int retval; int retval;
const char *name = (*env)->GetStringUTFChars(env, device_name, NULL); const char *name = (*env)->GetStringUTFChars(env, device_name, NULL);
@ -641,68 +641,59 @@ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)(
} }
JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)( JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)(
JNIEnv* env, jclass jcls, jint device_id) JNIEnv *env, jclass jcls, jint device_id)
{ {
return Android_RemoveHaptic(device_id); return Android_RemoveHaptic(device_id);
} }
/* Surface Created */ /* Surface Created */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv* env, jclass jcls) JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, jclass jcls)
{ {
SDL_WindowData *data; if (Android_Window && Android_Window->driverdata)
SDL_VideoDevice *_this; {
SDL_VideoDevice *_this = SDL_GetVideoDevice();
SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata;
if (Android_Window == NULL || Android_Window->driverdata == NULL ) { /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
return; if (data->egl_surface == EGL_NO_SURFACE) {
} if (data->native_window) {
ANativeWindow_release(data->native_window);
_this = SDL_GetVideoDevice(); }
data = (SDL_WindowData *) Android_Window->driverdata; data->native_window = Android_JNI_GetNativeWindow();
data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window);
/* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
if (data->egl_surface == EGL_NO_SURFACE) {
if(data->native_window) {
ANativeWindow_release(data->native_window);
} }
data->native_window = Android_JNI_GetNativeWindow();
data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window); /* GL Context handling is done in the event loop because this function is run from the Java thread */
} }
/* GL Context handling is done in the event loop because this function is run from the Java thread */
} }
/* Surface Destroyed */ /* Surface Destroyed */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(JNIEnv* env, jclass jcls) JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(JNIEnv *env, jclass jcls)
{ {
/* We have to clear the current context and destroy the egl surface here if (Android_Window && Android_Window->driverdata)
* Otherwise there's BAD_NATIVE_WINDOW errors coming from eglCreateWindowSurface on resume {
* Ref: http://stackoverflow.com/questions/8762589/eglcreatewindowsurface-on-ics-and-switching-from-2d-to-3d SDL_VideoDevice *_this = SDL_GetVideoDevice();
*/ SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata;
SDL_WindowData *data;
SDL_VideoDevice *_this;
if (Android_Window == NULL || Android_Window->driverdata == NULL ) { /* We have to clear the current context and destroy the egl surface here
return; * Otherwise there's BAD_NATIVE_WINDOW errors coming from eglCreateWindowSurface on resume
* Ref: http://stackoverflow.com/questions/8762589/eglcreatewindowsurface-on-ics-and-switching-from-2d-to-3d
*/
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_MakeCurrent(_this, NULL, NULL);
SDL_EGL_DestroySurface(_this, data->egl_surface);
data->egl_surface = EGL_NO_SURFACE;
}
/* GL Context handling is done in the event loop because this function is run from the Java thread */
} }
_this = SDL_GetVideoDevice();
data = (SDL_WindowData *) Android_Window->driverdata;
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_MakeCurrent(_this, NULL, NULL);
SDL_EGL_DestroySurface(_this, data->egl_surface);
data->egl_surface = EGL_NO_SURFACE;
}
/* GL Context handling is done in the event loop because this function is run from the Java thread */
} }
/* Keydown */ /* Keydown */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint keycode) jint keycode)
{ {
Android_OnKeyDown(keycode); Android_OnKeyDown(keycode);
@ -710,7 +701,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)(
/* Keyup */ /* Keyup */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint keycode) jint keycode)
{ {
Android_OnKeyUp(keycode); Android_OnKeyUp(keycode);
@ -718,7 +709,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
/* Keyboard Focus Lost */ /* Keyboard Focus Lost */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)(
JNIEnv* env, jclass jcls) JNIEnv *env, jclass jcls)
{ {
/* Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget */ /* Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget */
SDL_StopTextInput(); SDL_StopTextInput();
@ -727,24 +718,24 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)(
/* Touch */ /* Touch */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint touch_device_id_in, jint pointer_finger_id_in, jint touch_device_id_in, jint pointer_finger_id_in,
jint action, jfloat x, jfloat y, jfloat p) jint action, jfloat x, jfloat y, jfloat p)
{ {
Android_OnTouch(touch_device_id_in, pointer_finger_id_in, action, x, y, p); Android_OnTouch(Android_Window, touch_device_id_in, pointer_finger_id_in, action, x, y, p);
} }
/* Mouse */ /* Mouse */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jint button, jint action, jfloat x, jfloat y, jboolean relative) jint button, jint action, jfloat x, jfloat y, jboolean relative)
{ {
Android_OnMouse(button, action, x, y, relative); Android_OnMouse(Android_Window, button, action, x, y, relative);
} }
/* Accelerometer */ /* Accelerometer */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
JNIEnv* env, jclass jcls, JNIEnv *env, jclass jcls,
jfloat x, jfloat y, jfloat z) jfloat x, jfloat y, jfloat z)
{ {
fLastAccelerometer[0] = x; fLastAccelerometer[0] = x;
@ -755,21 +746,21 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)(
/* Clipboard */ /* Clipboard */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)(
JNIEnv* env, jclass jcls) JNIEnv *env, jclass jcls)
{ {
SDL_SendClipboardUpdate(); SDL_SendClipboardUpdate();
} }
/* Low memory */ /* Low memory */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)(
JNIEnv* env, jclass cls) JNIEnv *env, jclass cls)
{ {
SDL_SendAppEvent(SDL_APP_LOWMEMORY); SDL_SendAppEvent(SDL_APP_LOWMEMORY);
} }
/* Quit */ /* Quit */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
JNIEnv* env, jclass cls) JNIEnv *env, jclass cls)
{ {
/* Discard previous events. The user should have handled state storage /* Discard previous events. The user should have handled state storage
* in SDL_APP_WILLENTERBACKGROUND. After nativeQuit() is called, no * in SDL_APP_WILLENTERBACKGROUND. After nativeQuit() is called, no
@ -785,7 +776,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
/* Pause */ /* Pause */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
JNIEnv* env, jclass cls) JNIEnv *env, jclass cls)
{ {
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativePause()"); __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativePause()");
@ -803,7 +794,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
/* Resume */ /* Resume */
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
JNIEnv* env, jclass cls) JNIEnv *env, jclass cls)
{ {
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeResume()"); __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeResume()");
@ -828,7 +819,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
} }
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring text, jint newCursorPosition) jstring text, jint newCursorPosition)
{ {
const char *utftext = (*env)->GetStringUTFChars(env, text, NULL); const char *utftext = (*env)->GetStringUTFChars(env, text, NULL);
@ -839,7 +830,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)(
} }
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jchar chUnicode) jchar chUnicode)
{ {
SDL_Scancode code = SDL_SCANCODE_UNKNOWN; SDL_Scancode code = SDL_SCANCODE_UNKNOWN;
@ -869,7 +860,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancod
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring text, jint newCursorPosition) jstring text, jint newCursorPosition)
{ {
const char *utftext = (*env)->GetStringUTFChars(env, text, NULL); const char *utftext = (*env)->GetStringUTFChars(env, text, NULL);
@ -880,7 +871,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingTex
} }
JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)( JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring name) jstring name)
{ {
const char *utfname = (*env)->GetStringUTFChars(env, name, NULL); const char *utfname = (*env)->GetStringUTFChars(env, name, NULL);
@ -893,7 +884,7 @@ JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)(
} }
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)(
JNIEnv* env, jclass cls, JNIEnv *env, jclass cls,
jstring name, jstring value) jstring name, jstring value)
{ {
const char *utfname = (*env)->GetStringUTFChars(env, name, NULL); const char *utfname = (*env)->GetStringUTFChars(env, name, NULL);
@ -946,7 +937,7 @@ static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder)
SDL_Log("Leaving function %s", refholder->m_func); SDL_Log("Leaving function %s", refholder->m_func);
#endif #endif
if (refholder->m_env) { if (refholder->m_env) {
JNIEnv* env = refholder->m_env; JNIEnv *env = refholder->m_env;
(*env)->PopLocalFrame(env, NULL); (*env)->PopLocalFrame(env, NULL);
--s_active; --s_active;
} }
@ -1027,10 +1018,10 @@ SDL_bool Android_JNI_GetAccelerometerValues(float values[3])
return retval; return retval;
} }
static void Android_JNI_ThreadDestroyed(void* value) static void Android_JNI_ThreadDestroyed(void *value)
{ {
/* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */
JNIEnv *env = (JNIEnv*) value; JNIEnv *env = (JNIEnv *) value;
if (env != NULL) { if (env != NULL) {
(*mJavaVM)->DetachCurrentThread(mJavaVM); (*mJavaVM)->DetachCurrentThread(mJavaVM);
pthread_setspecific(mThreadKey, NULL); pthread_setspecific(mThreadKey, NULL);
@ -1053,7 +1044,7 @@ JNIEnv* Android_JNI_GetEnv(void)
JNIEnv *env; JNIEnv *env;
int status = (*mJavaVM)->AttachCurrentThread(mJavaVM, &env, NULL); int status = (*mJavaVM)->AttachCurrentThread(mJavaVM, &env, NULL);
if(status < 0) { if (status < 0) {
LOGE("failed to attach current thread"); LOGE("failed to attach current thread");
return 0; return 0;
} }
@ -1067,7 +1058,7 @@ JNIEnv* Android_JNI_GetEnv(void)
* Note: You can call this function any number of times for the same thread, there's no harm in it * Note: You can call this function any number of times for the same thread, there's no harm in it
* (except for some lost CPU cycles) * (except for some lost CPU cycles)
*/ */
pthread_setspecific(mThreadKey, (void*) env); pthread_setspecific(mThreadKey, (void *)env);
return env; return env;
} }
@ -1083,7 +1074,7 @@ int Android_JNI_SetupThread(void)
*/ */
static int audioBufferFormat = 0; static int audioBufferFormat = 0;
static jobject audioBuffer = NULL; static jobject audioBuffer = NULL;
static void* audioBufferPinned = NULL; static void *audioBufferPinned = NULL;
static int captureBufferFormat = 0; static int captureBufferFormat = 0;
static jobject captureBuffer = NULL; static jobject captureBuffer = NULL;
@ -1413,7 +1404,7 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
jclass exceptionClass = (*mEnv)->GetObjectClass(mEnv, exception); jclass exceptionClass = (*mEnv)->GetObjectClass(mEnv, exception);
jclass classClass = (*mEnv)->FindClass(mEnv, "java/lang/Class"); jclass classClass = (*mEnv)->FindClass(mEnv, "java/lang/Class");
jstring exceptionName; jstring exceptionName;
const char* exceptionNameUTF8; const char *exceptionNameUTF8;
jstring exceptionMessage; jstring exceptionMessage;
mid = (*mEnv)->GetMethodID(mEnv, classClass, "getName", "()Ljava/lang/String;"); mid = (*mEnv)->GetMethodID(mEnv, classClass, "getName", "()Ljava/lang/String;");
@ -1424,7 +1415,7 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
exceptionMessage = (jstring)(*mEnv)->CallObjectMethod(mEnv, exception, mid); exceptionMessage = (jstring)(*mEnv)->CallObjectMethod(mEnv, exception, mid);
if (exceptionMessage != NULL) { if (exceptionMessage != NULL) {
const char* exceptionMessageUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionMessage, 0); const char *exceptionMessageUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionMessage, 0);
SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8); SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8);
(*mEnv)->ReleaseStringUTFChars(mEnv, exceptionMessage, exceptionMessageUTF8); (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionMessage, exceptionMessageUTF8);
} else { } else {
@ -1440,7 +1431,7 @@ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent)
return SDL_FALSE; return SDL_FALSE;
} }
static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx) static int Internal_Android_JNI_FileOpen(SDL_RWops *ctx)
{ {
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
@ -1589,8 +1580,8 @@ failure:
return result; return result;
} }
int Android_JNI_FileOpen(SDL_RWops* ctx, int Android_JNI_FileOpen(SDL_RWops *ctx,
const char* fileName, const char* mode) const char *fileName, const char *mode)
{ {
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
JNIEnv *mEnv = Android_JNI_GetEnv(); JNIEnv *mEnv = Android_JNI_GetEnv();
@ -1619,7 +1610,7 @@ int Android_JNI_FileOpen(SDL_RWops* ctx,
return retval; return retval;
} }
size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, size_t Android_JNI_FileRead(SDL_RWops *ctx, void *buffer,
size_t size, size_t maxnum) size_t size, size_t maxnum)
{ {
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
@ -1682,14 +1673,14 @@ size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer,
} }
} }
size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer, size_t Android_JNI_FileWrite(SDL_RWops *ctx, const void *buffer,
size_t size, size_t num) size_t size, size_t num)
{ {
SDL_SetError("Cannot write to Android package filesystem"); SDL_SetError("Cannot write to Android package filesystem");
return 0; return 0;
} }
static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, SDL_bool release) static int Internal_Android_JNI_FileClose(SDL_RWops *ctx, SDL_bool release)
{ {
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
@ -1740,12 +1731,12 @@ static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, SDL_bool release)
} }
Sint64 Android_JNI_FileSize(SDL_RWops* ctx) Sint64 Android_JNI_FileSize(SDL_RWops *ctx)
{ {
return ctx->hidden.androidio.size; return ctx->hidden.androidio.size;
} }
Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) Sint64 Android_JNI_FileSeek(SDL_RWops *ctx, Sint64 offset, int whence)
{ {
if (ctx->hidden.androidio.assetFileDescriptorRef) { if (ctx->hidden.androidio.assetFileDescriptorRef) {
off_t ret; off_t ret;
@ -1829,14 +1820,14 @@ Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence)
} }
int Android_JNI_FileClose(SDL_RWops* ctx) int Android_JNI_FileClose(SDL_RWops *ctx)
{ {
return Internal_Android_JNI_FileClose(ctx, SDL_TRUE); return Internal_Android_JNI_FileClose(ctx, SDL_TRUE);
} }
int Android_JNI_SetClipboardText(const char* text) int Android_JNI_SetClipboardText(const char *text)
{ {
JNIEnv* env = Android_JNI_GetEnv(); JNIEnv *env = Android_JNI_GetEnv();
jstring string = (*env)->NewStringUTF(env, text); jstring string = (*env)->NewStringUTF(env, text);
(*env)->CallStaticVoidMethod(env, mActivityClass, midClipboardSetText, string); (*env)->CallStaticVoidMethod(env, mActivityClass, midClipboardSetText, string);
(*env)->DeleteLocalRef(env, string); (*env)->DeleteLocalRef(env, string);
@ -1845,13 +1836,13 @@ int Android_JNI_SetClipboardText(const char* text)
char* Android_JNI_GetClipboardText(void) char* Android_JNI_GetClipboardText(void)
{ {
JNIEnv* env = Android_JNI_GetEnv(); JNIEnv *env = Android_JNI_GetEnv();
char* text = NULL; char *text = NULL;
jstring string; jstring string;
string = (*env)->CallStaticObjectMethod(env, mActivityClass, midClipboardGetText); string = (*env)->CallStaticObjectMethod(env, mActivityClass, midClipboardGetText);
if (string) { if (string) {
const char* utf = (*env)->GetStringUTFChars(env, string, 0); const char *utf = (*env)->GetStringUTFChars(env, string, 0);
if (utf) { if (utf) {
text = SDL_strdup(utf); text = SDL_strdup(utf);
(*env)->ReleaseStringUTFChars(env, string, utf); (*env)->ReleaseStringUTFChars(env, string, utf);
@ -1864,7 +1855,7 @@ char* Android_JNI_GetClipboardText(void)
SDL_bool Android_JNI_HasClipboardText(void) SDL_bool Android_JNI_HasClipboardText(void)
{ {
JNIEnv* env = Android_JNI_GetEnv(); JNIEnv *env = Android_JNI_GetEnv();
jboolean retval = (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText); jboolean retval = (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText);
return (retval == JNI_TRUE) ? SDL_TRUE : SDL_FALSE; return (retval == JNI_TRUE) ? SDL_TRUE : SDL_FALSE;
} }
@ -1873,10 +1864,10 @@ SDL_bool Android_JNI_HasClipboardText(void)
* returns truthy or falsy value in plugged, charged and battery * returns truthy or falsy value in plugged, charged and battery
* returns the value in seconds and percent or -1 if not available * returns the value in seconds and percent or -1 if not available
*/ */
int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent) int Android_JNI_GetPowerInfo(int *plugged, int *charged, int *battery, int *seconds, int *percent)
{ {
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
JNIEnv* env = Android_JNI_GetEnv(); JNIEnv *env = Android_JNI_GetEnv();
jmethodID mid; jmethodID mid;
jobject context; jobject context;
jstring action; jstring action;
@ -2000,7 +1991,7 @@ int Android_JNI_GetTouchDeviceIds(int **ids) {
if (array) { if (array) {
number = (int) (*env)->GetArrayLength(env, array); number = (int) (*env)->GetArrayLength(env, array);
if (0 < number) { if (0 < number) {
jint* elements = (*env)->GetIntArrayElements(env, array, NULL); jint *elements = (*env)->GetIntArrayElements(env, array, NULL);
if (elements) { if (elements) {
int i; int i;
*ids = SDL_malloc(number * sizeof (**ids)); *ids = SDL_malloc(number * sizeof (**ids));

View File

@ -40,27 +40,27 @@ static void ANDROIDAUDIO_PauseDevices(void) {}
#endif #endif
static void static void
android_egl_context_restore() android_egl_context_restore(SDL_Window *window)
{ {
SDL_Event event; SDL_Event event;
SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context) < 0) { if (SDL_GL_MakeCurrent(window, (SDL_GLContext) data->egl_context) < 0) {
/* The context is no longer valid, create a new one */ /* The context is no longer valid, create a new one */
data->egl_context = (EGLContext) SDL_GL_CreateContext(Android_Window); data->egl_context = (EGLContext) SDL_GL_CreateContext(window);
SDL_GL_MakeCurrent(Android_Window, (SDL_GLContext) data->egl_context); SDL_GL_MakeCurrent(window, (SDL_GLContext) data->egl_context);
event.type = SDL_RENDER_DEVICE_RESET; event.type = SDL_RENDER_DEVICE_RESET;
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
} }
static void static void
android_egl_context_backup() android_egl_context_backup(SDL_Window *window)
{ {
/* Keep a copy of the EGL Context so we can try to restore it when we resume */ /* Keep a copy of the EGL Context so we can try to restore it when we resume */
SDL_WindowData *data = (SDL_WindowData *) Android_Window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
data->egl_context = SDL_GL_GetCurrentContext(); data->egl_context = SDL_GL_GetCurrentContext();
/* We need to do this so the EGLSurface can be freed */ /* We need to do this so the EGLSurface can be freed */
SDL_GL_MakeCurrent(Android_Window, NULL); SDL_GL_MakeCurrent(window, NULL);
} }
void void
@ -80,24 +80,24 @@ Android_PumpEvents(_THIS)
#if SDL_ANDROID_BLOCK_ON_PAUSE #if SDL_ANDROID_BLOCK_ON_PAUSE
if (isPaused && !isPausing) { if (isPaused && !isPausing) {
/* Make sure this is the last thing we do before pausing */ /* Make sure this is the last thing we do before pausing */
android_egl_context_backup(); android_egl_context_backup(Android_Window);
ANDROIDAUDIO_PauseDevices(); ANDROIDAUDIO_PauseDevices();
if(SDL_SemWait(Android_ResumeSem) == 0) { if (SDL_SemWait(Android_ResumeSem) == 0) {
#else #else
if (isPaused) { if (isPaused) {
if(SDL_SemTryWait(Android_ResumeSem) == 0) { if (SDL_SemTryWait(Android_ResumeSem) == 0) {
#endif #endif
isPaused = 0; isPaused = 0;
ANDROIDAUDIO_ResumeDevices(); ANDROIDAUDIO_ResumeDevices();
/* Restore the GL Context from here, as this operation is thread dependent */ /* Restore the GL Context from here, as this operation is thread dependent */
if (!SDL_HasEvent(SDL_QUIT)) { if (!SDL_HasEvent(SDL_QUIT)) {
android_egl_context_restore(); android_egl_context_restore(Android_Window);
} }
} }
} }
else { else {
#if SDL_ANDROID_BLOCK_ON_PAUSE #if SDL_ANDROID_BLOCK_ON_PAUSE
if( isPausing || SDL_SemTryWait(Android_PauseSem) == 0 ) { if (isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
/* We've been signaled to pause, but before we block ourselves, /* We've been signaled to pause, but before we block ourselves,
we need to make sure that certain key events have reached the app */ we need to make sure that certain key events have reached the app */
if (SDL_HasEvent(SDL_WINDOWEVENT) || SDL_HasEvent(SDL_APP_WILLENTERBACKGROUND) || SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND) ) { if (SDL_HasEvent(SDL_WINDOWEVENT) || SDL_HasEvent(SDL_APP_WILLENTERBACKGROUND) || SDL_HasEvent(SDL_APP_DIDENTERBACKGROUND) ) {
@ -109,8 +109,8 @@ Android_PumpEvents(_THIS)
} }
} }
#else #else
if(SDL_SemTryWait(Android_PauseSem) == 0) { if (SDL_SemTryWait(Android_PauseSem) == 0) {
android_egl_context_backup(); android_egl_context_backup(Android_Window);
ANDROIDAUDIO_PauseDevices(); ANDROIDAUDIO_PauseDevices();
isPaused = 1; isPaused = 1;
} }

View File

@ -62,7 +62,7 @@ Android_WrapCursor(int custom_cursor, int system_cursor)
cursor = SDL_calloc(1, sizeof(*cursor)); cursor = SDL_calloc(1, sizeof(*cursor));
if (cursor) { if (cursor) {
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*)SDL_calloc(1, sizeof(*data)); SDL_AndroidCursorData *data = (SDL_AndroidCursorData *)SDL_calloc(1, sizeof(*data));
if (data) { if (data) {
data->custom_cursor = custom_cursor; data->custom_cursor = custom_cursor;
data->system_cursor = system_cursor; data->system_cursor = system_cursor;
@ -141,13 +141,13 @@ Android_DestroyEmptyCursor()
} }
static int static int
Android_ShowCursor(SDL_Cursor * cursor) Android_ShowCursor(SDL_Cursor *cursor)
{ {
if (!cursor) { if (!cursor) {
cursor = Android_CreateEmptyCursor(); cursor = Android_CreateEmptyCursor();
} }
if (cursor) { if (cursor) {
SDL_AndroidCursorData *data = (SDL_AndroidCursorData*)cursor->driverdata; SDL_AndroidCursorData *data = (SDL_AndroidCursorData *)cursor->driverdata;
if (data->custom_cursor) { if (data->custom_cursor) {
if (!Android_JNI_SetCustomCursor(data->custom_cursor)) { if (!Android_JNI_SetCustomCursor(data->custom_cursor)) {
return SDL_Unsupported(); return SDL_Unsupported();
@ -220,12 +220,12 @@ TranslateButton(int state)
} }
void void
Android_OnMouse(int state, int action, float x, float y, SDL_bool relative) Android_OnMouse(SDL_Window *window, int state, int action, float x, float y, SDL_bool relative)
{ {
int changes; int changes;
Uint8 button; Uint8 button;
if (!Android_Window) { if (!window) {
return; return;
} }
@ -234,25 +234,25 @@ Android_OnMouse(int state, int action, float x, float y, SDL_bool relative)
changes = state & ~last_state; changes = state & ~last_state;
button = TranslateButton(changes); button = TranslateButton(changes);
last_state = state; last_state = state;
SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y); SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y);
SDL_SendMouseButton(Android_Window, 0, SDL_PRESSED, button); SDL_SendMouseButton(window, 0, SDL_PRESSED, button);
break; break;
case ACTION_UP: case ACTION_UP:
changes = last_state & ~state; changes = last_state & ~state;
button = TranslateButton(changes); button = TranslateButton(changes);
last_state = state; last_state = state;
SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y); SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y);
SDL_SendMouseButton(Android_Window, 0, SDL_RELEASED, button); SDL_SendMouseButton(window, 0, SDL_RELEASED, button);
break; break;
case ACTION_MOVE: case ACTION_MOVE:
case ACTION_HOVER_MOVE: case ACTION_HOVER_MOVE:
SDL_SendMouseMotion(Android_Window, 0, relative, (int)x, (int)y); SDL_SendMouseMotion(window, 0, relative, (int)x, (int)y);
break; break;
case ACTION_SCROLL: case ACTION_SCROLL:
SDL_SendMouseWheel(Android_Window, 0, x, y, SDL_MOUSEWHEEL_NORMAL); SDL_SendMouseWheel(window, 0, x, y, SDL_MOUSEWHEEL_NORMAL);
break; break;
default: default:

View File

@ -25,7 +25,7 @@
#include "SDL_androidvideo.h" #include "SDL_androidvideo.h"
extern void Android_InitMouse(void); extern void Android_InitMouse(void);
extern void Android_OnMouse(int button, int action, float x, float y, SDL_bool relative); extern void Android_OnMouse(SDL_Window *window, int button, int action, float x, float y, SDL_bool relative);
extern void Android_QuitMouse(void); extern void Android_QuitMouse(void);
#endif /* SDL_androidmouse_h_ */ #endif /* SDL_androidmouse_h_ */

View File

@ -40,12 +40,12 @@
#define ACTION_POINTER_DOWN 5 #define ACTION_POINTER_DOWN 5
#define ACTION_POINTER_UP 6 #define ACTION_POINTER_UP 6
static void Android_GetWindowCoordinates(float x, float y, static void Android_GetWindowCoordinates(SDL_Window *window, float x, float y,
int *window_x, int *window_y) int *window_x, int *window_y)
{ {
int window_w, window_h; int window_w, window_h;
SDL_GetWindowSize(Android_Window, &window_w, &window_h); SDL_GetWindowSize(window, &window_w, &window_h);
*window_x = (int)(x * window_w); *window_x = (int)(x * window_w);
*window_y = (int)(y * window_h); *window_y = (int)(y * window_h);
} }
@ -64,7 +64,7 @@ SeparateEventsHintWatcher(void *userdata, const char *name,
void Android_InitTouch(void) void Android_InitTouch(void)
{ {
int i; int i;
int* ids; int *ids;
const int number = Android_JNI_GetTouchDeviceIds(&ids); const int number = Android_JNI_GetTouchDeviceIds(&ids);
SDL_AddHintCallback(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH, SDL_AddHintCallback(SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH,
@ -85,14 +85,14 @@ void Android_QuitTouch(void)
separate_mouse_and_touch = SDL_FALSE; separate_mouse_and_touch = SDL_FALSE;
} }
void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p) void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
{ {
SDL_TouchID touchDeviceId = 0; SDL_TouchID touchDeviceId = 0;
SDL_FingerID fingerId = 0; SDL_FingerID fingerId = 0;
int window_x, window_y; int window_x, window_y;
static SDL_FingerID pointerFingerID = 0; static SDL_FingerID pointerFingerID = 0;
if (!Android_Window) { if (!window) {
return; return;
} }
@ -106,11 +106,11 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio
case ACTION_DOWN: case ACTION_DOWN:
/* Primary pointer down */ /* Primary pointer down */
if (!separate_mouse_and_touch) { if (!separate_mouse_and_touch) {
Android_GetWindowCoordinates(x, y, &window_x, &window_y); Android_GetWindowCoordinates(window, x, y, &window_x, &window_y);
/* send moved event */ /* send moved event */
SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y); SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
/* send mouse down event */ /* send mouse down event */
SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT); SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
} }
pointerFingerID = fingerId; pointerFingerID = fingerId;
case ACTION_POINTER_DOWN: case ACTION_POINTER_DOWN:
@ -121,9 +121,9 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio
case ACTION_MOVE: case ACTION_MOVE:
if (!pointerFingerID) { if (!pointerFingerID) {
if (!separate_mouse_and_touch) { if (!separate_mouse_and_touch) {
Android_GetWindowCoordinates(x, y, &window_x, &window_y); Android_GetWindowCoordinates(window, x, y, &window_x, &window_y);
/* send moved event */ /* send moved event */
SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y); SDL_SendMouseMotion(window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
} }
} }
SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p); SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
@ -133,7 +133,7 @@ void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int actio
/* Primary pointer up */ /* Primary pointer up */
if (!separate_mouse_and_touch) { if (!separate_mouse_and_touch) {
/* send mouse up */ /* send mouse up */
SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT); SDL_SendMouseButton(window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
} }
pointerFingerID = (SDL_FingerID) 0; pointerFingerID = (SDL_FingerID) 0;
case ACTION_POINTER_UP: case ACTION_POINTER_UP:

View File

@ -24,6 +24,6 @@
extern void Android_InitTouch(void); extern void Android_InitTouch(void);
extern void Android_QuitTouch(void); extern void Android_QuitTouch(void);
extern void Android_OnTouch( int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p); extern void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p);
/* vi: set ts=4 sw=4 expandtab: */ /* vi: set ts=4 sw=4 expandtab: */

View File

@ -22,8 +22,7 @@
#if SDL_VIDEO_DRIVER_ANDROID #if SDL_VIDEO_DRIVER_ANDROID
/* Android SDL video driver implementation /* Android SDL video driver implementation */
*/
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_mouse.h" #include "SDL_mouse.h"
@ -47,7 +46,7 @@
/* Initialization/Query functions */ /* Initialization/Query functions */
static int Android_VideoInit(_THIS); static int Android_VideoInit(_THIS);
static void Android_VideoQuit(_THIS); static void Android_VideoQuit(_THIS);
int Android_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi); int Android_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi);
#include "../SDL_egl_c.h" #include "../SDL_egl_c.h"
#define Android_GLES_GetProcAddress SDL_EGL_GetProcAddress #define Android_GLES_GetProcAddress SDL_EGL_GetProcAddress
@ -69,9 +68,6 @@ static int Android_ScreenRate = 0;
SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL; SDL_sem *Android_PauseSem = NULL, *Android_ResumeSem = NULL;
/* Currently only one window */
SDL_Window *Android_Window = NULL;
static int static int
Android_Available(void) Android_Available(void)
{ {
@ -85,7 +81,7 @@ Android_SuspendScreenSaver(_THIS)
} }
static void static void
Android_DeleteDevice(SDL_VideoDevice * device) Android_DeleteDevice(SDL_VideoDevice *device)
{ {
SDL_free(device->driverdata); SDL_free(device->driverdata);
SDL_free(device); SDL_free(device);
@ -104,7 +100,7 @@ Android_CreateDevice(int devindex)
return NULL; return NULL;
} }
data = (SDL_VideoData*) SDL_calloc(1, sizeof(SDL_VideoData)); data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
if (!data) { if (!data) {
SDL_OutOfMemory(); SDL_OutOfMemory();
SDL_free(device); SDL_free(device);
@ -206,15 +202,15 @@ Android_VideoQuit(_THIS)
} }
int int
Android_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi) Android_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
{ {
return Android_JNI_GetDisplayDPI(ddpi, hdpi, vdpi); return Android_JNI_GetDisplayDPI(ddpi, hdpi, vdpi);
} }
void void
Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate) Android_SetScreenResolution(SDL_Window *window, int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate)
{ {
SDL_VideoDevice* device; SDL_VideoDevice *device;
SDL_VideoDisplay *display; SDL_VideoDisplay *display;
Android_SurfaceWidth = surfaceWidth; Android_SurfaceWidth = surfaceWidth;
Android_SurfaceHeight = surfaceHeight; Android_SurfaceHeight = surfaceHeight;
@ -239,10 +235,10 @@ Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth
display->desktop_mode.refresh_rate = Android_ScreenRate; display->desktop_mode.refresh_rate = Android_ScreenRate;
} }
if (Android_Window) { if (window) {
/* Force the current mode to match the resize otherwise the SDL_WINDOWEVENT_RESTORED event /* Force the current mode to match the resize otherwise the SDL_WINDOWEVENT_RESTORED event
* will fall back to the old mode */ * will fall back to the old mode */
display = SDL_GetDisplayForWindow(Android_Window); display = SDL_GetDisplayForWindow(window);
display->display_modes[0].format = format; display->display_modes[0].format = format;
display->display_modes[0].w = Android_DeviceWidth; display->display_modes[0].w = Android_DeviceWidth;
@ -250,7 +246,7 @@ Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth
display->display_modes[0].refresh_rate = (int)rate; display->display_modes[0].refresh_rate = (int)rate;
display->current_mode = display->display_modes[0]; display->current_mode = display->display_modes[0];
SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESIZED, surfaceWidth, surfaceHeight); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, surfaceWidth, surfaceHeight);
} }
} }

View File

@ -28,7 +28,7 @@
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
/* Called by the JNI layer when the screen changes size or format */ /* Called by the JNI layer when the screen changes size or format */
extern void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate); extern void Android_SetScreenResolution(SDL_Window *window, int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate);
/* Private display data */ /* Private display data */
@ -42,8 +42,6 @@ extern int Android_SurfaceHeight;
extern int Android_DeviceWidth; extern int Android_DeviceWidth;
extern int Android_DeviceHeight; extern int Android_DeviceHeight;
extern SDL_sem *Android_PauseSem, *Android_ResumeSem; extern SDL_sem *Android_PauseSem, *Android_ResumeSem;
extern SDL_Window *Android_Window;
#endif /* SDL_androidvideo_h_ */ #endif /* SDL_androidvideo_h_ */

View File

@ -33,6 +33,9 @@
#include "SDL_androidwindow.h" #include "SDL_androidwindow.h"
#include "SDL_hints.h" #include "SDL_hints.h"
/* Currently only one window */
SDL_Window *Android_Window = NULL;
int int
Android_CreateWindow(_THIS, SDL_Window * window) Android_CreateWindow(_THIS, SDL_Window * window)
{ {
@ -94,13 +97,13 @@ Android_CreateWindow(_THIS, SDL_Window * window)
} }
void void
Android_SetWindowTitle(_THIS, SDL_Window * window) Android_SetWindowTitle(_THIS, SDL_Window *window)
{ {
Android_JNI_SetActivityTitle(window->title); Android_JNI_SetActivityTitle(window->title);
} }
void void
Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
{ {
/* If the window is being destroyed don't change visible state */ /* If the window is being destroyed don't change visible state */
if (!window->is_destroying) { if (!window->is_destroying) {
@ -117,7 +120,7 @@ Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * displ
return; return;
} }
SDL_WindowData * data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
if (!data || !data->native_window) { if (!data || !data->native_window) {
return; return;
@ -135,7 +138,7 @@ Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * displ
} }
void void
Android_DestroyWindow(_THIS, SDL_Window * window) Android_DestroyWindow(_THIS, SDL_Window *window)
{ {
SDL_WindowData *data; SDL_WindowData *data;
@ -161,7 +164,7 @@ Android_DestroyWindow(_THIS, SDL_Window * window)
} }
SDL_bool SDL_bool
Android_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
{ {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;

View File

@ -26,17 +26,18 @@
#include "../../core/android/SDL_android.h" #include "../../core/android/SDL_android.h"
#include "../SDL_egl_c.h" #include "../SDL_egl_c.h"
extern int Android_CreateWindow(_THIS, SDL_Window * window); extern int Android_CreateWindow(_THIS, SDL_Window *window);
extern void Android_SetWindowTitle(_THIS, SDL_Window * window); extern void Android_SetWindowTitle(_THIS, SDL_Window *window);
extern void Android_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); extern void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen);
extern void Android_DestroyWindow(_THIS, SDL_Window * window); extern void Android_DestroyWindow(_THIS, SDL_Window *window);
extern SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo * info); extern SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info);
extern SDL_Window *Android_Window;
typedef struct typedef struct
{ {
EGLSurface egl_surface; EGLSurface egl_surface;
EGLContext egl_context; /* We use this to preserve the context when losing focus */ EGLContext egl_context; /* We use this to preserve the context when losing focus */
ANativeWindow* native_window; ANativeWindow *native_window;
} SDL_WindowData; } SDL_WindowData;