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:
parent
ccb53340b6
commit
baf93b3abe
|
@ -117,6 +117,7 @@ KdPointerInfo *
|
|||
KdNewPointer (void)
|
||||
{
|
||||
KdPointerInfo *pi;
|
||||
int i;
|
||||
|
||||
pi = (KdPointerInfo *)xcalloc(1, sizeof(KdPointerInfo));
|
||||
if (!pi)
|
||||
|
@ -130,6 +131,9 @@ KdNewPointer (void)
|
|||
pi->next = NULL;
|
||||
pi->options = NULL;
|
||||
pi->nAxes = 3;
|
||||
pi->nButtons = KD_MAX_BUTTON;
|
||||
for (i = 1; i < KD_MAX_BUTTON; i++)
|
||||
pi->map[i] = i;
|
||||
|
||||
return pi;
|
||||
}
|
||||
|
|
|
@ -433,9 +433,6 @@ KdPointerProc(DeviceIntPtr pDevice, int onoff)
|
|||
return BadImplementation;
|
||||
}
|
||||
|
||||
for (i = 1; i <= pi->nButtons; i++)
|
||||
pi->map[i] = i;
|
||||
|
||||
if ((*pi->driver->Init) (pi) != Success) {
|
||||
return !Success;
|
||||
}
|
||||
|
@ -1156,9 +1153,6 @@ KdParsePointer (char *arg)
|
|||
pi->nButtons = 3;
|
||||
pi->inputClass = KD_MOUSE;
|
||||
|
||||
for (i = 0; i < KD_MAX_BUTTON; i++)
|
||||
pi->map[i] = i + 1;
|
||||
|
||||
if (!arg)
|
||||
{
|
||||
ErrorF("mouse: no arg\n");
|
||||
|
@ -1967,39 +1961,6 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
|
|||
* 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 */
|
||||
void
|
||||
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;
|
||||
y = ry;
|
||||
}
|
||||
/* screw this, use the DIX's acceleration (stolen from XFree86)
|
||||
* instead.
|
||||
* KdMouseAccelerate (pi, &x, &y); */
|
||||
}
|
||||
else {
|
||||
if (pi->transformCoordinates) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user