dix: add smooth limited pointer acceleration profile
This profile is inspired by the accel code removed from the wacom driver. It ascends from zero to acceleration, maxing out at threshold. This means you can control the slope using threshold, which wasn't possible in wacom. For sanity's sake, threshold should grow with acceleration. Works best with adaptive deceleration, since otherwise it only generates acceleration above 1, causing seldom pixel skips. Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
435f27667f
commit
1763550d01
|
@ -868,6 +868,31 @@ SmoothLinearProfile(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From 0 to threshold, the response graduates smoothly from min_accel to
|
||||||
|
* acceleration. Beyond threshold it is exactly the specified acceleration.
|
||||||
|
*/
|
||||||
|
static float
|
||||||
|
SmoothLimitedProfile(
|
||||||
|
DeviceIntPtr dev,
|
||||||
|
DeviceVelocityPtr vel,
|
||||||
|
float velocity,
|
||||||
|
float threshold,
|
||||||
|
float acc)
|
||||||
|
{
|
||||||
|
float res;
|
||||||
|
|
||||||
|
if(velocity >= threshold || threshold == 0.0f)
|
||||||
|
return acc;
|
||||||
|
|
||||||
|
velocity /= threshold; /* should be [0..1[ now */
|
||||||
|
|
||||||
|
res = CalcPenumbralGradient(velocity) * (acc - vel->min_acceleration);
|
||||||
|
|
||||||
|
return vel->min_acceleration + res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static float
|
static float
|
||||||
LinearProfile(
|
LinearProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
|
@ -879,7 +904,6 @@ LinearProfile(
|
||||||
return acc * velocity;
|
return acc * velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static float
|
static float
|
||||||
NoProfile(
|
NoProfile(
|
||||||
DeviceIntPtr dev,
|
DeviceIntPtr dev,
|
||||||
|
@ -911,6 +935,8 @@ GetAccelerationProfile(
|
||||||
return PowerProfile;
|
return PowerProfile;
|
||||||
case AccelProfileLinear:
|
case AccelProfileLinear:
|
||||||
return LinearProfile;
|
return LinearProfile;
|
||||||
|
case AccelProfileSmoothLimited:
|
||||||
|
return SmoothLimitedProfile;
|
||||||
case AccelProfileNone:
|
case AccelProfileNone:
|
||||||
return NoProfile;
|
return NoProfile;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -37,7 +37,8 @@
|
||||||
#define AccelProfileSimple 4
|
#define AccelProfileSimple 4
|
||||||
#define AccelProfilePower 5
|
#define AccelProfilePower 5
|
||||||
#define AccelProfileLinear 6
|
#define AccelProfileLinear 6
|
||||||
#define AccelProfileLAST AccelProfileLinear
|
#define AccelProfileSmoothLimited 7
|
||||||
|
#define AccelProfileLAST AccelProfileSmoothLimited
|
||||||
|
|
||||||
/* fwd */
|
/* fwd */
|
||||||
struct _DeviceVelocityRec;
|
struct _DeviceVelocityRec;
|
||||||
|
|
Loading…
Reference in New Issue