(Android) Rename g_android.input_state to g_extern.lifecycle_state

- intend to use this for RMenu as well
This commit is contained in:
twinaphex 2012-12-14 02:06:14 +01:00
parent 66180308e4
commit e1918b2ba6
5 changed files with 24 additions and 21 deletions

View File

@ -24,13 +24,12 @@ struct saved_state
{ {
int32_t x; int32_t x;
int32_t y; int32_t y;
uint64_t input_state; uint64_t lifecycle_state;
}; };
struct droid struct droid
{ {
struct android_app* app; struct android_app* app;
uint64_t input_state;
unsigned width; unsigned width;
unsigned height; unsigned height;
struct saved_state state; struct saved_state state;

View File

@ -328,7 +328,7 @@ static void android_input_poll(void *data)
} }
else if(input_state != -1) else if(input_state != -1)
{ {
g_android.input_state = input_state; g_extern.lifecycle_state = input_state;
handled = 0; handled = 0;
} }
} }
@ -376,9 +376,9 @@ static bool android_input_key_pressed(void *data, int key)
{ {
(void)data; (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; return true;
else if(g_android.input_state & (1ULL << key)) else if(g_extern.lifecycle_state & (1ULL << key))
return true; return true;
return false; return false;

View File

@ -145,7 +145,7 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
/* The window is being shown, get it ready. */ /* The window is being shown, get it ready. */
android_app->window = android_app->pendingWindow; 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(); gfx_ctx_init();
g_extern.audio_active = true; 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); pthread_mutex_unlock(&android_app->mutex);
if (android_app->window != NULL) if (android_app->window != NULL)
g_android.input_state |= (1ULL << RARCH_WINDOW_READY); g_extern.lifecycle_state |= (1ULL << RARCH_WINDOW_READY);
break; break;
case APP_CMD_RESUME: 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); pthread_mutex_unlock(&android_app->mutex);
/* EXEC */ /* EXEC */
if(g_android.input_state & (1ULL << RARCH_QUIT_KEY)) { } if(g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY)) { }
else else
{ {
/* Setting reentrancy */ /* Setting reentrancy */
RARCH_LOG("Setting up RetroArch re-entrancy...\n"); 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.audio_active = false;
g_extern.video_active = false; g_extern.video_active = false;
g_android.activity_paused = true; g_android.activity_paused = true;
@ -231,7 +231,7 @@ void engine_handle_cmd(struct android_app* android_app, int32_t cmd)
/* EXEC */ /* EXEC */
/* The window is being hidden or closed, clean it up. */ /* The window is being hidden or closed, clean it up. */
/* terminate display/EGL context here */ /* terminate display/EGL context here */
if(g_android.input_state & (1ULL << RARCH_REENTRANT)) if(g_extern.lifecycle_state & (1ULL << RARCH_REENTRANT))
gfx_ctx_destroy(); gfx_ctx_destroy();
/* POSTEXEC */ /* POSTEXEC */
@ -381,10 +381,10 @@ static void* android_app_entry(void* param)
// We are starting with a previous saved state; restore from it. // We are starting with a previous saved state; restore from it.
RARCH_LOG("Restoring reentrant savestate.\n"); RARCH_LOG("Restoring reentrant savestate.\n");
g_android.state = *(struct saved_state*)android_app->savedState; 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) 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); 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)) if(!android_run_events(android_app))
goto exit; goto exit;
@ -428,13 +428,13 @@ static void* android_app_entry(void* param)
/* We've done everything state-wise needed for RARCH_REENTRANT, /* We've done everything state-wise needed for RARCH_REENTRANT,
* get rid of it now */ * 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) else if ((init_ret = rarch_main_init(argc, argv)) != 0)
{ {
RARCH_LOG("Initialization failed.\n"); RARCH_LOG("Initialization failed.\n");
g_android.input_state |= (1ULL << RARCH_QUIT_KEY); g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
g_android.input_state |= (1ULL << RARCH_KILL); g_extern.lifecycle_state |= (1ULL << RARCH_KILL);
} }
else else
RARCH_LOG("Initializing succeeded.\n"); RARCH_LOG("Initializing succeeded.\n");
@ -454,7 +454,7 @@ static void* android_app_entry(void* param)
} }
exit: 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_LOG("Deinitializing RetroArch...\n");
rarch_main_deinit(); rarch_main_deinit();
@ -465,10 +465,10 @@ exit:
rarch_main_clear_state(); rarch_main_clear_state();
/* Make sure to quit RetroArch later on too */ /* 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!"); RARCH_LOG("android_app_destroy!");
free_saved_state(android_app); free_saved_state(android_app);

View File

@ -574,6 +574,10 @@ struct global
#endif #endif
} console; } console;
#if defined(ANDROID) || defined(HAVE_RMENU)
uint64_t lifecycle_state;
#endif
struct struct
{ {
char rom_path[PATH_MAX]; char rom_path[PATH_MAX];

View File

@ -165,7 +165,7 @@ static bool gfx_ctx_init(void)
goto error; 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"); 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. // 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; *quit = true;
} }