summaryrefslogtreecommitdiffstats
path: root/include/ui
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-09-09 15:39:35 -0700
committerJeff Brown <jeffbrown@google.com>2011-09-09 16:04:09 -0700
commit137c3c549504a1bf52b85aa983c97f10533c7083 (patch)
tree85bc5c19b9fa5e0bbb39f287c53b94b6bdc2b73c /include/ui
parent5904d3ed1761ec73255563021cff6ccc0db568bd (diff)
downloadframeworks_native-137c3c549504a1bf52b85aa983c97f10533c7083.zip
frameworks_native-137c3c549504a1bf52b85aa983c97f10533c7083.tar.gz
frameworks_native-137c3c549504a1bf52b85aa983c97f10533c7083.tar.bz2
Tweak VelocityTracker.
Bug: 5265529 Calculate the velocity using the most recent touch sample as the point of reference instead of the oldest. This change more heavily weights recent touch samples and reduces the sample time window used for calculation. This significantly improves the accuracy of fling gesture detection. Change-Id: Ib1940933e786e5f6a731552a99bcd9400741d55f
Diffstat (limited to 'include/ui')
-rw-r--r--include/ui/Input.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/include/ui/Input.h b/include/ui/Input.h
index f1385a0..af899ef 100644
--- a/include/ui/Input.h
+++ b/include/ui/Input.h
@@ -660,15 +660,19 @@ private:
static const uint32_t HISTORY_SIZE = 10;
// Oldest sample to consider when calculating the velocity.
- static const nsecs_t MAX_AGE = 200 * 1000000; // 200 ms
+ static const nsecs_t MAX_AGE = 100 * 1000000; // 100 ms
// The minimum duration between samples when estimating velocity.
- static const nsecs_t MIN_DURATION = 10 * 1000000; // 10 ms
+ static const nsecs_t MIN_DURATION = 5 * 1000000; // 5 ms
struct Movement {
nsecs_t eventTime;
BitSet32 idBits;
Position positions[MAX_POINTERS];
+
+ inline const Position& getPosition(uint32_t id) const {
+ return positions[idBits.getIndexOfBit(id)];
+ }
};
uint32_t mIndex;