diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index 7ebecdd023..4a0bdfc8d1 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -378,24 +378,6 @@ static void *android_input_init(void) static void android_input_poll(void *data) { - (void)data; - - RARCH_PERFORMANCE_INIT(input_poll); - RARCH_PERFORMANCE_START(input_poll); - - struct android_app* android_app = (struct android_app*)g_android; - - engine_handle_input(android_app, 0); -#if 0 - { - char msg[64]; - snprintf(msg, sizeof(msg), "Pointers: %u", pointer_count); - msg_queue_clear(g_extern.msg_queue); - msg_queue_push(g_extern.msg_queue, msg, 0, 30); - } -#endif - - RARCH_PERFORMANCE_STOP(input_poll); } static int16_t android_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id) diff --git a/frontend/frontend_android.c b/frontend/frontend_android.c index c7a17379e1..6064c8ca65 100644 --- a/frontend/frontend_android.c +++ b/frontend/frontend_android.c @@ -230,9 +230,7 @@ static void *android_app_entry(void *data) { RARCH_LOG("RetroArch started.\n"); - while ((input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ? - android_run_events(android_app) : - rarch_main_iterate()); + while (rarch_main_iterate()); RARCH_LOG("RetroArch stopped.\n"); } diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index ce0e76633d..8ad0e45c4d 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -172,8 +172,6 @@ static void gfx_ctx_check_window(bool *quit, { (void)frame_count; - struct android_app *android_app = (struct android_app*)g_android; - *quit = false; unsigned new_width, new_height; @@ -185,21 +183,6 @@ static void gfx_ctx_check_window(bool *quit, *resize = true; } - RARCH_PERFORMANCE_INIT(alooper_pollonce); - RARCH_PERFORMANCE_START(alooper_pollonce); - - while (ALooper_pollOnce(0, NULL, NULL, NULL) == LOOPER_ID_MAIN) - { - int8_t cmd; - - if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd)) - cmd = -1; - - engine_handle_cmd(android_app, cmd); - } - - RARCH_PERFORMANCE_STOP(alooper_pollonce); - // Check if we are exiting. if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY)) *quit = true; diff --git a/retroarch.c b/retroarch.c index dc3345e5d2..e9d0c21bd1 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2792,6 +2792,34 @@ bool rarch_main_iterate(void) return false; } +#ifdef ANDROID + struct android_app *android_app = (struct android_app*)g_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) + { + int8_t cmd; + + if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd)) + cmd = -1; + + engine_handle_cmd(android_app, cmd); + + if (cmd == APP_CMD_INIT_WINDOW) + { + if (g_extern.lifecycle_state & (1ULL << RARCH_PAUSE_TOGGLE)) + init_drivers(); + } + } + else if (!input_key_pressed_func(RARCH_PAUSE_TOGGLE)) + engine_handle_input(android_app, 0); + else + return true; + } +#endif + // Time to drop? if (input_key_pressed_func(RARCH_QUIT_KEY) || !video_alive_func())