(Android) android_input_poll now only reads and processes input

events - check_window polls for system messages once
This commit is contained in:
twinaphex 2012-12-16 02:04:13 +01:00
parent 7076685a1e
commit cf539edf91
2 changed files with 65 additions and 69 deletions

View File

@ -274,18 +274,10 @@ static void android_input_poll(void *data)
{
(void)data;
// Read all pending events.
struct android_app* android_app = g_android.app;
int id;
while((id = ALooper_pollOnce(0, NULL, NULL, NULL)) == ALOOPER_POLL_CALLBACK);
// Process this event.
while(id >= 0)
{
bool looper_input_do = id == LOOPER_ID_INPUT;
if(looper_input_do && AInputQueue_hasEvents(android_app->inputQueue))
// Read all pending events.
while(AInputQueue_hasEvents(android_app->inputQueue))
{
AInputEvent* event = NULL;
AInputQueue_getEvent(android_app->inputQueue, &event);
@ -316,7 +308,7 @@ static void android_input_poll(void *data)
state[i] |= PRESSED_UP(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
state[i] |= PRESSED_DOWN(x, y) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
}
else if(type == AINPUT_EVENT_TYPE_KEY)
else
{
int keycode = AKeyEvent_getKeyCode(event);
uint64_t input_state = keycode_lut[keycode];
@ -340,22 +332,6 @@ static void android_input_poll(void *data)
}
AInputQueue_finishEvent(android_app->inputQueue, event, handled);
}
else if(!looper_input_do)
{
int8_t cmd;
if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd))
{
if(cmd == APP_CMD_SAVE_STATE)
free_saved_state(android_app);
}
else
cmd = -1;
engine_handle_cmd(android_app, cmd);
}
while((id = ALooper_pollOnce(0, NULL, NULL, NULL)) == ALOOPER_POLL_CALLBACK);
}
}
static int16_t android_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)

View File

@ -211,9 +211,29 @@ static void gfx_ctx_check_window(bool *quit,
(void)height;
(void)frame_count;
int id;
struct android_app* android_app = g_android.app;
*quit = false;
*resize = false;
while((id = ALooper_pollOnce(0, NULL, NULL, NULL)) == ALOOPER_POLL_CALLBACK);
if(id == LOOPER_ID_MAIN)
{
int8_t cmd;
if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd))
{
if(cmd == APP_CMD_SAVE_STATE)
free_saved_state(android_app);
}
else
cmd = -1;
engine_handle_cmd(android_app, cmd);
}
if (g_android.reinit_video)
{
uninit_drivers();