Created
July 4, 2014 23:57
-
-
Save omo/30c01500ddb5e27fcba8 to your computer and use it in GitHub Desktop.
status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime, bool* outConsumedBatch)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, | |
bool consumeBatches, nsecs_t frameTime, bool* outConsumedBatch) { | |
.... | |
ScopedLocalRef<jobject> receiverObj(env, NULL); | |
bool skipCallbacks = false; | |
for (;;) { | |
uint32_t seq; | |
InputEvent* inputEvent; | |
status_t status = mInputConsumer.consume(&mInputEventFactory, | |
consumeBatches, frameTime, &seq, &inputEvent); | |
... | |
env->CallVoidMethod(receiverObj.get(), | |
gInputEventReceiverClassInfo.dispatchBatchedInputEventPending); | |
if (env->ExceptionCheck()) { | |
ALOGE("Exception dispatching batched input events."); | |
mBatchedInputEventPending = false; // try again later | |
} | |
} | |
return OK; | |
} | |
... | |
return status; | |
} | |
if (!skipCallbacks) { | |
... | |
jobject inputEventObj; | |
switch (inputEvent->getType()) { | |
case AINPUT_EVENT_TYPE_KEY: | |
inputEventObj = android_view_KeyEvent_fromNative(env, | |
static_cast<KeyEvent*>(inputEvent)); | |
break; | |
case AINPUT_EVENT_TYPE_MOTION: { | |
... | |
MotionEvent* motionEvent = static_cast<MotionEvent*>(inputEvent); | |
if ((motionEvent->getAction() & AMOTION_EVENT_ACTION_MOVE) && outConsumedBatch) { | |
*outConsumedBatch = true; | |
} | |
inputEventObj = android_view_MotionEvent_obtainAsCopy(env, motionEvent); | |
break; | |
} | |
... | |
} | |
if (inputEventObj) { | |
... | |
env->CallVoidMethod(receiverObj.get(), | |
gInputEventReceiverClassInfo.dispatchInputEvent, seq, inputEventObj); | |
... | |
} ... | |
} | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment