Hi,

I created another acceleration profile, inspired by the bits removed
from the wacom driver.

I think it's worth adding to the server because it has some qualities no
other profile has.

Cheers,

Simon

>From fcc93189b031ee78c6292d18c57e71a5c7e423f4 Mon Sep 17 00:00:00 2001
From: Simon Thum <simon.t...@gmx.de>
Date: Fri, 11 Dec 2009 20:55:56 +0100
Subject: [PATCH] dix: add smooth limited pointer acceleration profile

This profile is inspired by the accel code removed from the wacom driver.
It ascends from zero to acceleration, maxing out at threshold. This means you
can control the slope using threshold, which wasn't possible in wacom.
For sanity's sake, threshold should grow with acceleration.

Works best with adaptive deceleration, since otherwise it only generates
acceleration above 1, causing seldom pixel skips.

Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 dix/ptrveloc.c     |   28 +++++++++++++++++++++++++++-
 include/ptrveloc.h |    3 ++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 6fb9e21..c2f4378 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -868,6 +868,31 @@ SmoothLinearProfile(
 }
 
 
+/**
+ * From 0 to threshold, the response graduates smoothly from min_accel to
+ * acceleration. Beyond threshold it is exactly the specified acceleration.
+ */
+static float
+SmoothLimitedProfile(
+    DeviceIntPtr dev,
+    DeviceVelocityPtr vel,
+    float velocity,
+    float threshold,
+    float acc)
+{
+    float res;
+
+    if(velocity >= threshold || threshold == 0.0f)
+       return acc;
+
+    velocity /= threshold; /* should be [0..1[ now */
+
+    res = CalcPenumbralGradient(velocity) * (acc - vel->min_acceleration);
+
+    return vel->min_acceleration + res;
+}
+
+
 static float
 LinearProfile(
     DeviceIntPtr dev,
@@ -879,7 +904,6 @@ LinearProfile(
     return acc * velocity;
 }
 
-
 static float
 NoProfile(
     DeviceIntPtr dev,
@@ -911,6 +935,8 @@ GetAccelerationProfile(
             return PowerProfile;
         case AccelProfileLinear:
             return LinearProfile;
+        case AccelProfileSmoothLimited:
+            return SmoothLimitedProfile;
         case AccelProfileNone:
             return NoProfile;
         default:
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 2a4b40b..676c464 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -37,7 +37,8 @@
 #define AccelProfileSimple 4
 #define AccelProfilePower 5
 #define AccelProfileLinear 6
-#define AccelProfileLAST AccelProfileLinear
+#define AccelProfileSmoothLimited 7
+#define AccelProfileLAST AccelProfileSmoothLimited
 
 /* fwd */
 struct _DeviceVelocityRec;
-- 
1.6.4.4

_______________________________________________
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg

Reply via email to