Input: Widen pointer acceleration types to double
This widens almost all of the float-using code in ptrveloc.[ch] to doubles, other than values coming from properties which are specified to be floats by the property API. Bumps input API to v14 as this changes the AccelScheme signature, as used by xf86-input-synaptics. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
parent
8a4a4e1b8a
commit
2b8f1d07bd
228
dix/ptrveloc.c
228
dix/ptrveloc.c
|
@ -63,9 +63,9 @@
|
||||||
/* fwds */
|
/* fwds */
|
||||||
int
|
int
|
||||||
SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
|
SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
|
||||||
static float
|
static double
|
||||||
SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr vel, float velocity,
|
SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr vel, double velocity,
|
||||||
float threshold, float acc);
|
double threshold, double acc);
|
||||||
static PointerAccelerationProfileFunc
|
static PointerAccelerationProfileFunc
|
||||||
GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
|
GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
|
||||||
static BOOL
|
static BOOL
|
||||||
|
@ -478,14 +478,10 @@ DoGetDirection(int dx, int dy){
|
||||||
else
|
else
|
||||||
dir = UNDEFINED; /* shouldn't happen */
|
dir = UNDEFINED; /* shouldn't happen */
|
||||||
} else { /* compute angle and set appropriate flags */
|
} else { /* compute angle and set appropriate flags */
|
||||||
float r;
|
double r;
|
||||||
int i1, i2;
|
int i1, i2;
|
||||||
|
|
||||||
#ifdef _ISOC99_SOURCE
|
|
||||||
r = atan2f(dy, dx);
|
|
||||||
#else
|
|
||||||
r = atan2(dy, dx);
|
r = atan2(dy, dx);
|
||||||
#endif
|
|
||||||
/* find direction.
|
/* find direction.
|
||||||
*
|
*
|
||||||
* Add 360° to avoid r become negative since C has no well-defined
|
* Add 360° to avoid r become negative since C has no well-defined
|
||||||
|
@ -524,8 +520,7 @@ static int
|
||||||
GetDirection(int dx, int dy){
|
GetDirection(int dx, int dy){
|
||||||
static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE];
|
static int cache[DIRECTION_CACHE_SIZE][DIRECTION_CACHE_SIZE];
|
||||||
int dir;
|
int dir;
|
||||||
if (abs(dx) <= DIRECTION_CACHE_RANGE &&
|
if (abs(dx) <= DIRECTION_CACHE_RANGE && abs(dy) <= DIRECTION_CACHE_RANGE) {
|
||||||
abs(dy) <= DIRECTION_CACHE_RANGE) {
|
|
||||||
/* cacheable */
|
/* cacheable */
|
||||||
dir = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy];
|
dir = cache[DIRECTION_CACHE_RANGE+dx][DIRECTION_CACHE_RANGE+dy];
|
||||||
if(dir == 0) {
|
if(dir == 0) {
|
||||||
|
@ -553,7 +548,7 @@ GetDirection(int dx, int dy){
|
||||||
* 0/0 and set it as the current one.
|
* 0/0 and set it as the current one.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t)
|
FeedTrackers(DeviceVelocityPtr vel, double dx, double dy, int cur_t)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
for(n = 0; n < vel->num_tracker; n++){
|
for(n = 0; n < vel->num_tracker; n++){
|
||||||
|
@ -561,8 +556,8 @@ FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t)
|
||||||
vel->tracker[n].dy += dy;
|
vel->tracker[n].dy += dy;
|
||||||
}
|
}
|
||||||
n = (vel->cur_tracker + 1) % vel->num_tracker;
|
n = (vel->cur_tracker + 1) % vel->num_tracker;
|
||||||
vel->tracker[n].dx = 0;
|
vel->tracker[n].dx = 0.0;
|
||||||
vel->tracker[n].dy = 0;
|
vel->tracker[n].dy = 0.0;
|
||||||
vel->tracker[n].time = cur_t;
|
vel->tracker[n].time = cur_t;
|
||||||
vel->tracker[n].dir = GetDirection(dx, dy);
|
vel->tracker[n].dir = GetDirection(dx, dy);
|
||||||
DebugAccelF("(dix prtacc) motion [dx: %i dy: %i dir:%i diff: %i]\n",
|
DebugAccelF("(dix prtacc) motion [dx: %i dy: %i dir:%i diff: %i]\n",
|
||||||
|
@ -576,9 +571,9 @@ FeedTrackers(DeviceVelocityPtr vel, int dx, int dy, int cur_t)
|
||||||
* velocity scaling.
|
* velocity scaling.
|
||||||
* This assumes linear motion.
|
* This assumes linear motion.
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
CalcTracker(const MotionTracker *tracker, int cur_t){
|
CalcTracker(const MotionTracker *tracker, int cur_t){
|
||||||
float dist = sqrt(tracker->dx * tracker->dx + tracker->dy * tracker->dy);
|
double dist = sqrt(tracker->dx * tracker->dx + tracker->dy * tracker->dy);
|
||||||
int dtime = cur_t - tracker->time;
|
int dtime = cur_t - tracker->time;
|
||||||
if(dtime > 0)
|
if(dtime > 0)
|
||||||
return dist / dtime;
|
return dist / dtime;
|
||||||
|
@ -593,16 +588,16 @@ CalcTracker(const MotionTracker *tracker, int cur_t){
|
||||||
*
|
*
|
||||||
* @return The tracker's velocity or 0 if the above conditions are unmet
|
* @return The tracker's velocity or 0 if the above conditions are unmet
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
QueryTrackers(DeviceVelocityPtr vel, int cur_t){
|
QueryTrackers(DeviceVelocityPtr vel, int cur_t){
|
||||||
int offset, dir = UNDEFINED, used_offset = -1, age_ms;
|
int offset, dir = UNDEFINED, used_offset = -1, age_ms;
|
||||||
/* initial velocity: a low-offset, valid velocity */
|
/* initial velocity: a low-offset, valid velocity */
|
||||||
float initial_velocity = 0, result = 0, velocity_diff;
|
double initial_velocity = 0, result = 0, velocity_diff;
|
||||||
float velocity_factor = vel->corr_mul * vel->const_acceleration; /* premultiply */
|
double velocity_factor = vel->corr_mul * vel->const_acceleration; /* premultiply */
|
||||||
/* loop from current to older data */
|
/* loop from current to older data */
|
||||||
for(offset = 1; offset < vel->num_tracker; offset++){
|
for(offset = 1; offset < vel->num_tracker; offset++){
|
||||||
MotionTracker *tracker = TRACKER(vel, offset);
|
MotionTracker *tracker = TRACKER(vel, offset);
|
||||||
float tracker_velocity;
|
double tracker_velocity;
|
||||||
|
|
||||||
age_ms = cur_t - tracker->time;
|
age_ms = cur_t - tracker->time;
|
||||||
|
|
||||||
|
@ -674,11 +669,11 @@ QueryTrackers(DeviceVelocityPtr vel, int cur_t){
|
||||||
BOOL
|
BOOL
|
||||||
ProcessVelocityData2D(
|
ProcessVelocityData2D(
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
int dx,
|
double dx,
|
||||||
int dy,
|
double dy,
|
||||||
int time)
|
int time)
|
||||||
{
|
{
|
||||||
float velocity;
|
double velocity;
|
||||||
|
|
||||||
vel->last_velocity = vel->velocity;
|
vel->last_velocity = vel->velocity;
|
||||||
|
|
||||||
|
@ -694,12 +689,12 @@ ProcessVelocityData2D(
|
||||||
* this flattens significant ( > 1) mickeys a little bit for more steady
|
* this flattens significant ( > 1) mickeys a little bit for more steady
|
||||||
* constant-velocity response
|
* constant-velocity response
|
||||||
*/
|
*/
|
||||||
static inline float
|
static inline double
|
||||||
ApplySimpleSoftening(int prev_delta, int delta)
|
ApplySimpleSoftening(double prev_delta, double delta)
|
||||||
{
|
{
|
||||||
float result = delta;
|
double result = delta;
|
||||||
|
|
||||||
if (delta < -1 || delta > 1) {
|
if (delta < -1.0 || delta > 1.0) {
|
||||||
if (delta > prev_delta)
|
if (delta > prev_delta)
|
||||||
result -= 0.5;
|
result -= 0.5;
|
||||||
else if (delta < prev_delta)
|
else if (delta < prev_delta)
|
||||||
|
@ -718,8 +713,8 @@ ApplySimpleSoftening(int prev_delta, int delta)
|
||||||
static void
|
static void
|
||||||
ApplySoftening(
|
ApplySoftening(
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float* fdx,
|
double* fdx,
|
||||||
float* fdy)
|
double* fdy)
|
||||||
{
|
{
|
||||||
if (vel->use_softening) {
|
if (vel->use_softening) {
|
||||||
*fdx = ApplySimpleSoftening(vel->last_dx, *fdx);
|
*fdx = ApplySimpleSoftening(vel->last_dx, *fdx);
|
||||||
|
@ -728,7 +723,7 @@ ApplySoftening(
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ApplyConstantDeceleration(DeviceVelocityPtr vel, float *fdx, float *fdy)
|
ApplyConstantDeceleration(DeviceVelocityPtr vel, double *fdx, double *fdy)
|
||||||
{
|
{
|
||||||
*fdx *= vel->const_acceleration;
|
*fdx *= vel->const_acceleration;
|
||||||
*fdy *= vel->const_acceleration;
|
*fdy *= vel->const_acceleration;
|
||||||
|
@ -737,15 +732,15 @@ ApplyConstantDeceleration(DeviceVelocityPtr vel, float *fdx, float *fdy)
|
||||||
/*
|
/*
|
||||||
* compute the acceleration for given velocity and enforce min_acceleartion
|
* compute the acceleration for given velocity and enforce min_acceleartion
|
||||||
*/
|
*/
|
||||||
float
|
double
|
||||||
BasicComputeAcceleration(
|
BasicComputeAcceleration(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc){
|
double acc){
|
||||||
|
|
||||||
float result;
|
double result;
|
||||||
result = vel->Profile(dev, vel, velocity, threshold, acc);
|
result = vel->Profile(dev, vel, velocity, threshold, acc);
|
||||||
|
|
||||||
/* enforce min_acceleration */
|
/* enforce min_acceleration */
|
||||||
|
@ -759,13 +754,13 @@ BasicComputeAcceleration(
|
||||||
* If the velocity has changed, an average is taken of 6 velocity factors:
|
* If the velocity has changed, an average is taken of 6 velocity factors:
|
||||||
* current velocity, last velocity and 4 times the average between the two.
|
* current velocity, last velocity and 4 times the average between the two.
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
ComputeAcceleration(
|
ComputeAcceleration(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc){
|
double acc){
|
||||||
float result;
|
double result;
|
||||||
|
|
||||||
if(vel->velocity <= 0){
|
if(vel->velocity <= 0){
|
||||||
DebugAccelF("(dix ptracc) profile skipped\n");
|
DebugAccelF("(dix ptracc) profile skipped\n");
|
||||||
|
@ -808,13 +803,13 @@ ComputeAcceleration(
|
||||||
/**
|
/**
|
||||||
* Polynomial function similar previous one, but with f(1) = 1
|
* Polynomial function similar previous one, but with f(1) = 1
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
PolynomialAccelerationProfile(
|
PolynomialAccelerationProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float ignored,
|
double ignored,
|
||||||
float acc)
|
double acc)
|
||||||
{
|
{
|
||||||
return pow(velocity, (acc - 1.0) * 0.5);
|
return pow(velocity, (acc - 1.0) * 0.5);
|
||||||
}
|
}
|
||||||
|
@ -824,13 +819,13 @@ PolynomialAccelerationProfile(
|
||||||
* returns acceleration for velocity.
|
* returns acceleration for velocity.
|
||||||
* This profile selects the two functions like the old scheme did
|
* This profile selects the two functions like the old scheme did
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
ClassicProfile(
|
ClassicProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc)
|
double acc)
|
||||||
{
|
{
|
||||||
if (threshold > 0) {
|
if (threshold > 0) {
|
||||||
return SimpleSmoothProfile (dev,
|
return SimpleSmoothProfile (dev,
|
||||||
|
@ -856,15 +851,15 @@ ClassicProfile(
|
||||||
* This has the expense of overall response dependency on min-acceleration.
|
* This has the expense of overall response dependency on min-acceleration.
|
||||||
* In effect, min_acceleration mimics const_acceleration in this profile.
|
* In effect, min_acceleration mimics const_acceleration in this profile.
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
PowerProfile(
|
PowerProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc)
|
double acc)
|
||||||
{
|
{
|
||||||
float vel_dist;
|
double vel_dist;
|
||||||
|
|
||||||
acc = (acc-1.0) * 0.1f + 1.0; /* without this, acc of 2 is unuseable */
|
acc = (acc-1.0) * 0.1f + 1.0; /* without this, acc of 2 is unuseable */
|
||||||
|
|
||||||
|
@ -882,11 +877,11 @@ PowerProfile(
|
||||||
* - starts faster than a sinoid
|
* - starts faster than a sinoid
|
||||||
* - smoothness C1 (Cinf if you dare to ignore endpoints)
|
* - smoothness C1 (Cinf if you dare to ignore endpoints)
|
||||||
*/
|
*/
|
||||||
static inline float
|
static inline double
|
||||||
CalcPenumbralGradient(float x){
|
CalcPenumbralGradient(double x){
|
||||||
x *= 2.0f;
|
x *= 2.0f;
|
||||||
x -= 1.0f;
|
x -= 1.0f;
|
||||||
return 0.5f + (x * sqrt(1.0f - x*x) + asin(x))/M_PI;
|
return 0.5f + (x * sqrt(1.0 - x*x) + asin(x))/M_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -894,13 +889,13 @@ CalcPenumbralGradient(float x){
|
||||||
* acceleration function similar to classic accelerated/unaccelerated,
|
* acceleration function similar to classic accelerated/unaccelerated,
|
||||||
* but with smooth transition in between (and towards zero for adaptive dec.).
|
* but with smooth transition in between (and towards zero for adaptive dec.).
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
SimpleSmoothProfile(
|
SimpleSmoothProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc)
|
double acc)
|
||||||
{
|
{
|
||||||
if(velocity < 1.0f)
|
if(velocity < 1.0f)
|
||||||
return CalcPenumbralGradient(0.5 + velocity*0.5) * 2.0f - 1.0f;
|
return CalcPenumbralGradient(0.5 + velocity*0.5) * 2.0f - 1.0f;
|
||||||
|
@ -920,15 +915,15 @@ SimpleSmoothProfile(
|
||||||
* This profile uses the first half of the penumbral gradient as a start
|
* This profile uses the first half of the penumbral gradient as a start
|
||||||
* and then scales linearly.
|
* and then scales linearly.
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
SmoothLinearProfile(
|
SmoothLinearProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc)
|
double acc)
|
||||||
{
|
{
|
||||||
float res, nv;
|
double res, nv;
|
||||||
|
|
||||||
if(acc > 1.0f)
|
if(acc > 1.0f)
|
||||||
acc -= 1.0f; /*this is so acc = 1 is no acceleration */
|
acc -= 1.0f; /*this is so acc = 1 is no acceleration */
|
||||||
|
@ -955,15 +950,15 @@ SmoothLinearProfile(
|
||||||
* From 0 to threshold, the response graduates smoothly from min_accel to
|
* From 0 to threshold, the response graduates smoothly from min_accel to
|
||||||
* acceleration. Beyond threshold it is exactly the specified acceleration.
|
* acceleration. Beyond threshold it is exactly the specified acceleration.
|
||||||
*/
|
*/
|
||||||
static float
|
static double
|
||||||
SmoothLimitedProfile(
|
SmoothLimitedProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc)
|
double acc)
|
||||||
{
|
{
|
||||||
float res;
|
double res;
|
||||||
|
|
||||||
if(velocity >= threshold || threshold == 0.0f)
|
if(velocity >= threshold || threshold == 0.0f)
|
||||||
return acc;
|
return acc;
|
||||||
|
@ -976,24 +971,24 @@ SmoothLimitedProfile(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static float
|
static double
|
||||||
LinearProfile(
|
LinearProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc)
|
double acc)
|
||||||
{
|
{
|
||||||
return acc * velocity;
|
return acc * velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float
|
static double
|
||||||
NoProfile(
|
NoProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
DeviceVelocityPtr vel,
|
DeviceVelocityPtr vel,
|
||||||
float velocity,
|
double velocity,
|
||||||
float threshold,
|
double threshold,
|
||||||
float acc)
|
double acc)
|
||||||
{
|
{
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
@ -1119,7 +1114,8 @@ acceleratePointerPredictable(
|
||||||
ValuatorMask* val,
|
ValuatorMask* val,
|
||||||
CARD32 evtime)
|
CARD32 evtime)
|
||||||
{
|
{
|
||||||
int dx = 0, dy = 0, tmpi;
|
double dx = 0, dy = 0;
|
||||||
|
int tmpi;
|
||||||
DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev);
|
DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev);
|
||||||
Bool soften = TRUE;
|
Bool soften = TRUE;
|
||||||
|
|
||||||
|
@ -1139,47 +1135,44 @@ acceleratePointerPredictable(
|
||||||
dy = valuator_mask_get(val, 1);
|
dy = valuator_mask_get(val, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dx || dy){
|
if (dx != 0.0 || dy != 0.0) {
|
||||||
/* reset non-visible state? */
|
/* reset non-visible state? */
|
||||||
if (ProcessVelocityData2D(velocitydata, dx , dy, evtime)) {
|
if (ProcessVelocityData2D(velocitydata, dx , dy, evtime)) {
|
||||||
soften = FALSE;
|
soften = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
|
if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
|
||||||
float mult;
|
double mult;
|
||||||
|
|
||||||
/* invoke acceleration profile to determine acceleration */
|
/* invoke acceleration profile to determine acceleration */
|
||||||
mult = ComputeAcceleration (dev, velocitydata,
|
mult = ComputeAcceleration (dev, velocitydata,
|
||||||
dev->ptrfeed->ctrl.threshold,
|
dev->ptrfeed->ctrl.threshold,
|
||||||
(float)dev->ptrfeed->ctrl.num /
|
(double)dev->ptrfeed->ctrl.num /
|
||||||
(float)dev->ptrfeed->ctrl.den);
|
(double)dev->ptrfeed->ctrl.den);
|
||||||
|
|
||||||
if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) {
|
if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) {
|
||||||
float fdx = dx,
|
|
||||||
fdy = dy;
|
|
||||||
|
|
||||||
if (mult > 1.0f && soften)
|
if (mult > 1.0f && soften)
|
||||||
ApplySoftening(velocitydata, &fdx, &fdy);
|
ApplySoftening(velocitydata, &dx, &dy);
|
||||||
ApplyConstantDeceleration(velocitydata, &fdx, &fdy);
|
ApplyConstantDeceleration(velocitydata, &dx, &dy);
|
||||||
|
|
||||||
/* Calculate the new delta (with accel) and drop it back
|
/* Calculate the new delta (with accel) and drop it back
|
||||||
* into the valuator masks */
|
* into the valuator masks */
|
||||||
if (dx) {
|
if (dx != 0.0) {
|
||||||
float tmp;
|
double tmp;
|
||||||
tmp = mult * fdx + dev->last.remainder[0];
|
tmp = mult * dx + dev->last.remainder[0];
|
||||||
tmpi = trunc(tmp);
|
tmpi = trunc(tmp);
|
||||||
valuator_mask_set(val, 0, tmpi);
|
valuator_mask_set(val, 0, tmpi);
|
||||||
dev->last.remainder[0] = tmp - (float)tmpi;
|
dev->last.remainder[0] = tmp - (double)tmpi;
|
||||||
}
|
}
|
||||||
if (dy) {
|
if (dy != 0.0) {
|
||||||
float tmp;
|
double tmp;
|
||||||
tmp = mult * fdy + dev->last.remainder[1];
|
tmp = mult * dy + dev->last.remainder[1];
|
||||||
tmpi = trunc(tmp);
|
tmpi = trunc(tmp);
|
||||||
valuator_mask_set(val, 1, tmpi);
|
valuator_mask_set(val, 1, tmpi);
|
||||||
dev->last.remainder[1] = tmp - (float)tmpi;
|
dev->last.remainder[1] = tmp - (double)tmpi;
|
||||||
}
|
}
|
||||||
DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n",
|
DebugAccelF("pos (%i | %i) remainders x: %.3f y: %.3f delta x:%.3f y:%.3f\n",
|
||||||
*px, *py, dev->last.remainder[0], dev->last.remainder[1], fdx, fdy);
|
*px, *py, dev->last.remainder[0], dev->last.remainder[1], dx, dy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1200,8 +1193,9 @@ acceleratePointerLightweight(
|
||||||
ValuatorMask* val,
|
ValuatorMask* val,
|
||||||
CARD32 ignored)
|
CARD32 ignored)
|
||||||
{
|
{
|
||||||
float mult = 0.0, tmpf;
|
double mult = 0.0, tmpf;
|
||||||
int dx = 0, dy = 0, tmpi;
|
double dx = 0.0, dy = 0.0;
|
||||||
|
int tmpi;
|
||||||
|
|
||||||
if (valuator_mask_isset(val, 0)) {
|
if (valuator_mask_isset(val, 0)) {
|
||||||
dx = valuator_mask_get(val, 0);
|
dx = valuator_mask_get(val, 0);
|
||||||
|
@ -1211,52 +1205,52 @@ acceleratePointerLightweight(
|
||||||
dy = valuator_mask_get(val, 1);
|
dy = valuator_mask_get(val, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dx && !dy)
|
if (dx == 0.0 && dy == 0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
|
if (dev->ptrfeed && dev->ptrfeed->ctrl.num) {
|
||||||
/* modeled from xf86Events.c */
|
/* modeled from xf86Events.c */
|
||||||
if (dev->ptrfeed->ctrl.threshold) {
|
if (dev->ptrfeed->ctrl.threshold) {
|
||||||
if ((abs(dx) + abs(dy)) >= dev->ptrfeed->ctrl.threshold) {
|
if ((abs(dx) + abs(dy)) >= dev->ptrfeed->ctrl.threshold) {
|
||||||
tmpf = ((float)dx *
|
tmpf = ((double)dx *
|
||||||
(float)(dev->ptrfeed->ctrl.num)) /
|
(double)(dev->ptrfeed->ctrl.num)) /
|
||||||
(float)(dev->ptrfeed->ctrl.den) +
|
(double)(dev->ptrfeed->ctrl.den) +
|
||||||
dev->last.remainder[0];
|
dev->last.remainder[0];
|
||||||
if (dx) {
|
if (dx != 0.0) {
|
||||||
tmpi = (int) tmpf;
|
tmpi = (int) tmpf;
|
||||||
valuator_mask_set(val, 0, tmpi);
|
valuator_mask_set(val, 0, tmpi);
|
||||||
dev->last.remainder[0] = tmpf - (float)tmpi;
|
dev->last.remainder[0] = tmpf - (double)tmpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpf = ((float)dy *
|
tmpf = ((double)dy *
|
||||||
(float)(dev->ptrfeed->ctrl.num)) /
|
(double)(dev->ptrfeed->ctrl.num)) /
|
||||||
(float)(dev->ptrfeed->ctrl.den) +
|
(double)(dev->ptrfeed->ctrl.den) +
|
||||||
dev->last.remainder[1];
|
dev->last.remainder[1];
|
||||||
if (dy) {
|
if (dy != 0.0) {
|
||||||
tmpi = (int) tmpf;
|
tmpi = (int) tmpf;
|
||||||
valuator_mask_set(val, 1, tmpi);
|
valuator_mask_set(val, 1, tmpi);
|
||||||
dev->last.remainder[1] = tmpf - (float)tmpi;
|
dev->last.remainder[1] = tmpf - (double)tmpi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mult = pow((float)dx * (float)dx + (float)dy * (float)dy,
|
mult = pow((double)dx * (double)dx + (double)dy * (double)dy,
|
||||||
((float)(dev->ptrfeed->ctrl.num) /
|
((double)(dev->ptrfeed->ctrl.num) /
|
||||||
(float)(dev->ptrfeed->ctrl.den) - 1.0) /
|
(double)(dev->ptrfeed->ctrl.den) - 1.0) /
|
||||||
2.0) / 2.0;
|
2.0) / 2.0;
|
||||||
if (dx) {
|
if (dx != 0.0) {
|
||||||
tmpf = mult * (float)dx +
|
tmpf = mult * (double)dx +
|
||||||
dev->last.remainder[0];
|
dev->last.remainder[0];
|
||||||
tmpi = (int) tmpf;
|
tmpi = (int) tmpf;
|
||||||
valuator_mask_set(val, 0, tmpi);
|
valuator_mask_set(val, 0, tmpi);
|
||||||
dev->last.remainder[0] = tmpf - (float)tmpi;
|
dev->last.remainder[0] = tmpf - (double)tmpi;
|
||||||
}
|
}
|
||||||
if (dy) {
|
if (dy != 0.0) {
|
||||||
tmpf = mult * (float)dy +
|
tmpf = mult * (double)dy +
|
||||||
dev->last.remainder[1];
|
dev->last.remainder[1];
|
||||||
tmpi = (int)tmpf;
|
tmpi = (int)tmpf;
|
||||||
valuator_mask_set(val, 1, tmpi);
|
valuator_mask_set(val, 1, tmpi);
|
||||||
dev->last.remainder[1] = tmpf - (float)tmpi;
|
dev->last.remainder[1] = tmpf - (double)tmpi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ typedef enum {
|
||||||
*/
|
*/
|
||||||
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
|
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
|
||||||
#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(11, 0)
|
#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(11, 0)
|
||||||
#define ABI_XINPUT_VERSION SET_ABI_VERSION(13, 0)
|
#define ABI_XINPUT_VERSION SET_ABI_VERSION(14, 0)
|
||||||
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(6, 0)
|
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(6, 0)
|
||||||
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
|
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@ struct _DeviceVelocityRec;
|
||||||
* profile
|
* profile
|
||||||
* returns actual acceleration depending on velocity, acceleration control,...
|
* returns actual acceleration depending on velocity, acceleration control,...
|
||||||
*/
|
*/
|
||||||
typedef float (*PointerAccelerationProfileFunc)
|
typedef double (*PointerAccelerationProfileFunc)
|
||||||
(DeviceIntPtr dev, struct _DeviceVelocityRec* vel,
|
(DeviceIntPtr dev, struct _DeviceVelocityRec* vel,
|
||||||
float velocity, float threshold, float accelCoeff);
|
double velocity, double threshold, double accelCoeff);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a motion history, with just enough information to
|
* a motion history, with just enough information to
|
||||||
|
@ -57,7 +57,7 @@ typedef float (*PointerAccelerationProfileFunc)
|
||||||
* a more or less straight line
|
* a more or less straight line
|
||||||
*/
|
*/
|
||||||
typedef struct _MotionTracker {
|
typedef struct _MotionTracker {
|
||||||
int dx, dy; /* accumulated delta for each axis */
|
double dx, dy; /* accumulated delta for each axis */
|
||||||
int time; /* time of creation */
|
int time; /* time of creation */
|
||||||
int dir; /* initial direction bitfield */
|
int dir; /* initial direction bitfield */
|
||||||
} MotionTracker, *MotionTrackerPtr;
|
} MotionTracker, *MotionTrackerPtr;
|
||||||
|
@ -69,17 +69,17 @@ typedef struct _DeviceVelocityRec {
|
||||||
MotionTrackerPtr tracker;
|
MotionTrackerPtr tracker;
|
||||||
int num_tracker;
|
int num_tracker;
|
||||||
int cur_tracker; /* current index */
|
int cur_tracker; /* current index */
|
||||||
float velocity; /* velocity as guessed by algorithm */
|
double velocity; /* velocity as guessed by algorithm */
|
||||||
float last_velocity; /* previous velocity estimate */
|
double last_velocity; /* previous velocity estimate */
|
||||||
int last_dx; /* last time-difference */
|
double last_dx; /* last time-difference */
|
||||||
int last_dy ; /* phase of last/current estimate */
|
double last_dy; /* phase of last/current estimate */
|
||||||
float corr_mul; /* config: multiply this into velocity */
|
double corr_mul; /* config: multiply this into velocity */
|
||||||
float const_acceleration; /* config: (recipr.) const deceleration */
|
double const_acceleration; /* config: (recipr.) const deceleration */
|
||||||
float min_acceleration; /* config: minimum acceleration */
|
double min_acceleration; /* config: minimum acceleration */
|
||||||
short reset_time; /* config: reset non-visible state after # ms */
|
short reset_time; /* config: reset non-visible state after # ms */
|
||||||
short use_softening; /* config: use softening of mouse values */
|
short use_softening; /* config: use softening of mouse values */
|
||||||
float max_rel_diff; /* config: max. relative difference */
|
double max_rel_diff; /* config: max. relative difference */
|
||||||
float max_diff; /* config: max. difference */
|
double max_diff; /* config: max. difference */
|
||||||
int initial_range; /* config: max. offset used as initial velocity */
|
int initial_range; /* config: max. offset used as initial velocity */
|
||||||
Bool average_accel; /* config: average acceleration over velocity */
|
Bool average_accel; /* config: average acceleration over velocity */
|
||||||
PointerAccelerationProfileFunc Profile;
|
PointerAccelerationProfileFunc Profile;
|
||||||
|
@ -107,11 +107,11 @@ extern _X_EXPORT void
|
||||||
InitTrackers(DeviceVelocityPtr vel, int ntracker);
|
InitTrackers(DeviceVelocityPtr vel, int ntracker);
|
||||||
|
|
||||||
extern _X_EXPORT BOOL
|
extern _X_EXPORT BOOL
|
||||||
ProcessVelocityData2D(DeviceVelocityPtr vel, int dx, int dy, int time);
|
ProcessVelocityData2D(DeviceVelocityPtr vel, double dx, double dy, int time);
|
||||||
|
|
||||||
extern _X_EXPORT float
|
extern _X_EXPORT double
|
||||||
BasicComputeAcceleration(DeviceIntPtr dev, DeviceVelocityPtr vel,
|
BasicComputeAcceleration(DeviceIntPtr dev, DeviceVelocityPtr vel,
|
||||||
float velocity, float threshold, float acc);
|
double velocity, double threshold, double acc);
|
||||||
|
|
||||||
extern _X_EXPORT void
|
extern _X_EXPORT void
|
||||||
FreeVelocityData(DeviceVelocityPtr vel);
|
FreeVelocityData(DeviceVelocityPtr vel);
|
||||||
|
|
Loading…
Reference in New Issue