[PATCH 6/6] xfree86: init properties when ptraccel configuration is found.

Peter Hutterer peter.hutterer at who-t.net
Thu Dec 4 22:42:38 PST 2008


From: Simon Thum <simon.thum at gmx.de>

Signed-off-by: Peter Hutterer <peter.hutterer at redhat.com>
---
 hw/xfree86/common/xf86Xinput.c |   77 +++++++++++++++++++++++++++++++---------
 1 files changed, 60 insertions(+), 17 deletions(-)

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index fe62772..0461f92 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -54,6 +54,7 @@
 #include <X11/Xmd.h>
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
+#include <X11/Xatom.h>
 #include "xf86.h"
 #include "xf86Priv.h"
 #include "xf86Xinput.h"
@@ -85,6 +86,7 @@
 #include "mi.h"
 
 #include <ptrveloc.h>          /* dix pointer acceleration */
+#include <xserver-properties.h>
 
 #ifdef XFreeXDGA
 #include "dgaproc.h"
@@ -102,13 +104,69 @@ EventListPtr xf86Events = NULL;
  * Eval config and modify DeviceVelocityRec accordingly
  */
 static void
-ProcessVelocityConfiguration(char* devname, pointer list, DeviceVelocityPtr s){
+ProcessVelocityConfiguration(DeviceIntPtr pDev, char* devname, pointer list,
+                             DeviceVelocityPtr s)
+{
     int tempi, i;
     float tempf, tempf2;
+    Atom float_prop = XIGetKnownProperty(XATOM_FLOAT);
+    Atom prop;
 
     if(!s)
         return;
 
+    /* common settings (available via device properties) */
+    tempf = xf86SetIntOption(list, "ConstantDeceleration", 1);
+    if(tempf > 1.0){
+        xf86Msg(X_CONFIG, "%s: (accel) constant deceleration by %.1f\n",
+                devname, tempf);
+        prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
+        XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+                               PropModeReplace, 1, &tempf, FALSE);
+    }
+
+    tempf = xf86SetIntOption(list, "AdaptiveDeceleration", 1);
+    if(tempf > 1.0){
+        xf86Msg(X_CONFIG, "%s: (accel) adaptive deceleration by %.1f\n",
+                devname, tempf);
+        prop = XIGetKnownProperty(ACCEL_PROP_ADAPTIVE_DECELERATION);
+        XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+                               PropModeReplace, 1, &tempf, FALSE);
+    }
+
+    /* select profile by number */
+    tempi = xf86SetIntOption(list, "AccelerationProfile",
+            s->statistics.profile_number);
+
+    prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
+    if (XIChangeDeviceProperty(pDev, prop, XA_INTEGER, 32,
+                               PropModeReplace, 1, &tempi, FALSE) == Success)
+    {
+        xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i\n", devname,
+                tempi);
+    } else {
+        xf86Msg(X_CONFIG, "%s: (accel) acceleration profile %i is unknown\n",
+                devname, tempi);
+    }
+
+    /* set scaling */
+    tempf = xf86SetRealOption(list, "ExpectedRate", 0);
+    prop = XIGetKnownProperty(ACCEL_PROP_VELOCITY_SCALING);
+    if(tempf > 0){
+        if(tempf > 300){
+            xf86Msg(X_WARNING, "%s: (accel) Using ExpectedRate > 300 may not "
+                    "yield good controllability!\n", devname);
+        }
+        tempf = 1000.0 / tempf;
+        XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+                               PropModeReplace, 1, &tempf, FALSE);
+    }else{
+        tempf = xf86SetRealOption(list, "VelocityScale", s->corr_mul);
+        XIChangeDeviceProperty(pDev, prop, float_prop, 32,
+                               PropModeReplace, 1, &tempf, FALSE);
+    }
+
+    /* advanced stuff, best kept in .fdi's */
     tempf = xf86SetRealOption(list, "FilterHalflife", -1);
     if(tempf > 0)
         tempf = 1.0 / tempf;   /* set reciprocal if possible */
@@ -135,21 +193,6 @@ ProcessVelocityConfiguration(char* devname, pointer list, DeviceVelocityPtr s){
                 devname, i, 1.0f / (s->filters[i].rdecay));
     }
 
-    tempf = xf86SetRealOption(list, "ConstantDeceleration", 1.0);
-    if(tempf > 1.0){
-        xf86Msg(X_CONFIG, "%s: (accel) constant deceleration by %.1f\n",
-                devname, tempf);
-        s->const_acceleration = 1.0 / tempf;   /* set reciprocal deceleration
-                                                  alias acceleration */
-    }
-
-    tempf = xf86SetRealOption(list, "AdaptiveDeceleration", 1.0);
-    if(tempf > 1.0){
-        xf86Msg(X_CONFIG, "%s: (accel) adaptive deceleration by %.1f\n",
-                devname, tempf);
-        s->min_acceleration = 1.0 / tempf;   /* set minimum acceleration */
-    }
-
     tempf = xf86SetRealOption(list, "VelocityCoupling", -1);
     if(tempf >= 0){
 	xf86Msg(X_CONFIG, "%s: (accel) velocity coupling is %.1f%%\n", devname,
@@ -234,7 +277,7 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
         switch(scheme){
             case PtrAccelPredictable:
                 pVel = GetDevicePredictableAccelData(dev);
-                ProcessVelocityConfiguration (local->name, local->options,
+                ProcessVelocityConfiguration (dev, local->name, local->options,
                                               pVel);
                 break;
         }
-- 
1.6.0.4




More information about the xorg mailing list