summaryrefslogtreecommitdiffstats
path: root/core/jni/android_view_MotionEvent.cpp
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2010-07-14 18:48:53 -0700
committerJeff Brown <jeffbrown@google.com>2010-07-15 18:32:33 -0700
commitc5ed5910c9ef066cec6a13bbb404ec57b1e92637 (patch)
treeb06dfdac2d807dae78a2634007b6e627eefd0804 /core/jni/android_view_MotionEvent.cpp
parentd9452ecd0ce6c8e0518055929ba1fd0712146405 (diff)
downloadframeworks_base-c5ed5910c9ef066cec6a13bbb404ec57b1e92637.zip
frameworks_base-c5ed5910c9ef066cec6a13bbb404ec57b1e92637.tar.gz
frameworks_base-c5ed5910c9ef066cec6a13bbb404ec57b1e92637.tar.bz2
Add support for new input sources.
Added several new coordinate values to MotionEvents to capture touch major/minor area, tool major/minor area and orientation. Renamed NDK input constants per convention. Added InputDevice class in Java which will eventually provide useful information about available input devices. Added APIs for manufacturing new MotionEvent objects with multiple pointers and all necessary coordinate data. Fixed a bug in the input dispatcher where it could get stuck with a pointer down forever. Fixed a bug in the WindowManager where the input window list could end up containing stale removed windows. Fixed a bug in the WindowManager where the input channel was being removed only after the final animation transition had taken place which caused spurious WINDOW DIED log messages to be printed. Change-Id: Ie55084da319b20aad29b28a0499b8dd98bb5da68
Diffstat (limited to 'core/jni/android_view_MotionEvent.cpp')
-rw-r--r--core/jni/android_view_MotionEvent.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/core/jni/android_view_MotionEvent.cpp b/core/jni/android_view_MotionEvent.cpp
index 78137e2..fe247e8 100644
--- a/core/jni/android_view_MotionEvent.cpp
+++ b/core/jni/android_view_MotionEvent.cpp
@@ -24,7 +24,7 @@
#include "android_view_MotionEvent.h"
// Number of float items per entry in a DVM sample data array
-#define NUM_SAMPLE_DATA 4
+#define NUM_SAMPLE_DATA 9
namespace android {
@@ -36,13 +36,14 @@ static struct {
jmethodID obtain;
jmethodID recycle;
+ jfieldID mDeviceId;
+ jfieldID mSource;
jfieldID mDownTimeNano;
jfieldID mAction;
jfieldID mXOffset;
jfieldID mYOffset;
jfieldID mXPrecision;
jfieldID mYPrecision;
- jfieldID mDeviceId;
jfieldID mEdgeFlags;
jfieldID mMetaState;
jfieldID mNumPointers;
@@ -70,6 +71,10 @@ jobject android_view_MotionEvent_fromNative(JNIEnv* env, const MotionEvent* even
return NULL;
}
+ env->SetIntField(eventObj, gMotionEventClassInfo.mDeviceId,
+ event->getDeviceId());
+ env->SetIntField(eventObj, gMotionEventClassInfo.mSource,
+ event->getSource());
env->SetLongField(eventObj, gMotionEventClassInfo.mDownTimeNano,
event->getDownTime());
env->SetIntField(eventObj, gMotionEventClassInfo.mAction,
@@ -82,8 +87,6 @@ jobject android_view_MotionEvent_fromNative(JNIEnv* env, const MotionEvent* even
event->getXPrecision());
env->SetFloatField(eventObj, gMotionEventClassInfo.mYPrecision,
event->getYPrecision());
- env->SetIntField(eventObj, gMotionEventClassInfo.mDeviceId,
- event->getDeviceId());
env->SetIntField(eventObj, gMotionEventClassInfo.mEdgeFlags,
event->getEdgeFlags());
env->SetIntField(eventObj, gMotionEventClassInfo.mMetaState,
@@ -129,6 +132,11 @@ jobject android_view_MotionEvent_fromNative(JNIEnv* env, const MotionEvent* even
*(destDataSamples++) = srcSamplePointerCoords->y;
*(destDataSamples++) = srcSamplePointerCoords->pressure;
*(destDataSamples++) = srcSamplePointerCoords->size;
+ *(destDataSamples++) = srcSamplePointerCoords->touchMajor;
+ *(destDataSamples++) = srcSamplePointerCoords->touchMinor;
+ *(destDataSamples++) = srcSamplePointerCoords->toolMajor;
+ *(destDataSamples++) = srcSamplePointerCoords->toolMinor;
+ *(destDataSamples++) = srcSamplePointerCoords->orientation;
srcSamplePointerCoords += 1;
}
@@ -142,15 +150,16 @@ jobject android_view_MotionEvent_fromNative(JNIEnv* env, const MotionEvent* even
return eventObj;
}
-void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj, int32_t nature,
+void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj,
MotionEvent* event) {
+ jint deviceId = env->GetIntField(eventObj, gMotionEventClassInfo.mDeviceId);
+ jint source = env->GetIntField(eventObj, gMotionEventClassInfo.mSource);
jlong downTimeNano = env->GetLongField(eventObj, gMotionEventClassInfo.mDownTimeNano);
jint action = env->GetIntField(eventObj, gMotionEventClassInfo.mAction);
jfloat xOffset = env->GetFloatField(eventObj, gMotionEventClassInfo.mXOffset);
jfloat yOffset = env->GetFloatField(eventObj, gMotionEventClassInfo.mYOffset);
jfloat xPrecision = env->GetFloatField(eventObj, gMotionEventClassInfo.mXPrecision);
jfloat yPrecision = env->GetFloatField(eventObj, gMotionEventClassInfo.mYPrecision);
- jint deviceId = env->GetIntField(eventObj, gMotionEventClassInfo.mDeviceId);
jint edgeFlags = env->GetIntField(eventObj, gMotionEventClassInfo.mEdgeFlags);
jint metaState = env->GetIntField(eventObj, gMotionEventClassInfo.mMetaState);
jint numPointers = env->GetIntField(eventObj, gMotionEventClassInfo.mNumPointers);
@@ -180,9 +189,14 @@ void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj, int32_t na
samplePointerCoords[j].y = *(srcDataSamples++);
samplePointerCoords[j].pressure = *(srcDataSamples++);
samplePointerCoords[j].size = *(srcDataSamples++);
+ samplePointerCoords[j].touchMajor = *(srcDataSamples++);
+ samplePointerCoords[j].touchMinor = *(srcDataSamples++);
+ samplePointerCoords[j].toolMajor = *(srcDataSamples++);
+ samplePointerCoords[j].toolMinor = *(srcDataSamples++);
+ samplePointerCoords[j].orientation = *(srcDataSamples++);
}
- event->initialize(deviceId, nature, action, edgeFlags, metaState,
+ event->initialize(deviceId, source, action, edgeFlags, metaState,
xOffset, yOffset, xPrecision, yPrecision, downTimeNano, sampleEventTime,
numPointers, pointerIdentifiers, samplePointerCoords);
@@ -193,6 +207,11 @@ void android_view_MotionEvent_toNative(JNIEnv* env, jobject eventObj, int32_t na
samplePointerCoords[j].y = *(srcDataSamples++);
samplePointerCoords[j].pressure = *(srcDataSamples++);
samplePointerCoords[j].size = *(srcDataSamples++);
+ samplePointerCoords[j].touchMajor = *(srcDataSamples++);
+ samplePointerCoords[j].touchMinor = *(srcDataSamples++);
+ samplePointerCoords[j].toolMajor = *(srcDataSamples++);
+ samplePointerCoords[j].toolMinor = *(srcDataSamples++);
+ samplePointerCoords[j].orientation = *(srcDataSamples++);
}
event->addSample(sampleEventTime, samplePointerCoords);
}
@@ -242,6 +261,10 @@ int register_android_view_MotionEvent(JNIEnv* env) {
GET_METHOD_ID(gMotionEventClassInfo.recycle, gMotionEventClassInfo.clazz,
"recycle", "()V");
+ GET_FIELD_ID(gMotionEventClassInfo.mDeviceId, gMotionEventClassInfo.clazz,
+ "mDeviceId", "I");
+ GET_FIELD_ID(gMotionEventClassInfo.mSource, gMotionEventClassInfo.clazz,
+ "mSource", "I");
GET_FIELD_ID(gMotionEventClassInfo.mDownTimeNano, gMotionEventClassInfo.clazz,
"mDownTimeNano", "J");
GET_FIELD_ID(gMotionEventClassInfo.mAction, gMotionEventClassInfo.clazz,
@@ -254,8 +277,6 @@ int register_android_view_MotionEvent(JNIEnv* env) {
"mXPrecision", "F");
GET_FIELD_ID(gMotionEventClassInfo.mYPrecision, gMotionEventClassInfo.clazz,
"mYPrecision", "F");
- GET_FIELD_ID(gMotionEventClassInfo.mDeviceId, gMotionEventClassInfo.clazz,
- "mDeviceId", "I");
GET_FIELD_ID(gMotionEventClassInfo.mEdgeFlags, gMotionEventClassInfo.clazz,
"mEdgeFlags", "I");
GET_FIELD_ID(gMotionEventClassInfo.mMetaState, gMotionEventClassInfo.clazz,