summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Thum <simon.thum@gmx.de>2008-07-10 22:33:39 +0930
committerPeter Hutterer <peter.hutterer@who-t.net>2008-07-13 20:54:33 +0930
commitc9eb0e870c87d291311491452adf7f91a911e24b (patch)
tree0d8f5c9ff2ba7d17bf8574ace0d440f5e82c4e3e /include
parente7abe1676a6a4e4249504b8c9660cbad70569199 (diff)
Add support for multiple pointer acceleration schemes. #8583
Available acceleration schemes: - xorg classic scheme. - the new "Predictable" polynomial accel scheme. X.Org Bug 8583 <http://bugs.freedesktop.org/show_bug.cgi?id=8583> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am1
-rw-r--r--include/input.h21
-rw-r--r--include/inputstr.h14
-rw-r--r--include/ptrveloc.h89
4 files changed, 123 insertions, 2 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index 5edefe7b5..3d7879933 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -35,6 +35,7 @@ sdk_HEADERS = \
privates.h \
property.h \
propertyst.h \
+ ptrveloc.h \
region.h \
regionstr.h \
registry.h \
diff --git a/include/input.h b/include/input.h
index 59f4e7f95..ba4492839 100644
--- a/include/input.h
+++ b/include/input.h
@@ -63,6 +63,12 @@ SOFTWARE.
#define POINTER_ABSOLUTE (1 << 2)
#define POINTER_ACCELERATE (1 << 3)
+/*int constants for pointer acceleration schemes*/
+#define PtrAccelNoOp 0
+#define PtrAccelPredictable 1
+#define PtrAccelClassic 2
+#define PtrAccelDefault PtrAccelPredictable
+
#define MAX_VALUATORS 36 /* XXX from comment in dix/getevents.c */
#define NO_AXIS_LIMITS -1
@@ -155,6 +161,17 @@ typedef void (*DeviceUnwrapProc)(
void* /*data*/
);
+/* pointer acceleration handling */
+typedef void (*PointerAccelSchemeProc)(
+ DeviceIntPtr /*pDev*/,
+ int /*first_valuator*/,
+ int /*num_valuators*/,
+ int* /*valuators*/,
+ int /*evtime*/);
+
+typedef void (*DeviceCallbackProc)(
+ DeviceIntPtr /*pDev*/);
+
typedef struct _DeviceRec {
pointer devicePrivate;
ProcessInputProc processInputProc; /* current */
@@ -280,6 +297,10 @@ extern Bool InitValuatorClassDeviceStruct(
int /*numMotionEvents*/,
int /*mode*/);
+extern Bool InitPointerAccelerationScheme(
+ DeviceIntPtr /*dev*/,
+ int /*scheme*/);
+
extern Bool InitAbsoluteClassDeviceStruct(
DeviceIntPtr /*device*/);
diff --git a/include/inputstr.h b/include/inputstr.h
index f3211a972..3f5c76870 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -166,6 +166,13 @@ typedef struct _AxisInfo {
int max_value;
} AxisInfo, *AxisInfoPtr;
+typedef struct _ValuatorAccelerationRec {
+ int number;
+ PointerAccelSchemeProc AccelSchemeProc;
+ void *accelData; /* at disposal of AccelScheme */
+ DeviceCallbackProc AccelCleanupProc;
+} ValuatorAccelerationRec, *ValuatorAccelerationPtr;
+
typedef struct _ValuatorClassRec {
int numMotionEvents;
int first_motion;
@@ -177,8 +184,8 @@ typedef struct _ValuatorClassRec {
AxisInfoPtr axes;
unsigned short numAxes;
int *axisVal; /* always absolute, but device-coord system */
- float dxremaind, dyremaind; /* for acceleration */
CARD8 mode;
+ ValuatorAccelerationRec accelScheme;
} ValuatorClassRec, *ValuatorClassPtr;
typedef struct _ButtonClassRec {
@@ -467,9 +474,12 @@ typedef struct _DeviceIntRec {
/* last valuator values recorded, not posted to client;
* for slave devices, valuators is in device coordinates
* for master devices, valuators is in screen coordinates
- * see dix/getevents.c */
+ * see dix/getevents.c
+ * remainder supports acceleration
+ */
struct {
int valuators[MAX_VALUATORS];
+ float remainder[MAX_VALUATORS];
int numValuators;
} last;
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
new file mode 100644
index 000000000..dd5ee5067
--- /dev/null
+++ b/include/ptrveloc.h
@@ -0,0 +1,89 @@
+/*
+* 2006-2008 by Simon Thum
+*/
+
+#ifndef POINTERVELOCITY_H
+#define POINTERVELOCITY_H
+
+#include <input.h> /* DeviceIntPtr */
+
+#define MAX_VELOCITY_FILTERS 8
+
+struct _DeviceVelocityRec;
+
+/**
+ * profile
+ * returns actual acceleration depending on velocity, acceleration control,...
+ */
+typedef float (*PointerAccelerationProfileFunc)
+ (struct _DeviceVelocityRec* /*pVel*/,
+ float /*threshold*/, float /*acc*/);
+
+/**
+ * a filter stage contains the data for the 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.
+ */
+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;
+
+/**
+ * Contains all data needed to implement mouse ballistics
+ */
+typedef struct _DeviceVelocityRec {
+ FilterStage filters[MAX_VELOCITY_FILTERS];
+ float velocity; /* velocity as guessed by algorithm */
+ int lrm_time; /* time the last motion event was processed */
+ int last_dx, last_dy; /* last motion delta */
+ int last_diff; /* last time-diff */
+ 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 */
+ 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];
+ } statistics;
+} DeviceVelocityRec, *DeviceVelocityPtr;
+
+
+extern void
+InitVelocityData(DeviceVelocityPtr s);
+
+extern void
+InitFilterChain(DeviceVelocityPtr s, float rdecay, float degression,
+ int lutsize, int stages);
+
+extern int
+SetAccelerationProfile(DeviceVelocityPtr s, int profile_num);
+
+extern void
+SetDeviceSpecificAccelerationProfile(DeviceIntPtr s,
+ PointerAccelerationProfileFunc profile);
+
+extern void
+AccelerationDefaultCleanup(DeviceIntPtr pDev);
+
+extern void
+acceleratePointerPredictable(DeviceIntPtr pDev, int first_valuator,
+ int num_valuators, int *valuators, int evtime);
+
+extern void
+acceleratePointerClassic(DeviceIntPtr pDev, int first_valuator,
+ int num_valuators, int *valuators, int ignore);
+
+#endif /* POINTERVELOCITY_H */