dix: refactor scheme init

This makes it possible to init a scheme in one init call, so we
get rid of the tightly coupled two-phase init used before.

Signed-off-by: Simon Thum <simon.thum@gmx.de>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Simon Thum
2010-09-04 16:31:24 +02:00
committed by Peter Hutterer
parent 38ffeec0c8
commit 006157f203
5 changed files with 57 additions and 52 deletions

View File

@@ -67,6 +67,10 @@ SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr vel, float velocity,
float threshold, float acc);
static PointerAccelerationProfileFunc
GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
static BOOL
InitializePredictableAccelerationProperties(DeviceIntPtr dev);
static BOOL
DeletePredictableAccelerationProperties(DeviceIntPtr dev);
/*#define PTRACCEL_DEBUGGING*/
@@ -85,7 +89,7 @@ GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num);
/**
* Init struct so it should match the average case
* Init DeviceVelocity struct so it should match the average case
*/
void
InitVelocityData(DeviceVelocityPtr vel)
@@ -107,7 +111,7 @@ InitVelocityData(DeviceVelocityPtr vel)
/**
* Clean up
* Clean up DeviceVelocityRec
*/
void
FreeVelocityData(DeviceVelocityPtr vel){
@@ -116,8 +120,28 @@ FreeVelocityData(DeviceVelocityPtr vel){
}
/*
* dix uninit helper, called through scheme
/**
* Init predictable scheme
*/
Bool
InitPredictableAccelerationScheme(DeviceIntPtr dev,
ValuatorAccelerationPtr protoScheme) {
DeviceVelocityPtr vel;
ValuatorAccelerationRec scheme;
scheme = *protoScheme;
vel = calloc(1, sizeof(DeviceVelocityRec));
if (!vel)
return FALSE;
InitVelocityData(vel);
scheme.accelData = vel;
dev->valuator->accelScheme = scheme;
InitializePredictableAccelerationProperties(dev);
return TRUE;
}
/**
* Uninit scheme
*/
void
AccelerationDefaultCleanup(DeviceIntPtr dev)
@@ -1024,12 +1048,10 @@ acceleratePointerPredictable(
int *valuators,
int evtime)
{
float mult = 0.0;
float fdx, fdy, tmp, mult; /* no need to init */
int dx = 0, dy = 0;
int *px = NULL, *py = NULL;
DeviceVelocityPtr velocitydata =
(DeviceVelocityPtr) dev->valuator->accelScheme.accelData;
float fdx, fdy, tmp; /* no need to init */
DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev);
Bool soften = TRUE;
if (!num_valuators || !valuators || !velocitydata)