[xserver-commit] xserver/hw/kdrive/src kinput.c,1.36,1.37
Keith Packard
xserver-commit@pdx.freedesktop.org
Tue, 04 Nov 2003 22:46:15 -0800
Committed by: keithp
Update of /cvs/xserver/xserver/hw/kdrive/src
In directory pdx:/tmp/cvs-serv7853/hw/kdrive/src
Modified Files:
kinput.c
Log Message:
* composite/compinit.c: (CompositeExtensionInit):
* composite/compwindow.c: (compWindowUpdateAutomatic),
(compWindowUpdate):
* hw/kdrive/src/kinput.c: (KdMouseAccelerate),
(KdEnqueueMouseEvent):
Replace translucent compositing hacks with PictOpSrc to
match eventual extension semantics.
Replace mouse acceleration with quadratic.
Index: kinput.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/src/kinput.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- kinput.c 2 Nov 2003 19:56:10 -0000 1.36
+++ kinput.c 5 Nov 2003 06:46:13 -0000 1.37
@@ -1347,14 +1347,30 @@
* passed off to MI for enqueueing.
*/
-static int
-KdMouseAccelerate (DeviceIntPtr device, int delta)
+static void
+KdMouseAccelerate (DeviceIntPtr device, int *dx, int *dy)
{
PtrCtrl *pCtrl = &device->ptrfeed->ctrl;
+ double speed = sqrt (*dx * *dx + *dy * *dy);
+ double accel;
+ double m;
- if (abs(delta) > pCtrl->threshold)
- delta = (delta * pCtrl->num) / pCtrl->den;
- return delta;
+ /*
+ * 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;
+ *dx = accel * *dx;
+ *dy = accel * *dy;
}
void
@@ -1385,8 +1401,7 @@
x = rx;
y = ry;
}
- x = KdMouseAccelerate (pKdPointer, x);
- y = KdMouseAccelerate (pKdPointer, y);
+ KdMouseAccelerate (pKdPointer, &x, &y);
xE.u.keyButtonPointer.pad1 = 1;
}
else