diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-06-03 21:16:38 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-06-03 21:16:38 -0700 |
commit | 1fbbc0716f9b70c6dcee00c4550757077ef7f7b5 (patch) | |
tree | 3e6ba76e20907a8f1073e9872d12a82903043bc6 /include | |
parent | f47e76e2c78e78e26110786e99548d718d177c32 (diff) | |
parent | 53dd12a66884540b87fe428383e2f79d0f5e32ba (diff) | |
download | frameworks_base-1fbbc0716f9b70c6dcee00c4550757077ef7f7b5.zip frameworks_base-1fbbc0716f9b70c6dcee00c4550757077ef7f7b5.tar.gz frameworks_base-1fbbc0716f9b70c6dcee00c4550757077ef7f7b5.tar.bz2 |
Merge "Implement an integrating VelocityTracker strategy." into jb-dev
Diffstat (limited to 'include')
-rw-r--r-- | include/androidfw/VelocityTracker.h | 33 |
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 |