summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@android.com>2011-06-07 16:50:14 -0700
committerJeff Brown <jeffbrown@android.com>2011-06-07 16:50:14 -0700
commit6674d9bf0a53387df0cf8482458cf5f9ab274ec0 (patch)
tree97da2f8df8afc3a22b1d954e9b96a776d3f9477a
parent9181a5f40cf5ac7d413d5bc3bd6c15cc6d13705f (diff)
downloadframeworks_base-6674d9bf0a53387df0cf8482458cf5f9ab274ec0.zip
frameworks_base-6674d9bf0a53387df0cf8482458cf5f9ab274ec0.tar.gz
frameworks_base-6674d9bf0a53387df0cf8482458cf5f9ab274ec0.tar.bz2
Fix swipe gesture cosine calculation.
Bug: 4124987 Recent changes introduced a multiplication factor into the distance calculation which ended up being absent from the dot product calculation. Change-Id: Ia367912b9ac09b6285d5a498a0c271563c9e9e39
-rw-r--r--services/input/InputReader.cpp6
-rw-r--r--services/input/InputReader.h2
2 files changed, 6 insertions, 2 deletions
diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp
index ce8a939..1ed5ad7 100644
--- a/services/input/InputReader.cpp
+++ b/services/input/InputReader.cpp
@@ -3940,7 +3940,11 @@ bool TouchInputMapper::preparePointerGestures(nsecs_t when,
// approches 1.0. Recall that dot(v1, v2) = cos(angle) * mag(v1) * mag(v2).
PointerGesture::Delta& delta1 = mPointerGesture.referenceDeltas[id1];
PointerGesture::Delta& delta2 = mPointerGesture.referenceDeltas[id2];
- float dot = delta1.dx * delta2.dx + delta1.dy * delta2.dy;
+ float dx1 = delta1.dx * mLocked.pointerGestureXZoomScale;
+ float dy1 = delta1.dy * mLocked.pointerGestureYZoomScale;
+ float dx2 = delta2.dx * mLocked.pointerGestureXZoomScale;
+ float dy2 = delta2.dy * mLocked.pointerGestureYZoomScale;
+ float dot = dx1 * dx2 + dy1 * dy2;
float cosine = dot / (dist1 * dist2); // denominator always > 0
if (cosine >= mConfig->pointerGestureSwipeTransitionAngleCosine) {
// Pointers are moving in the same direction. Switch to SWIPE.
diff --git a/services/input/InputReader.h b/services/input/InputReader.h
index 82faf7d..fa3239c 100644
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -143,7 +143,7 @@ struct InputReaderConfiguration {
pointerGestureTapSlop(10.0f), // 10 pixels
pointerGestureMultitouchSettleInterval(100 * 1000000LL), // 100 ms
pointerGestureMultitouchMinDistance(15), // 15 pixels
- pointerGestureSwipeTransitionAngleCosine(0.5f), // cosine of 45degrees
+ pointerGestureSwipeTransitionAngleCosine(0.2588f), // cosine of 75 degrees
pointerGestureSwipeMaxWidthRatio(0.25f),
pointerGestureMovementSpeedRatio(0.8f),
pointerGestureZoomSpeedRatio(0.3f) { }