mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 18:35:22 +00:00
Refactor Android-specific polling logic.
This commit is contained in:
parent
69192932fc
commit
cae578fe73
@ -176,6 +176,20 @@ static bool android_app_start_main(struct android_app *android_app, int *init_re
|
||||
}
|
||||
}
|
||||
|
||||
// Handle all events. If our activity is in pause state, block until we're unpaused.
|
||||
static void android_handle_events(void)
|
||||
{
|
||||
int ident;
|
||||
while ((ident = ALooper_pollAll((input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ? -1 : 0,
|
||||
NULL, NULL, NULL)) >= 0)
|
||||
{
|
||||
if (ident == LOOPER_ID_MAIN)
|
||||
engine_handle_cmd();
|
||||
else if (!input_key_pressed_func(RARCH_PAUSE_TOGGLE))
|
||||
engine_handle_input();
|
||||
}
|
||||
}
|
||||
|
||||
static void *android_app_entry(void *data)
|
||||
{
|
||||
struct android_app* android_app = (struct android_app*)data;
|
||||
@ -216,7 +230,11 @@ static void *android_app_entry(void *data)
|
||||
{
|
||||
RARCH_LOG("RetroArch started.\n");
|
||||
|
||||
while (rarch_main_iterate());
|
||||
// Main loop
|
||||
do
|
||||
{
|
||||
android_handle_events();
|
||||
} while (rarch_main_iterate());
|
||||
|
||||
RARCH_LOG("RetroArch stopped.\n");
|
||||
}
|
||||
|
14
retroarch.c
14
retroarch.c
@ -2792,20 +2792,6 @@ bool rarch_main_iterate(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
int ident;
|
||||
|
||||
while ((ident = ALooper_pollAll( (input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ? -1 : 0, NULL, NULL, NULL)) >= 0)
|
||||
{
|
||||
if (ident == LOOPER_ID_MAIN)
|
||||
engine_handle_cmd();
|
||||
else if (!input_key_pressed_func(RARCH_PAUSE_TOGGLE))
|
||||
engine_handle_input();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Time to drop?
|
||||
if (input_key_pressed_func(RARCH_QUIT_KEY) ||
|
||||
!video_alive_func())
|
||||
|
Loading…
x
Reference in New Issue
Block a user