diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index 7a7dbfe88e..608f7db316 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -83,8 +83,6 @@ void engine_handle_cmd(void) switch (cmd) { case APP_CMD_INPUT_CHANGED: - RARCH_LOG("APP_CMD_INPUT_CHANGED\n"); - pthread_mutex_lock(&android_app->mutex); if (android_app->inputQueue != NULL) @@ -106,8 +104,6 @@ void engine_handle_cmd(void) break; case APP_CMD_INIT_WINDOW: - RARCH_LOG("engine_handle_cmd: APP_CMD_INIT_WINDOW.\n"); - pthread_mutex_lock(&android_app->mutex); android_app->window = android_app->pendingWindow; pthread_cond_broadcast(&android_app->cond); @@ -118,8 +114,6 @@ void engine_handle_cmd(void) break; case APP_CMD_RESUME: - RARCH_LOG("engine_handle_cmd: APP_CMD_RESUME.\n"); - pthread_mutex_lock(&android_app->mutex); android_app->activityState = cmd; pthread_cond_broadcast(&android_app->cond); @@ -127,8 +121,6 @@ void engine_handle_cmd(void) break; case APP_CMD_START: - RARCH_LOG("engine_handle_cmd: APP_CMD_START.\n"); - pthread_mutex_lock(&android_app->mutex); android_app->activityState = cmd; pthread_cond_broadcast(&android_app->cond); @@ -136,8 +128,6 @@ void engine_handle_cmd(void) break; case APP_CMD_PAUSE: - RARCH_LOG("engine_handle_cmd: APP_CMD_PAUSE.\n"); - pthread_mutex_lock(&android_app->mutex); android_app->activityState = cmd; pthread_cond_broadcast(&android_app->cond); @@ -151,8 +141,6 @@ void engine_handle_cmd(void) break; case APP_CMD_STOP: - RARCH_LOG("engine_handle_cmd: APP_CMD_STOP.\n"); - pthread_mutex_lock(&android_app->mutex); android_app->activityState = cmd; pthread_cond_broadcast(&android_app->cond); @@ -160,12 +148,8 @@ void engine_handle_cmd(void) break; case APP_CMD_CONFIG_CHANGED: - RARCH_LOG("engine_handle_cmd: APP_CMD_CONFIG_CHANGED.\n"); break; - case APP_CMD_TERM_WINDOW: - RARCH_LOG("engine_handle_cmd: APP_CMD_TERM_WINDOW.\n"); - pthread_mutex_lock(&android_app->mutex); /* The window is being hidden or closed, clean it up. */ @@ -181,17 +165,13 @@ void engine_handle_cmd(void) break; case APP_CMD_GAINED_FOCUS: - RARCH_LOG("engine_handle_cmd: APP_CMD_GAINED_FOCUS.\n"); - g_extern.lifecycle_state &= ~(1ULL << RARCH_PAUSE_TOGGLE); break; case APP_CMD_LOST_FOCUS: - RARCH_LOG("engine_handle_cmd: APP_CMD_LOST_FOCUS.\n"); break; case APP_CMD_DESTROY: - RARCH_LOG("engine_handle_cmd: APP_CMD_DESTROY\n"); g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY); break; } @@ -410,19 +390,6 @@ static inline void engine_handle_input(void) } } -// Handle all events. If our activity is in pause state, block until we're unpaused. -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_input_init(void) { @@ -485,8 +452,19 @@ static void *android_input_init(void) return (void*)-1; } +// Handle all events. If our activity is in pause state, block until we're unpaused. + static void android_input_poll(void *data) { + 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 int16_t android_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id) diff --git a/driver_funcs.h b/driver_funcs.h index 3d5521f588..076c3585aa 100644 --- a/driver_funcs.h +++ b/driver_funcs.h @@ -46,9 +46,11 @@ #define video_free_func() driver.video->free(driver.video_data) #define input_init_func() driver.input->init() #ifdef HAVE_ASYNC_POLL +#define input_async_poll_func() driver.input->poll(driver.input_data) #define input_poll_func() #else #define input_poll_func() driver.input->poll(driver.input_data) +#define input_async_poll_func() #endif #define input_input_state_func(retro_keybinds, port, device, index, id) \ driver.input->input_state(driver.input_data, retro_keybinds, port, device, index, id) @@ -153,6 +155,7 @@ static inline bool input_key_pressed_func(int key) #define gfx_ctx_window_has_focus() (true) #define input_init_func() MAKENAME_INPUT(_input_init)() +#define input_async_poll_func() #define input_poll_func() MAKENAME_INPUT(_input_poll)(driver.input_data) #define input_input_state_func(retro_keybinds, port, device, index, id) \ MAKENAME_INPUT(_input_state)(driver.input_data, retro_keybinds, port, device, index, id) diff --git a/frontend/frontend_android.c b/frontend/frontend_android.c index 6c7e39ba12..1747a0dc16 100644 --- a/frontend/frontend_android.c +++ b/frontend/frontend_android.c @@ -219,7 +219,7 @@ static void *android_app_entry(void *data) // Main loop do { - android_handle_events(); + input_async_poll_func(); } while (rarch_main_iterate()); RARCH_LOG("RetroArch stopped.\n"); diff --git a/frontend/frontend_android.h b/frontend/frontend_android.h index 71d87e237c..6592f5b85d 100644 --- a/frontend/frontend_android.h +++ b/frontend/frontend_android.h @@ -156,7 +156,6 @@ enum { int8_t android_app_read_cmd (void *data); extern void engine_app_read_cmd(void); extern void engine_handle_cmd(void); -extern void android_handle_events(void); extern struct android_app *g_android;