2009-09-06 13:44:18 -06:00
|
|
|
/*
|
|
|
|
*
|
2011-11-05 07:32:40 -06:00
|
|
|
* Copyright © 2006-2011 Simon Thum simon dot thum at gmx dot de
|
2009-09-06 13:44:18 -06:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef POINTERVELOCITY_H
|
|
|
|
#define POINTERVELOCITY_H
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
#include <input.h>
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
/* constants for acceleration profiles */
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
#define AccelProfileNone -1
|
2009-09-06 13:44:18 -06:00
|
|
|
#define AccelProfileClassic 0
|
|
|
|
#define AccelProfileDeviceSpecific 1
|
|
|
|
#define AccelProfilePolynomial 2
|
|
|
|
#define AccelProfileSmoothLinear 3
|
|
|
|
#define AccelProfileSimple 4
|
|
|
|
#define AccelProfilePower 5
|
|
|
|
#define AccelProfileLinear 6
|
2010-07-27 13:02:24 -06:00
|
|
|
#define AccelProfileSmoothLimited 7
|
|
|
|
#define AccelProfileLAST AccelProfileSmoothLimited
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
/* fwd */
|
|
|
|
struct _DeviceVelocityRec;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* profile
|
|
|
|
* returns actual acceleration depending on velocity, acceleration control,...
|
|
|
|
*/
|
2012-06-10 07:21:05 -06:00
|
|
|
typedef double (*PointerAccelerationProfileFunc)
|
|
|
|
(DeviceIntPtr dev, struct _DeviceVelocityRec * vel,
|
|
|
|
double velocity, double threshold, double accelCoeff);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
/**
|
2010-07-27 13:02:24 -06:00
|
|
|
* a motion history, with just enough information to
|
|
|
|
* calc mean velocity and decide which motion was along
|
|
|
|
* a more or less straight line
|
2009-09-06 13:44:18 -06:00
|
|
|
*/
|
2010-07-27 13:02:24 -06:00
|
|
|
typedef struct _MotionTracker {
|
2012-06-10 07:21:05 -06:00
|
|
|
double dx, dy; /* accumulated delta for each axis */
|
|
|
|
int time; /* time of creation */
|
|
|
|
int dir; /* initial direction bitfield */
|
2010-07-27 13:02:24 -06:00
|
|
|
} MotionTracker, *MotionTrackerPtr;
|
2009-09-06 13:44:18 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains all data needed to implement mouse ballistics
|
|
|
|
*/
|
|
|
|
typedef struct _DeviceVelocityRec {
|
2010-07-27 13:02:24 -06:00
|
|
|
MotionTrackerPtr tracker;
|
|
|
|
int num_tracker;
|
2012-06-10 07:21:05 -06:00
|
|
|
int cur_tracker; /* current index */
|
|
|
|
double velocity; /* velocity as guessed by algorithm */
|
|
|
|
double last_velocity; /* previous velocity estimate */
|
|
|
|
double last_dx; /* last time-difference */
|
|
|
|
double last_dy; /* phase of last/current estimate */
|
|
|
|
double corr_mul; /* config: multiply this into velocity */
|
|
|
|
double const_acceleration; /* config: (recipr.) const deceleration */
|
|
|
|
double min_acceleration; /* config: minimum acceleration */
|
|
|
|
short reset_time; /* config: reset non-visible state after # ms */
|
|
|
|
short use_softening; /* config: use softening of mouse values */
|
|
|
|
double max_rel_diff; /* config: max. relative difference */
|
|
|
|
double max_diff; /* config: max. difference */
|
|
|
|
int initial_range; /* config: max. offset used as initial velocity */
|
|
|
|
Bool average_accel; /* config: average acceleration over velocity */
|
2009-09-06 13:44:18 -06:00
|
|
|
PointerAccelerationProfileFunc Profile;
|
|
|
|
PointerAccelerationProfileFunc deviceSpecificProfile;
|
2012-06-10 07:21:05 -06:00
|
|
|
void *profile_private; /* extended data, see SetAccelerationProfile() */
|
|
|
|
struct { /* to be able to query this information */
|
|
|
|
int profile_number;
|
2009-09-06 13:44:18 -06:00
|
|
|
} statistics;
|
|
|
|
} DeviceVelocityRec, *DeviceVelocityPtr;
|
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
/**
|
|
|
|
* contains the run-time data for the predictable scheme, that is, a
|
|
|
|
* DeviceVelocityPtr and the property handlers.
|
|
|
|
*/
|
|
|
|
typedef struct _PredictableAccelSchemeRec {
|
|
|
|
DeviceVelocityPtr vel;
|
2012-06-10 07:21:05 -06:00
|
|
|
long *prop_handlers;
|
2011-11-05 07:32:40 -06:00
|
|
|
int num_prop_handlers;
|
|
|
|
} PredictableAccelSchemeRec, *PredictableAccelSchemePtr;
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
extern _X_EXPORT void
|
2013-06-07 11:28:45 -06:00
|
|
|
InitVelocityData(DeviceVelocityPtr vel);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
extern _X_EXPORT void
|
2013-06-07 11:28:45 -06:00
|
|
|
InitTrackers(DeviceVelocityPtr vel, int ntracker);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
extern _X_EXPORT BOOL
|
2012-06-10 07:21:05 -06:00
|
|
|
ProcessVelocityData2D(DeviceVelocityPtr vel, double dx, double dy, int time);
|
|
|
|
|
|
|
|
extern _X_EXPORT double
|
2010-07-27 13:02:24 -06:00
|
|
|
BasicComputeAcceleration(DeviceIntPtr dev, DeviceVelocityPtr vel,
|
2012-06-10 07:21:05 -06:00
|
|
|
double velocity, double threshold, double acc);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
extern _X_EXPORT void
|
2013-06-07 11:28:45 -06:00
|
|
|
FreeVelocityData(DeviceVelocityPtr vel);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
extern _X_EXPORT int
|
2013-06-07 11:28:45 -06:00
|
|
|
SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
extern _X_EXPORT DeviceVelocityPtr
|
|
|
|
GetDevicePredictableAccelData(DeviceIntPtr dev);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
extern _X_EXPORT void
|
|
|
|
SetDeviceSpecificAccelerationProfile(DeviceVelocityPtr vel,
|
2009-09-06 13:44:18 -06:00
|
|
|
PointerAccelerationProfileFunc profile);
|
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
extern _X_INTERNAL void
|
2013-06-07 11:28:45 -06:00
|
|
|
AccelerationDefaultCleanup(DeviceIntPtr dev);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
extern _X_INTERNAL Bool
|
|
|
|
InitPredictableAccelerationScheme(DeviceIntPtr dev,
|
2012-06-10 07:21:05 -06:00
|
|
|
struct _ValuatorAccelerationRec *protoScheme);
|
2011-11-05 07:32:40 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
extern _X_INTERNAL void
|
2012-06-10 07:21:05 -06:00
|
|
|
acceleratePointerPredictable(DeviceIntPtr dev, ValuatorMask *val,
|
2011-11-05 07:32:40 -06:00
|
|
|
CARD32 evtime);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2010-07-27 13:02:24 -06:00
|
|
|
extern _X_INTERNAL void
|
2012-06-10 07:21:05 -06:00
|
|
|
acceleratePointerLightweight(DeviceIntPtr dev, ValuatorMask *val,
|
2011-11-05 07:32:40 -06:00
|
|
|
CARD32 evtime);
|
2009-09-06 13:44:18 -06:00
|
|
|
|
2012-06-10 07:21:05 -06:00
|
|
|
#endif /* POINTERVELOCITY_H */
|