diff options
author | Michael Wright <michaelwr@google.com> | 2015-05-08 20:08:04 +0100 |
---|---|---|
committer | Michael Wright <michaelwr@google.com> | 2015-05-14 14:18:05 +0100 |
commit | ec0ce51b733f10c620cb9447b074f022d042e31d (patch) | |
tree | b1fb669f40ae6038e271f7c1a81ca46c7a19fb0b /core/jni | |
parent | fbb34dd8df7bc89ae972c545130e76c5bbb4176e (diff) | |
download | frameworks_base-ec0ce51b733f10c620cb9447b074f022d042e31d.zip frameworks_base-ec0ce51b733f10c620cb9447b074f022d042e31d.tar.gz frameworks_base-ec0ce51b733f10c620cb9447b074f022d042e31d.tar.bz2 |
Add new MotionEvent actions for button press and release.
Introduce ACTION_BUTTON_PRESS and ACTION_BUTTON_RELEASE as actions to
signal a button press or release. If these actions happen
simulanteously with a DOWN or UP event then they're explicitly
ordered to happen after the DOWN or preceding the UP in order to send
them to the most recently targeted view.
Also, introduce new stylus button constants that differ from the
constants we use for mouse buttons.
Bug: 20704355
Change-Id: I5b75e5c5e692171c1c117ee687dd185a0d9dd15c
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android_view_InputEventSender.cpp | 3 | ||||
-rw-r--r-- | core/jni/android_view_MotionEvent.cpp | 20 |
2 files changed, 21 insertions, 2 deletions
diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp index 265daeb..d61dee7 100644 --- a/core/jni/android_view_InputEventSender.cpp +++ b/core/jni/android_view_InputEventSender.cpp @@ -135,7 +135,8 @@ status_t NativeInputEventSender::sendMotionEvent(uint32_t seq, const MotionEvent for (size_t i = 0; i <= event->getHistorySize(); i++) { publishedSeq = mNextPublishedSeq++; status_t status = mInputPublisher.publishMotionEvent(publishedSeq, - event->getDeviceId(), event->getSource(), event->getAction(), event->getFlags(), + event->getDeviceId(), event->getSource(), + event->getAction(), event->getActionButton(), event->getFlags(), event->getEdgeFlags(), event->getMetaState(), event->getButtonState(), event->getXOffset(), event->getYOffset(), event->getXPrecision(), event->getYPrecision(), diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp index e622768..1f28643 100644 --- a/core/jni/android_view_MotionEvent.cpp +++ b/core/jni/android_view_MotionEvent.cpp @@ -370,7 +370,7 @@ static jlong android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz env->DeleteLocalRef(pointerCoordsObj); } - event->initialize(deviceId, source, action, flags, edgeFlags, metaState, buttonState, + event->initialize(deviceId, source, action, flags, edgeFlags, metaState, buttonState, 0, xOffset, yOffset, xPrecision, yPrecision, downTimeNanos, eventTimeNanos, pointerCount, pointerProperties, rawPointerCoords); @@ -456,6 +456,12 @@ static void android_view_MotionEvent_nativeSetAction(JNIEnv* env, jclass clazz, event->setAction(action); } +static int android_view_MotionEvent_nativeGetActionButton(JNIEnv* env, jclass clazz, + jlong nativePtr) { + MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); + return event->getActionButton(); +} + static jboolean android_view_MotionEvent_nativeIsTouchEvent(JNIEnv* env, jclass clazz, jlong nativePtr) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); @@ -498,6 +504,12 @@ static jint android_view_MotionEvent_nativeGetButtonState(JNIEnv* env, jclass cl return event->getButtonState(); } +static void android_view_MotionEvent_nativeSetButtonState(JNIEnv* env, jclass clazz, + jlong nativePtr, jint buttonState) { + MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); + event->setButtonState(buttonState); +} + static void android_view_MotionEvent_nativeOffsetLocation(JNIEnv* env, jclass clazz, jlong nativePtr, jfloat deltaX, jfloat deltaY) { MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr); @@ -764,6 +776,9 @@ static JNINativeMethod gMotionEventMethods[] = { { "nativeSetAction", "(JI)V", (void*)android_view_MotionEvent_nativeSetAction }, + { "nativeGetActionButton", + "(J)I", + (void*)android_view_MotionEvent_nativeGetActionButton}, { "nativeIsTouchEvent", "(J)Z", (void*)android_view_MotionEvent_nativeIsTouchEvent }, @@ -785,6 +800,9 @@ static JNINativeMethod gMotionEventMethods[] = { { "nativeGetButtonState", "(J)I", (void*)android_view_MotionEvent_nativeGetButtonState }, + { "nativeSetButtonState", + "(JI)V", + (void*)android_view_MotionEvent_nativeSetButtonState }, { "nativeOffsetLocation", "(JFF)V", (void*)android_view_MotionEvent_nativeOffsetLocation }, |