summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-02-12 15:52:09 -0800
committerDianne Hackborn <hackbod@google.com>2010-02-12 17:52:22 -0800
commitb125dc5599468a09d82751cd76152071ae485afb (patch)
tree6d7ea46208c30bf1ae9014b70d7f5f50167eaa10 /common
parentd382e4bee9c6cf96f97700ebcffcf81465294146 (diff)
downloadframeworks_base-b125dc5599468a09d82751cd76152071ae485afb.zip
frameworks_base-b125dc5599468a09d82751cd76152071ae485afb.tar.gz
frameworks_base-b125dc5599468a09d82751cd76152071ae485afb.tar.bz2
Fix MotionEvent pointer API.
Ooops. The API said that the pointer down and up actions contained the pointer id, but it is actually the index. Actually it makes much more sense for it to be the index, and those ACTION_POINTER_1_DOWN etc. constants were stupid.
Diffstat (limited to 'common')
-rw-r--r--common/java/com/android/common/ui/PointerLocationView.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/common/java/com/android/common/ui/PointerLocationView.java b/common/java/com/android/common/ui/PointerLocationView.java
index e83c5ae..7bdb0bc 100644
--- a/common/java/com/android/common/ui/PointerLocationView.java
+++ b/common/java/com/android/common/ui/PointerLocationView.java
@@ -234,8 +234,9 @@ public class PointerLocationView extends View {
}
if ((action&MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN) {
- final int id = (action&MotionEvent.ACTION_POINTER_ID_MASK)
- >> MotionEvent.ACTION_POINTER_ID_SHIFT;
+ final int index = (action&MotionEvent.ACTION_POINTER_INDEX_MASK)
+ >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
+ final int id = event.getPointerId(index);
while (NP <= id) {
PointerState ps = new PointerState();
ps.mVelocity = VelocityTracker.obtain();
@@ -260,13 +261,14 @@ public class PointerLocationView extends View {
}
for (int i=0; i<NI; i++) {
- final PointerState ps = mPointers.get(event.getPointerId(i));
+ final int id = event.getPointerId(i);
+ final PointerState ps = mPointers.get(id);
ps.mVelocity.addMovement(event);
ps.mVelocity.computeCurrentVelocity(1);
final int N = event.getHistorySize();
for (int j=0; j<N; j++) {
if (mPrintCoords) {
- Log.i("Pointer", "Pointer " + (i+1) + ": ("
+ Log.i("Pointer", "Pointer " + (id+1) + ": ("
+ event.getHistoricalX(i, j)
+ ", " + event.getHistoricalY(i, j) + ")"
+ " Prs=" + event.getHistoricalPressure(i, j)
@@ -276,7 +278,7 @@ public class PointerLocationView extends View {
ps.mYs.add(event.getHistoricalY(i, j));
}
if (mPrintCoords) {
- Log.i("Pointer", "Pointer " + (i+1) + ": ("
+ Log.i("Pointer", "Pointer " + (id+1) + ": ("
+ event.getX(i) + ", " + event.getY(i) + ")"
+ " Prs=" + event.getPressure(i)
+ " Size=" + event.getSize(i));
@@ -293,8 +295,9 @@ public class PointerLocationView extends View {
}
if ((action&MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP) {
- final int id = (action&MotionEvent.ACTION_POINTER_ID_MASK)
- >> MotionEvent.ACTION_POINTER_ID_SHIFT;
+ final int index = (action&MotionEvent.ACTION_POINTER_INDEX_MASK)
+ >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
+ final int id = event.getPointerId(index);
final PointerState ps = mPointers.get(id);
ps.mXs.add(Float.NaN);
ps.mYs.add(Float.NaN);
@@ -306,11 +309,12 @@ public class PointerLocationView extends View {
if (action == MotionEvent.ACTION_UP) {
for (int i=0; i<NI; i++) {
- final PointerState ps = mPointers.get(event.getPointerId(i));
+ final int id = event.getPointerId(i);
+ final PointerState ps = mPointers.get(id);
if (ps.mCurDown) {
ps.mCurDown = false;
if (mPrintCoords) {
- Log.i("Pointer", "Pointer " + (i+1) + ": UP");
+ Log.i("Pointer", "Pointer " + (id+1) + ": UP");
}
}
}