(Android) Try to prevent race condition causing ANRs when two input devices
are being pressed at the same time - see http://ps3computing.blogspot.nl/2012/12/anr-application-not-responding.html
This commit is contained in:
parent
b3d971f490
commit
c65e85f3df
|
@ -89,30 +89,35 @@ static void android_input_poll(void *data)
|
|||
bool debug_enable = g_settings.input.debug_enable;
|
||||
struct android_app* android_app = (struct android_app*)g_android;
|
||||
uint64_t *lifecycle_state = &g_extern.lifecycle_state;
|
||||
AInputEvent* event = NULL;
|
||||
|
||||
*lifecycle_state &= ~((1ULL << RARCH_RESET) | (1ULL << RARCH_REWIND) | (1ULL << RARCH_FAST_FORWARD_KEY) | (1ULL << RARCH_FAST_FORWARD_HOLD_KEY) | (1ULL << RARCH_MUTE) | (1ULL << RARCH_SAVE_STATE_KEY) | (1ULL << RARCH_LOAD_STATE_KEY) | (1ULL << RARCH_STATE_SLOT_PLUS) | (1ULL << RARCH_STATE_SLOT_MINUS));
|
||||
|
||||
// Read all pending events.
|
||||
while (AInputQueue_hasEvents(android_app->inputQueue) > 0)
|
||||
while (AInputQueue_hasEvents(android_app->inputQueue))
|
||||
{
|
||||
if (AInputQueue_getEvent(android_app->inputQueue, &event) >= 0)
|
||||
{
|
||||
AInputEvent* event = NULL;
|
||||
if (AInputQueue_getEvent(android_app->inputQueue, &event) < 0)
|
||||
break;
|
||||
|
||||
bool long_msg_enable = false;
|
||||
int32_t handled = 1;
|
||||
int action = 0;
|
||||
char msg[128];
|
||||
msg[0] = 0;
|
||||
int source, id, predispatched, keycode, type_event, state_id;
|
||||
|
||||
int source = AInputEvent_getSource(event);
|
||||
int id = AInputEvent_getDeviceId(event);
|
||||
msg[0] = 0;
|
||||
predispatched =AInputQueue_preDispatchEvent(android_app->inputQueue,event);
|
||||
|
||||
if (predispatched)
|
||||
continue;
|
||||
|
||||
source = AInputEvent_getSource(event);
|
||||
id = AInputEvent_getDeviceId(event);
|
||||
if (id == zeus_second_id)
|
||||
id = zeus_id;
|
||||
int keycode = AKeyEvent_getKeyCode(event);
|
||||
keycode = AKeyEvent_getKeyCode(event);
|
||||
|
||||
int type_event = AInputEvent_getType(event);
|
||||
int state_id = -1;
|
||||
type_event = AInputEvent_getType(event);
|
||||
state_id = -1;
|
||||
|
||||
if (source & (AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD))
|
||||
state_id = 0; // touch overlay is always player 1
|
||||
|
@ -253,6 +258,7 @@ static void android_input_poll(void *data)
|
|||
|
||||
AInputQueue_finishEvent(android_app->inputQueue, event, handled);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue