summaryrefslogtreecommitdiff
path: root/include/ptrveloc.h
diff options
context:
space:
mode:
authorSimon Thum <simon.thum@gmx.de>2009-02-28 22:17:47 +0100
committerPeter Hutterer <peter.hutterer@who-t.net>2009-03-20 14:48:57 +1000
commit1a71862d333282e2d251ff0036866cec22bcce85 (patch)
treea48b3a2c8b6ae22069b489722b5ce1268b4b372b /include/ptrveloc.h
parent5ae129baef85b47590c02e4cf61b23904d8f7aa9 (diff)
dix/xfree86: simplified velocity approximation algorithm
Replace multi-stage filtering with simple linear velocity, tracked several instances backwards. A heuristic ensures only approximately linear motion is considered, so velocity remains valid in any case. Numerical stability is much better, and nothing changes to people who didn't tune the advanced features of the previous algorithm. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'include/ptrveloc.h')
-rw-r--r--include/ptrveloc.h49
1 files changed, 19 insertions, 30 deletions
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index f9933c98a..6ef8c754e 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -27,11 +27,6 @@
#include <input.h> /* DeviceIntPtr */
-/* maximum number of filters to approximate velocity.
- * ABI-breaker!
- */
-#define MAX_VELOCITY_FILTERS 8
-
/* constants for acceleration profiles;
* see */
@@ -57,46 +52,41 @@ typedef float (*PointerAccelerationProfileFunc)
float /*velocity*/, float /*threshold*/, float /*acc*/);
/**
- * a filter stage contains the data for adaptive IIR filtering.
- * To improve results, one may run several parallel filters
- * which have different decays. Since more integration means more
- * delay, a given filter only does good matches in a specific phase of
- * a stroke.
- *
- * Basically, the coupling feature makes one filter fairly enough,
- * so that is the default.
+ * a motion history, with just enough information to
+ * calc mean velocity and decide which motion was along
+ * a more or less straight line
*/
-typedef struct _FilterStage {
- float* fading_lut; /* lookup for adaptive IIR filter */
- int fading_lut_size; /* size of lookup table */
- float rdecay; /* reciprocal weighting halflife in ms */
- float current;
-} FilterStage, *FilterStagePtr;
+typedef struct _MotionTracker {
+ int dx, dy; /* accumulated delta for each axis */
+ int time; /* time of creation */
+ int dir; /* initial direction bitfield */
+} MotionTracker, *MotionTrackerPtr;
/**
* Contains all data needed to implement mouse ballistics
*/
typedef struct _DeviceVelocityRec {
- FilterStage filters[MAX_VELOCITY_FILTERS];
+ MotionTrackerPtr tracker;
+ int num_tracker;
+ int cur_tracker; /* current index */
float velocity; /* velocity as guessed by algorithm */
float last_velocity; /* previous velocity estimate */
- int lrm_time; /* time the last motion event was processed */
- int last_dx, last_dy; /* last motion delta */
- int last_diff; /* last time-difference */
- int last_phase; /* phase of last/current estimate */
+ int last_dx; /* last time-difference */
+ int last_dy ; /* phase of last/current estimate */
float corr_mul; /* config: multiply this into velocity */
float const_acceleration; /* config: (recipr.) const deceleration */
float min_acceleration; /* config: minimum acceleration */
short reset_time; /* config: reset non-visible state after # ms */
short use_softening; /* config: use softening of mouse values */
- float coupling; /* config: max. divergence before coupling */
+ float max_rel_diff; /* config: max. relative difference */
+ float max_diff; /* config: max. difference */
+ int initial_range; /* config: max. offset used as initial velocity */
Bool average_accel; /* config: average acceleration over velocity */
PointerAccelerationProfileFunc Profile;
PointerAccelerationProfileFunc deviceSpecificProfile;
void* profile_private;/* extended data, see SetAccelerationProfile() */
struct { /* to be able to query this information */
int profile_number;
- int filter_usecount[MAX_VELOCITY_FILTERS +1];
} statistics;
} DeviceVelocityRec, *DeviceVelocityPtr;
@@ -104,13 +94,12 @@ typedef struct _DeviceVelocityRec {
extern _X_EXPORT void
InitVelocityData(DeviceVelocityPtr s);
+extern _X_EXPORT void
+InitTrackers(DeviceVelocityPtr s, int ntracker);
+
extern _X_EXPORT BOOL
InitializePredictableAccelerationProperties(DeviceIntPtr pDev);
-extern _X_EXPORT void
-InitFilterChain(DeviceVelocityPtr s, float rdecay, float degression,
- int lutsize, int stages);
-
extern _X_EXPORT int
SetAccelerationProfile(DeviceVelocityPtr s, int profile_num);