(Android) Reimplemented input loop - better throughput/latency

This commit is contained in:
twinaphex 2013-03-02 23:53:06 +01:00
parent ff88dc759c
commit ec114db356
4 changed files with 29 additions and 38 deletions

View File

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

View File

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

View File

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

View File

@ -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())