summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2003-11-05 06:46:13 +0000
committerKeith Packard <keithp@keithp.com>2003-11-05 06:46:13 +0000
commit7e1a564c416f6dc337a0021b1c0e1f2cb3b27296 (patch)
tree335eca0768a66a60f46b22d87ccf4a7220c9486a
parent5378236aa647ec9a723a3e5fbd2a57eb286a1938 (diff)
Replace translucent compositing hacks with PictOpSrc to match eventual
extension semantics. Replace mouse acceleration with quadratic.
-rw-r--r--hw/kdrive/src/kinput.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 016e35ddc..eb65cb98a 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1347,14 +1347,30 @@ KdEnqueueKeyboardEvent(unsigned char scan_code,
* 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 @@ KdEnqueueMouseEvent(KdMouseInfo *mi, unsigned long flags, int rx, int ry)
x = rx;
y = ry;
}
- x = KdMouseAccelerate (pKdPointer, x);
- y = KdMouseAccelerate (pKdPointer, y);
+ KdMouseAccelerate (pKdPointer, &x, &y);
xE.u.keyButtonPointer.pad1 = 1;
}
else