summaryrefslogtreecommitdiffstats
path: root/include/androidfw/VelocityTracker.h
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-06-03 21:19:16 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-06-03 21:19:16 -0700
commit767bc6d26c98594525ed7dd94e8880335e15e8a8 (patch)
tree7e5a977d8c4486530f198baec39934267cd1decb /include/androidfw/VelocityTracker.h
parent7d3fa093bbd34e19f6b580b6258c8ea4e138c777 (diff)
parent1fbbc0716f9b70c6dcee00c4550757077ef7f7b5 (diff)
downloadframeworks_base-767bc6d26c98594525ed7dd94e8880335e15e8a8.zip
frameworks_base-767bc6d26c98594525ed7dd94e8880335e15e8a8.tar.gz
frameworks_base-767bc6d26c98594525ed7dd94e8880335e15e8a8.tar.bz2
am 1fbbc071: Merge "Implement an integrating VelocityTracker strategy." into jb-dev
* commit '1fbbc0716f9b70c6dcee00c4550757077ef7f7b5': Implement an integrating VelocityTracker strategy.
Diffstat (limited to 'include/androidfw/VelocityTracker.h')
-rw-r--r--include/androidfw/VelocityTracker.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/androidfw/VelocityTracker.h b/include/androidfw/VelocityTracker.h
index 1d44f13..e600c5a 100644
--- a/include/androidfw/VelocityTracker.h
+++ b/include/androidfw/VelocityTracker.h
@@ -172,6 +172,39 @@ private:
Movement mMovements[HISTORY_SIZE];
};
+
+/*
+ * Velocity tracker algorithm that uses an IIR filter.
+ */
+class IntegratingVelocityTrackerStrategy : public VelocityTrackerStrategy {
+public:
+ IntegratingVelocityTrackerStrategy();
+ ~IntegratingVelocityTrackerStrategy();
+
+ virtual void clear();
+ virtual void clearPointers(BitSet32 idBits);
+ virtual void addMovement(nsecs_t eventTime, BitSet32 idBits,
+ const VelocityTracker::Position* positions);
+ virtual bool getEstimator(uint32_t id, VelocityTracker::Estimator* outEstimator) const;
+
+private:
+ // Current state estimate for a particular pointer.
+ struct State {
+ nsecs_t updateTime;
+ bool first;
+
+ float xpos, xvel;
+ float ypos, yvel;
+ };
+
+ BitSet32 mPointerIdBits;
+ State mPointerState[MAX_POINTER_ID + 1];
+
+ static void initState(State& state, nsecs_t eventTime, float xpos, float ypos);
+ static void updateState(State& state, nsecs_t eventTime, float xpos, float ypos);
+ static void populateEstimator(const State& state, VelocityTracker::Estimator* outEstimator);
+};
+
} // namespace android
#endif // _ANDROIDFW_VELOCITY_TRACKER_H