From e1918b2ba616e565435d72a2c07c8406fc1eb01e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 14 Dec 2012 02:06:14 +0100 Subject: [PATCH] (Android) Rename g_android.input_state to g_extern.lifecycle_state - intend to use this for RMenu as well --- android/native/jni/android_general.h | 3 +-- android/native/jni/input_android.c | 6 +++--- android/native/jni/main.c | 28 ++++++++++++++-------------- general.h | 4 ++++ gfx/context/androidegl_ctx.c | 4 ++-- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/android/native/jni/android_general.h b/android/native/jni/android_general.h index 7316c5c3e7..e51f8630b5 100644 --- a/android/native/jni/android_general.h +++ b/android/native/jni/android_general.h @@ -24,13 +24,12 @@ struct saved_state { int32_t x; int32_t y; - uint64_t input_state; + uint64_t lifecycle_state; }; struct droid { struct android_app* app; - uint64_t input_state; unsigned width; unsigned height; struct saved_state state; diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index 10e82a5e75..7c781d22a7 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -328,7 +328,7 @@ static void android_input_poll(void *data) } else if(input_state != -1) { - g_android.input_state = input_state; + g_extern.lifecycle_state = input_state; handled = 0; } } @@ -376,9 +376,9 @@ static bool android_input_key_pressed(void *data, int key) { (void)data; - if(key == RARCH_QUIT_KEY && (g_android.input_state & (1ULL << RARCH_KILL))) + if(key == RARCH_QUIT_KEY && (g_extern.lifecycle_state & (1ULL << RARCH_KILL))) return true; - else if(g_android.input_state & (1ULL << key)) + else if(g_extern.lifecycle_state & (1ULL << key)) return true; return false; diff --git a/android/native/jni/main.c b/android/native/jni/main.c index 5bfcd95274..defaadf7b4 100644 --- a/android/native/jni/main.c +++ b/android/native/jni/main.c @@ -145,7 +145,7 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd) /* The window is being shown, get it ready. */ android_app->window = android_app->pendingWindow; - if (g_android.input_state & (1ULL << RARCH_REENTRANT)) + if (g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT)) { gfx_ctx_init(); g_extern.audio_active = true; @@ -157,7 +157,7 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd) pthread_mutex_unlock(&android_app->mutex); if (android_app->window != NULL) - g_android.input_state |= (1ULL << RARCH_WINDOW_READY); + g_extern.lifecycle_state |= (1ULL << RARCH_WINDOW_READY); break; case APP_CMD_RESUME: @@ -194,12 +194,12 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd) pthread_mutex_unlock(&android_app->mutex); /* EXEC */ - if(g_android.input_state & (1ULL << RARCH_QUIT_KEY)) { } + if(g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY)) { } else { /* Setting reentrancy */ RARCH_LOG("Setting up RetroArch re-entrancy...\n"); - g_android.input_state |= (1ULL << RARCH_REENTRANT); + g_extern.lifecycle_state |= (1ULL << RARCH_REENTRANT); g_extern.audio_active = false; g_extern.video_active = false; g_android.activity_paused = true; @@ -231,7 +231,7 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd) /* EXEC */ /* The window is being hidden or closed, clean it up. */ /* terminate display/EGL context here */ - if(g_android.input_state & (1ULL << RARCH_REENTRANT)) + if(g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT)) gfx_ctx_destroy(); /* POSTEXEC */ @@ -381,10 +381,10 @@ static void* android_app_entry(void* param) // We are starting with a previous saved state; restore from it. RARCH_LOG("Restoring reentrant savestate.\n"); g_android.state = *(struct saved_state*)android_app->savedState; - g_android.input_state = g_android.state.input_state; + g_extern.lifecycle_state = g_android.state.lifecycle_state; } - bool rarch_reentrant = (g_android.input_state & (1ULL << RARCH_REENTRANT)); + bool rarch_reentrant = (g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT)); if(rarch_reentrant) { @@ -414,7 +414,7 @@ static void* android_app_entry(void* param) RARCH_LOG("Setting RetroArch video refresh rate to: %.2fHz.\n", g_android.disp_refresh_rate); - while(!(g_android.input_state & (1ULL << RARCH_WINDOW_READY))) + while(!(g_extern.lifecycle_state & (1ULL << RARCH_WINDOW_READY))) { if(!android_run_events(android_app)) goto exit; @@ -428,13 +428,13 @@ static void* android_app_entry(void* param) /* We've done everything state-wise needed for RARCH_REENTRANT, * get rid of it now */ - g_android.input_state &= ~(1ULL << RARCH_REENTRANT); + g_extern.lifecycle_state &= ~(1ULL << RARCH_REENTRANT); } else if ((init_ret = rarch_main_init(argc, argv)) != 0) { RARCH_LOG("Initialization failed.\n"); - g_android.input_state |= (1ULL << RARCH_QUIT_KEY); - g_android.input_state |= (1ULL << RARCH_KILL); + g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY); + g_extern.lifecycle_state |= (1ULL << RARCH_KILL); } else RARCH_LOG("Initializing succeeded.\n"); @@ -454,7 +454,7 @@ static void* android_app_entry(void* param) } exit: - if(g_android.input_state & (1ULL << RARCH_QUIT_KEY)) + if(g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY)) { RARCH_LOG("Deinitializing RetroArch...\n"); rarch_main_deinit(); @@ -465,10 +465,10 @@ exit: rarch_main_clear_state(); /* Make sure to quit RetroArch later on too */ - g_android.input_state |= (1ULL << RARCH_KILL); + g_extern.lifecycle_state |= (1ULL << RARCH_KILL); } - if(g_android.input_state & (1ULL << RARCH_KILL)) + if(g_extern.lifecycle_state & (1ULL << RARCH_KILL)) { RARCH_LOG("android_app_destroy!"); free_saved_state(android_app); diff --git a/general.h b/general.h index 5300fb3d99..c7e16622e8 100644 --- a/general.h +++ b/general.h @@ -574,6 +574,10 @@ struct global #endif } console; +#if defined(ANDROID) || defined(HAVE_RMENU) + uint64_t lifecycle_state; +#endif + struct { char rom_path[PATH_MAX]; diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index 7c70dca826..79bf425f5e 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -165,7 +165,7 @@ static bool gfx_ctx_init(void) goto error; } - if (g_android.input_state & (1ULL << RARCH_REENTRANT)) + if (g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT)) { RARCH_LOG("[ANDROID/EGL]: Setting up reentrant state.\n"); @@ -234,7 +234,7 @@ static void gfx_ctx_check_window(bool *quit, } // Check if we are exiting. - if (g_android.app->destroyRequested != 0 || (g_android.input_state & (1ULL << RARCH_KILL))) + if (g_android.app->destroyRequested != 0 || (g_extern.lifecycle_state & (1ULL << RARCH_KILL))) *quit = true; }