mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-21 00:05:30 +00:00
(Android) Reimplemented input loop - better throughput/latency
This commit is contained in:
parent
ff88dc759c
commit
ec114db356
@ -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)
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
28
retroarch.c
28
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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user