On Sat, Feb 05, 2011 at 10:39:43PM +0100, Simon Thum wrote: > the patch series consists mainly of refactoring, no functional changes. > The main point is to separate property handling from the acceleration > structure and to make use of the ValuatorMask struct now in place. > > They work on my machine, any I don't think much further testing is required. > > And one more thing: The some code in AddInputDevice seems bogus to me, > but I don't have the HW to test it. The transform matrix gets set as a > input property before the handler is registered. Thus if I'm right, > dev->transform never gets initialized as long as no-one updates the > property. Simply moving the handler registration upwards should fix it. > > Cheers, > > Simon
> From b1fe1b9b727f2018ced6e90f7f6e492c20069703 Mon Sep 17 00:00:00 2001 > From: Simon Thum <[email protected]> > Date: Sat, 4 Sep 2010 16:31:24 +0200 > Subject: [PATCH 1/4] dix: refactor scheme init why? what has been done, with what purpose? the commit message should explain this, future archeologists may rely on it. one thing that goes across all 4 patches: please check the indentation. there's plenty of space/tab mixups. as usual, the golden rule is "same indentation as the surrounding code". > Signed-off-by: Simon Thum <[email protected]> > --- > dix/devices.c | 53 +++++++++++++++------------------------------------ > dix/ptrveloc.c | 34 +++++++++++++++++++++++++------- > include/input.h | 5 ++++ > include/inputstr.h | 1 + > include/ptrveloc.h | 4 +++ > 5 files changed, 52 insertions(+), 45 deletions(-) > > diff --git a/dix/devices.c b/dix/devices.c > index 6c0dc42..052813a 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) > + 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; > - } > - default: > - break; > - } > - > - val->accelScheme = pointerAccelerationScheme[i]; > - val->accelScheme.accelData = data; > - > - /* post-init scheme */ > - switch(scheme){ > - case PtrAccelPredictable: > - InitializePredictableAccelerationProperties(dev); > - break; > - > - default: > - break; > + if (pointerAccelerationScheme[i].AccelInitProc) { > + if (!pointerAccelerationScheme[i].AccelInitProc(dev, > + &pointerAccelerationScheme[i])) { > + return FALSE; > + } > + } else { > + val->accelScheme = pointerAccelerationScheme[i]; spaces, no tabs here please. i believe the other code is space-indented too. > } > - > return TRUE; > } > > diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c > index 8f03321..829cbf4 100644 > --- a/dix/ptrveloc.c > +++ b/dix/ptrveloc.c > @@ -85,7 +85,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 +107,7 @@ InitVelocityData(DeviceVelocityPtr vel) > > > /** > - * Clean up > + * Clean up DeviceVelocityRec > */ > void > FreeVelocityData(DeviceVelocityPtr vel){ > @@ -116,8 +116,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); while you're refacturing - why not return the memory allocated from InitVelocityData()? > + scheme.accelData = vel; > + dev->valuator->accelScheme = scheme; > + InitializePredictableAccelerationProperties(dev); > + return TRUE; > +} > + > + > +/** > + * Uninit scheme > */ > void > AccelerationDefaultCleanup(DeviceIntPtr dev) > @@ -1024,12 +1044,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) > diff --git a/include/input.h b/include/input.h > index f96a0a9..ab58a15 100644 > --- a/include/input.h > +++ b/include/input.h > @@ -150,6 +150,11 @@ typedef void (*PointerAccelSchemeProc)( > typedef void (*DeviceCallbackProc)( > DeviceIntPtr /*pDev*/); > > +struct _ValuatorAccelerationRec; > +typedef Bool (*PointerAccelSchemeInitProc)( > + DeviceIntPtr /*dev*/, > + struct _ValuatorAccelerationRec* /*protoScheme*/); > + > typedef struct _DeviceRec { > pointer devicePrivate; > ProcessInputProc processInputProc; /* current */ > diff --git a/include/inputstr.h b/include/inputstr.h > index b74ee04..65b9ef9 100644 > --- a/include/inputstr.h > +++ b/include/inputstr.h > @@ -266,6 +266,7 @@ typedef struct _ValuatorAccelerationRec { > int number; > PointerAccelSchemeProc AccelSchemeProc; > void *accelData; /* at disposal of AccelScheme */ > + PointerAccelSchemeInitProc AccelInitProc; > DeviceCallbackProc AccelCleanupProc; > } ValuatorAccelerationRec, *ValuatorAccelerationPtr; > > diff --git a/include/ptrveloc.h b/include/ptrveloc.h > index 6f999a8..8d7f037 100644 > --- a/include/ptrveloc.h > +++ b/include/ptrveloc.h > @@ -129,6 +129,10 @@ SetDeviceSpecificAccelerationProfile(DeviceVelocityPtr > vel, > extern _X_INTERNAL void > AccelerationDefaultCleanup(DeviceIntPtr dev); > > +extern _X_INTERNAL Bool > +InitPredictableAccelerationScheme(DeviceIntPtr dev, > + struct _ValuatorAccelerationRec* protoScheme); > + > extern _X_INTERNAL void > acceleratePointerPredictable(DeviceIntPtr dev, int first_valuator, > int num_valuators, int *valuators, int evtime); > -- > 1.7.3.4 > > From 61520c030634911182a7ef81b7360ad2b7ab485c Mon Sep 17 00:00:00 2001 > From: Simon Thum <[email protected]> > Date: Sun, 5 Sep 2010 18:10:42 +0200 > Subject: [PATCH 2/4] dix: refactor predictable scheme initialization > > This intends to clean up the predictable accel struct > from purely scheme-related things like input properties, > as they would be useless in other use cases such > as wheel acceleration. > > Signed-off-by: Simon Thum <[email protected]> > --- > dix/ptrveloc.c | 68 > ++++++++++++++++++++++++++++++++++++---------------- > include/ptrveloc.h | 22 +++++++++------- > 2 files changed, 59 insertions(+), 31 deletions(-) > > diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c > index 829cbf4..e2b9e12 100644 > --- a/dix/ptrveloc.c > +++ b/dix/ptrveloc.c > @@ -30,6 +30,7 @@ > #include <ptrveloc.h> > #include <exevents.h> > #include <X11/Xatom.h> > +#include <os.h> > > #include <xserver-properties.h> > > @@ -67,6 +68,10 @@ SimpleSmoothProfile(DeviceIntPtr dev, DeviceVelocityPtr > vel, float velocity, > float threshold, float acc); > static PointerAccelerationProfileFunc > GetAccelerationProfile(DeviceVelocityPtr vel, int profile_num); > +static BOOL > +InitializePredictableAccelerationProperties(DeviceIntPtr, long*); > +static BOOL > +DeletePredictableAccelerationProperties(DeviceIntPtr, long*); > > /*#define PTRACCEL_DEBUGGING*/ > > @@ -124,14 +129,21 @@ InitPredictableAccelerationScheme(DeviceIntPtr dev, > ValuatorAccelerationPtr protoScheme) { > DeviceVelocityPtr vel; > ValuatorAccelerationRec scheme; > + PredictableAccelSchemePtr schemeData; > scheme = *protoScheme; > vel = calloc(1, sizeof(DeviceVelocityRec)); > - if (!vel) > + schemeData = calloc(1, sizeof(PredictableAccelSchemeRec)); > + if (!vel || !schemeData) > return FALSE; > InitVelocityData(vel); > - scheme.accelData = vel; > + schemeData->vel = vel; > + schemeData->prop_handlers = calloc(NPROPS_PREDICTABLE_ACCEL, > + sizeof(long)); > + if (!schemeData->prop_handlers) > + return FALSE; > + scheme.accelData = schemeData; > dev->valuator->accelScheme = scheme; > - InitializePredictableAccelerationProperties(dev); > + InitializePredictableAccelerationProperties(dev, > schemeData->prop_handlers); > return TRUE; > } > > @@ -142,14 +154,24 @@ InitPredictableAccelerationScheme(DeviceIntPtr dev, > void > AccelerationDefaultCleanup(DeviceIntPtr dev) > { > - /*sanity check*/ > - if( dev->valuator->accelScheme.AccelSchemeProc == > acceleratePointerPredictable > - && dev->valuator->accelScheme.accelData != NULL){ > + DeviceVelocityPtr vel = GetDevicePredictableAccelData(dev); > + long* prop_handlers; > + if (vel) { > + /* the proper guarantee would be that we're not inside of > + * AccelSchemeProc(), but that seems impossible. Schemes don't get > + * schwitched often anyway. > + */ > + OsBlockSignals(); > dev->valuator->accelScheme.AccelSchemeProc = NULL; > - FreeVelocityData(dev->valuator->accelScheme.accelData); > + FreeVelocityData(vel); > + free(vel); while you're refacturing - is there any case where we need FreeVelocityData(vel) without free(vel)? If not, could that be merged together? > + prop_handlers = ((PredictableAccelSchemePtr) > + dev->valuator->accelScheme.accelData)->prop_handlers; > + DeletePredictableAccelerationProperties(dev, prop_handlers); > + free(prop_handlers); > free(dev->valuator->accelScheme.accelData); > dev->valuator->accelScheme.accelData = NULL; > - DeletePredictableAccelerationProperties(dev); > + OsReleaseSignals(); > } > } > > @@ -341,26 +363,30 @@ AccelInitScaleProperty(DeviceIntPtr dev, > DeviceVelocityPtr vel) > return XIRegisterPropertyHandler(dev, AccelSetScaleProperty, NULL, NULL); > } > > -BOOL > -InitializePredictableAccelerationProperties(DeviceIntPtr dev) > +static BOOL > +InitializePredictableAccelerationProperties( > + DeviceIntPtr dev, > + long* prop_handlers) > { > DeviceVelocityPtr vel = GetDevicePredictableAccelData(dev); > > if(!vel) > return FALSE; > > - vel->prop_handlers[0] = AccelInitProfileProperty(dev, vel); > - vel->prop_handlers[1] = AccelInitDecelProperty(dev, vel); > - vel->prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel); > - vel->prop_handlers[3] = AccelInitScaleProperty(dev, vel); > + prop_handlers[0] = AccelInitProfileProperty(dev, vel); > + prop_handlers[1] = AccelInitDecelProperty(dev, vel); > + prop_handlers[2] = AccelInitAdaptDecelProperty(dev, vel); > + prop_handlers[3] = AccelInitScaleProperty(dev, vel); > > return TRUE; > } > > BOOL > -DeletePredictableAccelerationProperties(DeviceIntPtr dev) > +DeletePredictableAccelerationProperties( > + DeviceIntPtr dev, > + long* prop_handlers) > { > - DeviceVelocityPtr vel; > + DeviceVelocityPtr vel; > Atom prop; > int i; > > @@ -375,8 +401,8 @@ DeletePredictableAccelerationProperties(DeviceIntPtr dev) > > vel = GetDevicePredictableAccelData(dev); > for (i = 0; vel && i < NPROPS_PREDICTABLE_ACCEL; i++) > - if (vel->prop_handlers[i]) > - XIUnregisterPropertyHandler(dev, vel->prop_handlers[i]); > + if (prop_handlers[i]) > + XIUnregisterPropertyHandler(dev, prop_handlers[i]); > > return TRUE; > } > @@ -393,8 +419,7 @@ InitTrackers(DeviceVelocityPtr vel, int ntracker) > return; > } > free(vel->tracker); > - vel->tracker = (MotionTrackerPtr)malloc(ntracker * > sizeof(MotionTracker)); > - memset(vel->tracker, 0, ntracker * sizeof(MotionTracker)); > + vel->tracker = (MotionTrackerPtr)calloc(ntracker, sizeof(MotionTracker)); > vel->num_tracker = ntracker; > } > > @@ -1022,7 +1047,8 @@ GetDevicePredictableAccelData( > acceleratePointerPredictable && > dev->valuator->accelScheme.accelData != NULL){ > > - return (DeviceVelocityPtr)dev->valuator->accelScheme.accelData; > + return ((PredictableAccelSchemePtr) > + dev->valuator->accelScheme.accelData)->vel; > } > return NULL; > } > diff --git a/include/ptrveloc.h b/include/ptrveloc.h > index 8d7f037..3cc3d97 100644 > --- a/include/ptrveloc.h > +++ b/include/ptrveloc.h > @@ -62,9 +62,6 @@ typedef struct _MotionTracker { > int dir; /* initial direction bitfield */ > } MotionTracker, *MotionTrackerPtr; > > -/* number of properties for predictable acceleration */ > -#define NPROPS_PREDICTABLE_ACCEL 4 > - > /** > * Contains all data needed to implement mouse ballistics > */ > @@ -91,9 +88,20 @@ typedef struct _DeviceVelocityRec { > struct { /* to be able to query this information */ > int profile_number; > } statistics; > - long prop_handlers[NPROPS_PREDICTABLE_ACCEL]; > } DeviceVelocityRec, *DeviceVelocityPtr; > > +/* number of properties for predictable acceleration */ > +#define NPROPS_PREDICTABLE_ACCEL 4 > + > +/** > + * contains the run-time data for the predictable scheme, that is, a > + * DeviceVelocityPtr and the property handlers. > + */ > +typedef struct _PredictableAccelSchemeRec { > + DeviceVelocityPtr vel; > + long* prop_handlers; No magic "we just know how many are in there" arrays please. Add another field for the array size. > +} PredictableAccelSchemeRec, *PredictableAccelSchemePtr; > + > extern _X_EXPORT void > InitVelocityData(DeviceVelocityPtr vel); > > @@ -110,12 +118,6 @@ BasicComputeAcceleration(DeviceIntPtr dev, > DeviceVelocityPtr vel, > extern _X_EXPORT void > FreeVelocityData(DeviceVelocityPtr vel); > > -extern _X_INTERNAL BOOL > -InitializePredictableAccelerationProperties(DeviceIntPtr dev); > - > -extern _X_INTERNAL BOOL > -DeletePredictableAccelerationProperties(DeviceIntPtr dev); > - > extern _X_EXPORT int > SetAccelerationProfile(DeviceVelocityPtr vel, int profile_num); > > -- > 1.7.3.4 > > From 9ccb40ac70f2231782d8d5d746effcd031dad0e4 Mon Sep 17 00:00:00 2001 > From: Simon Thum <[email protected]> > Date: Wed, 2 Feb 2011 00:03:44 +0100 > Subject: [PATCH 3/4] dix: avoid FP promotion during pointer acceleration > > Signed-off-by: Simon Thum <[email protected]> > --- > dix/ptrveloc.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c > index e2b9e12..4fb6ef1 100644 > --- a/dix/ptrveloc.c > +++ b/dix/ptrveloc.c > @@ -1106,11 +1106,11 @@ acceleratePointerPredictable( > (float)dev->ptrfeed->ctrl.num / > (float)dev->ptrfeed->ctrl.den); > > - if(mult != 1.0 || velocitydata->const_acceleration != 1.0) { > + if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) { > ApplySofteningAndConstantDeceleration( velocitydata, > dx, dy, > &fdx, &fdy, > - (mult > 1.0) && soften); > + (mult > 1.0f) && soften); > > if (dx) { > tmp = mult * fdx + dev->last.remainder[0]; > -- > 1.7.3.4 Reviewed-by: Peter Hutterer <[email protected]> > From 6d541530bef8d0676cfe57d52689d133c9748de0 Mon Sep 17 00:00:00 2001 > From: Simon Thum <[email protected]> > Date: Thu, 3 Feb 2011 21:52:24 +0100 > Subject: [PATCH 4/4] dix: update pointer acceleration code to use ValuatorMask > > Signed-off-by: Simon Thum <[email protected]> > --- > dix/getevents.c | 24 ++--------- > dix/ptrveloc.c | 114 ++++++++++++++++++++++++--------------------------- > include/input.h | 10 ++--- > include/ptrveloc.h | 15 +++---- > 4 files changed, 68 insertions(+), 95 deletions(-) > > diff --git a/dix/getevents.c b/dix/getevents.c > index 794df42..1ccddfa 100644 > --- a/dix/getevents.c > +++ b/dix/getevents.c > @@ -791,17 +791,14 @@ moveRelative(DeviceIntPtr dev, int *x, int *y, > ValuatorMask *mask) > * Accelerate the data in valuators based on the device's acceleration > scheme. > * > * @param dev The device which's pointer is to be moved. > - * @param first The first valuator in @valuators > - * @param num Total number of valuators in @valuators. > - * @param valuators Valuator data for each axis between @first and > - * @first+@num. > + * @param valuators Valuator mask > * @param ms Current time. > */ > static void > -accelPointer(DeviceIntPtr dev, int first, int num, int *valuators, CARD32 ms) > +accelPointer(DeviceIntPtr dev, ValuatorMask* valuators, CARD32 ms) > { > if (dev->valuator->accelScheme.AccelSchemeProc) > - dev->valuator->accelScheme.AccelSchemeProc(dev, first, num, > valuators, ms); > + dev->valuator->accelScheme.AccelSchemeProc(dev, valuators, ms); > } > > /** > @@ -1169,20 +1166,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, > int type, int buttons, > moveAbsolute(pDev, &x, &y, &mask); > } else { > if (flags & POINTER_ACCELERATE) { > - /* FIXME: Pointer acceleration only requires X and Y values. This > - * should be converted to masked valuators. */ > - int vals[2]; > - vals[0] = valuator_mask_isset(&mask, 0) ? > - valuator_mask_get(&mask, 0) : 0; > - vals[1] = valuator_mask_isset(&mask, 1) ? > - valuator_mask_get(&mask, 1) : 0; > - accelPointer(pDev, 0, 2, vals, ms); > - > - if (valuator_mask_isset(&mask, 0)) > - valuator_mask_set(&mask, 0, vals[0]); > - if (valuator_mask_isset(&mask, 1)) > - valuator_mask_set(&mask, 1, vals[1]); > - > + accelPointer(pDev, &mask, ms); > /* The pointer acceleration code modifies the fractional part > * in-place, so we need to extract this information first */ > x_frac = pDev->last.remainder[0]; > diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c > index 4fb6ef1..ceae72b 100644 > --- a/dix/ptrveloc.c > +++ b/dix/ptrveloc.c > @@ -81,6 +81,9 @@ DeletePredictableAccelerationProperties(DeviceIntPtr, > long*); > #define DebugAccelF(...) /* */ > #endif > > +/* number of input properties for predictable acceleration */ > +#define NPROPS_PREDICTABLE_ACCEL 4 > + > /******************************** > * Init/Uninit > *******************************/ > @@ -1065,18 +1068,15 @@ GetDevicePredictableAccelData( > void > acceleratePointerPredictable( > DeviceIntPtr dev, > - int first_valuator, > - int num_valuators, > - int *valuators, > - int evtime) > + ValuatorMask* val, > + CARD32 evtime) > { > float fdx, fdy, tmp, mult; /* no need to init */ > - int dx = 0, dy = 0; > - int *px = NULL, *py = NULL; > + int dx = 0, dy = 0, tmpi; > DeviceVelocityPtr velocitydata = GetDevicePredictableAccelData(dev); > Bool soften = TRUE; > > - if (!num_valuators || !valuators || !velocitydata) > + if (!velocitydata) > return; > > if (velocitydata->statistics.profile_number == AccelProfileNone && > @@ -1084,13 +1084,12 @@ acceleratePointerPredictable( > return; /*we're inactive anyway, so skip the whole thing.*/ > } > > - if (first_valuator == 0) { > - dx = valuators[0]; > - px = &valuators[0]; > + if (valuator_mask_isset(val, 0)) { > + dx = valuator_mask_get(val, 0); > } > - if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) { > - dy = valuators[1 - first_valuator]; > - py = &valuators[1 - first_valuator]; > + > + if (valuator_mask_isset(val, 1)) { > + dy = valuator_mask_get(val, 1); > } > > if (dx || dy){ > @@ -1104,7 +1103,7 @@ acceleratePointerPredictable( > mult = ComputeAcceleration (dev, velocitydata, > dev->ptrfeed->ctrl.threshold, > (float)dev->ptrfeed->ctrl.num / > - (float)dev->ptrfeed->ctrl.den); > + (float)dev->ptrfeed->ctrl.den); > > if(mult != 1.0f || velocitydata->const_acceleration != 1.0f) { > ApplySofteningAndConstantDeceleration( velocitydata, > @@ -1119,13 +1118,15 @@ acceleratePointerPredictable( > * process each axis conditionally, there's no danger > * of a toggling remainder. Its lack of guarantees likely > * makes it faster on the average target. */ > - *px = lrintf(tmp); > - dev->last.remainder[0] = tmp - (float)*px; > + tmpi = lrintf(tmp); > + valuator_mask_set(val, 0, tmpi); > + dev->last.remainder[0] = tmp - (float)tmpi; > } > if (dy) { > tmp = mult * fdy + dev->last.remainder[1]; > - *py = lrintf(tmp); > - dev->last.remainder[1] = tmp - (float)*py; > + tmpi = lrintf(tmp); > + valuator_mask_set(val, 1, tmpi); > + dev->last.remainder[1] = tmp - (float)tmpi; > } > 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); > @@ -1146,25 +1147,18 @@ acceleratePointerPredictable( > void > acceleratePointerLightweight( > DeviceIntPtr dev, > - int first_valuator, > - int num_valuators, > - int *valuators, > - int ignored) > + ValuatorMask* val, > + CARD32 ignored) > { > - float mult = 0.0; > - int dx = 0, dy = 0; > - int *px = NULL, *py = NULL; > - > - if (!num_valuators || !valuators) > - return; > + float mult = 0.0, tmpf; > + int dx = 0, dy = 0, tmpi; > > - if (first_valuator == 0) { > - dx = valuators[0]; > - px = &valuators[0]; > + if (valuator_mask_isset(val, 0)) { > + dx = valuator_mask_get(val, 0); > } > - if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) { > - dy = valuators[1 - first_valuator]; > - py = &valuators[1 - first_valuator]; > + > + if (valuator_mask_isset(val, 1)) { > + dy = valuator_mask_get(val, 1); > } > > if (!dx && !dy) > @@ -1174,24 +1168,24 @@ acceleratePointerLightweight( > /* modeled from xf86Events.c */ > if (dev->ptrfeed->ctrl.threshold) { > if ((abs(dx) + abs(dy)) >= dev->ptrfeed->ctrl.threshold) { > - dev->last.remainder[0] = ((float)dx * > - > (float)(dev->ptrfeed->ctrl.num)) / > - (float)(dev->ptrfeed->ctrl.den) > + > - dev->last.remainder[0]; > - if (px) { > - *px = (int)dev->last.remainder[0]; > - dev->last.remainder[0] = dev->last.remainder[0] - > - (float)(*px); > + tmpf = ((float)dx * > + (float)(dev->ptrfeed->ctrl.num)) / > + (float)(dev->ptrfeed->ctrl.den) + > + dev->last.remainder[0]; > + if (dx) { > + tmpi = (int) tmpf; > + valuator_mask_set(val, 0, tmpi); > + dev->last.remainder[0] = tmpf - (float)tmpi; > } > > - dev->last.remainder[1] = ((float)dy * > - > (float)(dev->ptrfeed->ctrl.num)) / > - (float)(dev->ptrfeed->ctrl.den) > + > - dev->last.remainder[1]; > - if (py) { > - *py = (int)dev->last.remainder[1]; > - dev->last.remainder[1] = dev->last.remainder[1] - > - (float)(*py); > + tmpf = ((float)dy * > + (float)(dev->ptrfeed->ctrl.num)) / > + (float)(dev->ptrfeed->ctrl.den) + > + dev->last.remainder[1]; > + if (dy) { > + tmpi = (int) tmpf; > + valuator_mask_set(val, 1, tmpi); > + dev->last.remainder[1] = tmpf - (float)tmpi; > } > } > } > @@ -1201,18 +1195,18 @@ acceleratePointerLightweight( > (float)(dev->ptrfeed->ctrl.den) - 1.0) / > 2.0) / 2.0; > if (dx) { > - dev->last.remainder[0] = mult * (float)dx + > - dev->last.remainder[0]; > - *px = (int)dev->last.remainder[0]; > - dev->last.remainder[0] = dev->last.remainder[0] - > - (float)(*px); > + tmpf = mult * (float)dx + > + dev->last.remainder[0]; > + tmpi = (int) tmpf; > + valuator_mask_set(val, 0, tmpi); > + dev->last.remainder[0] = tmpf - (float)tmpi; > } > if (dy) { > - dev->last.remainder[1] = mult * (float)dy + > - dev->last.remainder[1]; > - *py = (int)dev->last.remainder[1]; > - dev->last.remainder[1] = dev->last.remainder[1] - > - (float)(*py); > + tmpf = mult * (float)dy + > + dev->last.remainder[1]; > + tmpi = (int)tmpf; > + valuator_mask_set(val, 1, tmpi); > + dev->last.remainder[1] = tmpf - (float)tmpi; > } > } > } > diff --git a/include/input.h b/include/input.h > index ab58a15..3b2652c 100644 > --- a/include/input.h > +++ b/include/input.h > @@ -106,6 +106,8 @@ typedef struct _ClassesRec *ClassesPtr; > typedef struct _SpriteRec *SpritePtr; > typedef union _GrabMask GrabMask; > > +typedef struct _ValuatorMask ValuatorMask; > + > typedef struct _EventList { > xEvent* event; > int evlen; /* length of allocated memory for event in bytes. This is not > @@ -142,10 +144,8 @@ typedef void (*DeviceUnwrapProc)( > /* pointer acceleration handling */ > typedef void (*PointerAccelSchemeProc)( > DeviceIntPtr /*pDev*/, > - int /*first_valuator*/, > - int /*num_valuators*/, > - int* /*valuators*/, > - int /*evtime*/); > + ValuatorMask* /*first_valuator*/, "first_valuator" ? > + CARD32 /*evtime*/); > > typedef void (*DeviceCallbackProc)( > DeviceIntPtr /*pDev*/); > @@ -163,8 +163,6 @@ typedef struct _DeviceRec { > Bool on; /* used by DDX to keep state */ > } DeviceRec, *DevicePtr; > > -typedef struct _ValuatorMask ValuatorMask; > - > typedef struct { > int click, bell, bell_pitch, bell_duration; > Bool autoRepeat; > diff --git a/include/ptrveloc.h b/include/ptrveloc.h > index 3cc3d97..6411a2c 100644 > --- a/include/ptrveloc.h > +++ b/include/ptrveloc.h > @@ -1,6 +1,6 @@ > /* > * > - * Copyright ?? 2006-2009 Simon Thum simon dot thum at gmx dot de > + * Copyright ?? 2006-2011 Simon Thum simon dot thum at gmx dot de > * > * Permission is hereby granted, free of charge, to any person obtaining a > * copy of this software and associated documentation files (the "Software"), > @@ -25,7 +25,7 @@ > #ifndef POINTERVELOCITY_H > #define POINTERVELOCITY_H > > -#include <input.h> /* DeviceIntPtr */ > +#include <input.h> > > /* constants for acceleration profiles */ > > @@ -90,9 +90,6 @@ typedef struct _DeviceVelocityRec { > } statistics; > } DeviceVelocityRec, *DeviceVelocityPtr; > > -/* number of properties for predictable acceleration */ > -#define NPROPS_PREDICTABLE_ACCEL 4 > - > /** > * contains the run-time data for the predictable scheme, that is, a > * DeviceVelocityPtr and the property handlers. > @@ -136,11 +133,11 @@ InitPredictableAccelerationScheme(DeviceIntPtr dev, > struct _ValuatorAccelerationRec* protoScheme); > > extern _X_INTERNAL void > -acceleratePointerPredictable(DeviceIntPtr dev, int first_valuator, > - int num_valuators, int *valuators, int evtime); > +acceleratePointerPredictable(DeviceIntPtr dev, ValuatorMask* val, > + CARD32 evtime); > > extern _X_INTERNAL void > -acceleratePointerLightweight(DeviceIntPtr dev, int first_valuator, > - int num_valuators, int *valuators, int ignored); > +acceleratePointerLightweight(DeviceIntPtr dev, ValuatorMask* val, > + CARD32 evtime); > > #endif /* POINTERVELOCITY_H */ > -- > 1.7.3.4 Reviewed-by: Peter Hutterer <[email protected]> for this one except for the comment typo and the indentation issues. Cheers, Peter _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
