kdrive: move map initialisation to KdNewPointer

Do a linear n -> n initialisation on the map up until KD_MAX_BUTTON in
KdNewPointer, moving it out of both KdParsePointer, and KdPointerProc.
Also remove dead pointer acceleration code.
This commit is contained in:
Daniel Stone 2006-08-07 21:12:45 +03:00 committed by Daniel Stone
parent ccb53340b6
commit baf93b3abe
2 changed files with 4 additions and 42 deletions

View File

@ -117,6 +117,7 @@ KdPointerInfo *
KdNewPointer (void) KdNewPointer (void)
{ {
KdPointerInfo *pi; KdPointerInfo *pi;
int i;
pi = (KdPointerInfo *)xcalloc(1, sizeof(KdPointerInfo)); pi = (KdPointerInfo *)xcalloc(1, sizeof(KdPointerInfo));
if (!pi) if (!pi)
@ -130,6 +131,9 @@ KdNewPointer (void)
pi->next = NULL; pi->next = NULL;
pi->options = NULL; pi->options = NULL;
pi->nAxes = 3; pi->nAxes = 3;
pi->nButtons = KD_MAX_BUTTON;
for (i = 1; i < KD_MAX_BUTTON; i++)
pi->map[i] = i;
return pi; return pi;
} }

View File

@ -433,9 +433,6 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
return BadImplementation; return BadImplementation;
} }
for (i = 1; i <= pi->nButtons; i++)
pi->map[i] = i;
if ((*pi->driver->Init) (pi) != Success) { if ((*pi->driver->Init) (pi) != Success) {
return !Success; return !Success;
} }
@ -1156,9 +1153,6 @@ KdParsePointer (char *arg)
pi->nButtons = 3; pi->nButtons = 3;
pi->inputClass = KD_MOUSE; pi->inputClass = KD_MOUSE;
for (i = 0; i < KD_MAX_BUTTON; i++)
pi->map[i] = i + 1;
if (!arg) if (!arg)
{ {
ErrorF("mouse: no arg\n"); ErrorF("mouse: no arg\n");
@ -1967,39 +1961,6 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
* passed off to MI for enqueueing. * passed off to MI for enqueueing.
*/ */
static void
KdMouseAccelerate (KdPointerInfo *pi, int *dx, int *dy)
{
DeviceIntPtr device = pi->dixdev;
PtrCtrl *pCtrl = &device->ptrfeed->ctrl;
double speed = sqrt (*dx * *dx + *dy * *dy);
double accel;
#ifdef QUADRATIC_ACCELERATION
double m;
/*
* Ok, so we want it moving num/den times faster at threshold*2
*
* accel = m *threshold + b
* 1 = m * 0 + b -> b = 1
*
* num/den = m * (threshold * 2) + 1
*
* num / den - 1 = m * threshold * 2
* (num / den - 1) / threshold * 2 = m
*/
m = (((double) pCtrl->num / (double) pCtrl->den - 1.0) /
((double) pCtrl->threshold * 2.0));
accel = m * speed + 1;
#else
accel = 1.0;
if (speed > pCtrl->threshold)
accel = (double) pCtrl->num / pCtrl->den;
#endif
*dx = accel * *dx;
*dy = accel * *dy;
}
/* FIXME do something a little more clever to deal with multiple axes here */ /* FIXME do something a little more clever to deal with multiple axes here */
void void
KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry, KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
@ -2028,9 +1989,6 @@ KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
x = rx; x = rx;
y = ry; y = ry;
} }
/* screw this, use the DIX's acceleration (stolen from XFree86)
* instead.
* KdMouseAccelerate (pi, &x, &y); */
} }
else { else {
if (pi->transformCoordinates) { if (pi->transformCoordinates) {