summaryrefslogtreecommitdiffstats
path: root/core/java/com/android/internal/widget/PointerLocationView.java
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-02-19 05:07:28 -0800
committerJeff Brown <jeffbrown@google.com>2011-02-19 06:14:21 -0800
commitcc0c159e9b3dd4e0f48da0ce3e33d2c68a651413 (patch)
tree7a4e3c578e3e0f2c01fef4d64e721d81c851748e /core/java/com/android/internal/widget/PointerLocationView.java
parent6f2fba428ca5e77a26d991ad728e346cc47609ee (diff)
downloadframeworks_base-cc0c159e9b3dd4e0f48da0ce3e33d2c68a651413.zip
frameworks_base-cc0c159e9b3dd4e0f48da0ce3e33d2c68a651413.tar.gz
frameworks_base-cc0c159e9b3dd4e0f48da0ce3e33d2c68a651413.tar.bz2
Add new hover move action and scroll wheel plumbing.
Added support for tracking the mouse position even when the mouse button is not pressed. To avoid confusing existing applications, mouse movements are reported using the new ACTION_HOVER_MOVE action when the mouse button is not pressed. Added some more plumbing for the scroll wheel axes. The values are reported to Views but they are not yet handled by the framework. Change-Id: I1706be850d25cf34e5adf880bbed5cc3265cf4b1
Diffstat (limited to 'core/java/com/android/internal/widget/PointerLocationView.java')
-rw-r--r--core/java/com/android/internal/widget/PointerLocationView.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java
index 4a6857c..c72d0e8 100644
--- a/core/java/com/android/internal/widget/PointerLocationView.java
+++ b/core/java/com/android/internal/widget/PointerLocationView.java
@@ -27,6 +27,7 @@ import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
+import android.view.MotionEvent.PointerCoords;
import java.util.ArrayList;
@@ -43,7 +44,7 @@ public class PointerLocationView extends View {
private boolean mCurDown;
// Most recent coordinates.
- private MotionEvent.PointerCoords mCoords = new MotionEvent.PointerCoords();
+ private PointerCoords mCoords = new PointerCoords();
// Most recent velocity.
private float mXVelocity;
@@ -86,6 +87,7 @@ public class PointerLocationView extends View {
private int mMaxNumPointers;
private int mActivePointerId;
private final ArrayList<PointerState> mPointers = new ArrayList<PointerState>();
+ private final PointerCoords mHoverCoords = new PointerCoords();
private final VelocityTracker mVelocity;
@@ -386,9 +388,11 @@ public class PointerLocationView extends View {
}
final int NI = event.getPointerCount();
-
+
+ final boolean hover = (action == MotionEvent.ACTION_HOVER_MOVE);
mCurDown = action != MotionEvent.ACTION_UP
- && action != MotionEvent.ACTION_CANCEL;
+ && action != MotionEvent.ACTION_CANCEL
+ && !hover;
mCurNumPointers = mCurDown ? NI : 0;
if (mMaxNumPointers < mCurNumPointers) {
mMaxNumPointers = mCurNumPointers;
@@ -399,22 +403,27 @@ public class PointerLocationView extends View {
for (int i=0; i<NI; i++) {
final int id = event.getPointerId(i);
- final PointerState ps = mPointers.get(id);
+ final PointerState ps = hover ? null : mPointers.get(id);
+ final PointerCoords coords = ps != null ? ps.mCoords : mHoverCoords;
final int N = event.getHistorySize();
for (int j=0; j<N; j++) {
- event.getHistoricalPointerCoords(i, j, ps.mCoords);
+ event.getHistoricalPointerCoords(i, j, coords);
if (mPrintCoords) {
- logPointerCoords(ps.mCoords, id);
+ logPointerCoords(coords, id);
+ }
+ if (ps != null) {
+ ps.addTrace(event.getHistoricalX(i, j), event.getHistoricalY(i, j));
}
- ps.addTrace(event.getHistoricalX(i, j), event.getHistoricalY(i, j));
}
- event.getPointerCoords(i, ps.mCoords);
+ event.getPointerCoords(i, coords);
if (mPrintCoords) {
- logPointerCoords(ps.mCoords, id);
+ logPointerCoords(coords, id);
+ }
+ if (ps != null) {
+ ps.addTrace(coords.x, coords.y);
+ ps.mXVelocity = mVelocity.getXVelocity(id);
+ ps.mYVelocity = mVelocity.getYVelocity(id);
}
- ps.addTrace(ps.mCoords.x, ps.mCoords.y);
- ps.mXVelocity = mVelocity.getXVelocity(id);
- ps.mYVelocity = mVelocity.getYVelocity(id);
}
if (action == MotionEvent.ACTION_UP