(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 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;

View File

@ -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;

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. */
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);

View File

@ -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];

View File

@ -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;
}