summaryrefslogtreecommitdiff
path: root/dix/devices.c
diff options
context:
space:
mode:
authorSimon Thum <simon.thum@gmx.de>2010-09-04 16:31:24 +0200
committerPeter Hutterer <peter.hutterer@who-t.net>2011-02-17 10:23:01 +1000
commit006157f203f8493bb3d18e333a3fd3d6cb10f8ea (patch)
tree80d69f0d2189d3119b782f9c1b089cfc01b7839b /dix/devices.c
parent38ffeec0c89e83afc62579dec221c325d667cc1e (diff)
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>
Diffstat (limited to 'dix/devices.c')
-rw-r--r--dix/devices.c53
1 files changed, 16 insertions, 37 deletions
diff --git a/dix/devices.c b/dix/devices.c
index 6c0dc42a4..3065319d0 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1279,10 +1279,11 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
/* global list of acceleration schemes */
ValuatorAccelerationRec pointerAccelerationScheme[] = {
- {PtrAccelNoOp, NULL, NULL, NULL},
- {PtrAccelPredictable, acceleratePointerPredictable, NULL, AccelerationDefaultCleanup},
- {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL},
- {-1, NULL, NULL, NULL} /* terminator */
+ {PtrAccelNoOp, NULL, NULL, NULL, NULL},
+ {PtrAccelPredictable, acceleratePointerPredictable, NULL,
+ InitPredictableAccelerationScheme, AccelerationDefaultCleanup},
+ {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL, NULL},
+ {-1, NULL, NULL, NULL, NULL} /* terminator */
};
/**
@@ -1294,59 +1295,37 @@ InitPointerAccelerationScheme(DeviceIntPtr dev,
int scheme)
{
int x, i = -1;
- void* data = NULL;
ValuatorClassPtr val;
val = dev->valuator;
- if(!val)
- return FALSE;
+ if (!val)
+ return FALSE;
- if(IsMaster(dev) && scheme != PtrAccelNoOp)
+ if (IsMaster(dev) && scheme != PtrAccelNoOp)
return FALSE;
- for(x = 0; pointerAccelerationScheme[x].number >= 0; x++) {
+ for (x = 0; pointerAccelerationScheme[x].number >= 0; x++) {
if(pointerAccelerationScheme[x].number == scheme){
i = x;
break;
}
}
- if(-1 == i)
+ if (-1 == i)
return FALSE;
if (val->accelScheme.AccelCleanupProc)
val->accelScheme.AccelCleanupProc(dev);
- /* init scheme-specific data */
- switch(scheme){
- case PtrAccelPredictable:
- {
- DeviceVelocityPtr s;
- s = malloc(sizeof(DeviceVelocityRec));
- if(!s)
- return FALSE;
- InitVelocityData(s);
- data = s;
- break;
+ if (pointerAccelerationScheme[i].AccelInitProc) {
+ if (!pointerAccelerationScheme[i].AccelInitProc(dev,
+ &pointerAccelerationScheme[i])) {
+ return FALSE;
}
- default:
- break;
+ } else {
+ val->accelScheme = pointerAccelerationScheme[i];
}
-
- val->accelScheme = pointerAccelerationScheme[i];
- val->accelScheme.accelData = data;
-
- /* post-init scheme */
- switch(scheme){
- case PtrAccelPredictable:
- InitializePredictableAccelerationProperties(dev);
- break;
-
- default:
- break;
- }
-
return TRUE;
}