diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-06-01 13:24:04 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-06-03 19:23:58 -0700 |
commit | 53dd12a66884540b87fe428383e2f79d0f5e32ba (patch) | |
tree | 7493fd04d9e2ad3143b679b9ae30829877ef38e4 /include | |
parent | 9eb7d86181729c3eb769d71123c4ce9ffc868f08 (diff) | |
download | frameworks_base-53dd12a66884540b87fe428383e2f79d0f5e32ba.zip frameworks_base-53dd12a66884540b87fe428383e2f79d0f5e32ba.tar.gz frameworks_base-53dd12a66884540b87fe428383e2f79d0f5e32ba.tar.bz2 |
Implement an integrating VelocityTracker strategy.
This algorithm better tolerates certain kinds of errors in the
touch input than the least squares strategy but it may underestimate
the velocity of accelerating movements. This algorithm is
mainly of interest as a baseline for testing and comparison with the
least squares algorithm, which remains the default.
Bug: 6413587
Change-Id: I8ddb50084e44875e234717907e5b06d03f59788c
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 |