xserver: Branch 'master' - 8 commits

Peter Hutterer whot at kemper.freedesktop.org
Mon Jul 28 01:56:41 PDT 2008


 COPYING                        |    1 
 dix/devices.c                  |   13 ++
 dix/ptrveloc.c                 |  198 ++++++++++++++++++++++++++++++-----------
 hw/xfree86/common/xf86Xinput.c |   33 +++++-
 include/input.h                |    2 
 include/ptrveloc.h             |   54 +++++++++--
 6 files changed, 231 insertions(+), 70 deletions(-)

New commits:
commit 805f28e96ceb20bc53792ae3cf17f9c26564ae0e
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Jul 23 12:10:52 2008 +0200

    some trivial changes regarding C compat, indentation, etc.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index d6cd8c5..21a2eca 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -458,7 +458,10 @@ ApplySofteningAndConstantDeceleration(
  * Polynomial function similar previous one, but with f(1) = 1
  */
 static float
-PolynomialAccelerationProfile(DeviceVelocityPtr pVel, float ignored, float acc)
+PolynomialAccelerationProfile(
+    DeviceVelocityPtr pVel,
+    float ignored,
+    float acc)
 {
    return pow(pVel->velocity, (acc - 1.0) * 0.5);
 }
@@ -474,7 +477,6 @@ ClassicProfile(
     float threshold,
     float acc)
 {
-
     if (threshold) {
 	return SimpleSmoothProfile (pVel,
                                     threshold,
@@ -516,7 +518,8 @@ PowerProfile(
  * just a smooth function in [0..1] -> [0..1]
  *  - point symmetry at 0.5
  *  - f'(0) = f'(1) = 0
- *  - starts faster than sinoids, C1 (Cinf if you dare to ignore endpoints)
+ *  - starts faster than a sinoid
+ *  - smoothness C1 (Cinf if you dare to ignore endpoints)
  */
 static inline float
 CalcPenumbralGradient(float x){
@@ -561,13 +564,15 @@ SmoothLinearProfile(
     float threshold,
     float acc)
 {
+    float res, nv;
+
     if(acc > 1.0f)
         acc -= 1.0f; /*this is so acc = 1 is no acceleration */
     else
         return 1.0f;
 
-    float nv = (pVel->velocity - threshold) * acc * 0.5f;
-    float res;
+    nv = (pVel->velocity - threshold) * acc * 0.5f;
+
     if(nv < 0){
         res = 0;
     }else if(nv < 2){
@@ -696,8 +701,12 @@ GetDevicePredictableAccelData(
  * enable fine-grained predictable acceleration profiles.
  */
 void
-acceleratePointerPredictable(DeviceIntPtr pDev, int first_valuator,
-                             int num_valuators, int *valuators, int evtime)
+acceleratePointerPredictable(
+    DeviceIntPtr pDev,
+    int first_valuator,
+    int num_valuators,
+    int *valuators,
+    int evtime)
 {
     float mult = 0.0;
     int dx = 0, dy = 0;
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index fbd10e9..ea4dbba 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -138,7 +138,7 @@ ProcessVelocityConfiguration(char* devname, pointer list, DeviceVelocityPtr s){
         s->min_acceleration = 1.0 / tempf;   /* set minimum acceleration */
     }
 
-    tempf = xf86SetRealOption(list, "VelocityCoupling", 0.2);
+    tempf = xf86SetRealOption(list, "VelocityCoupling", 0.25);
     xf86Msg(X_CONFIG, "%s: (accel) velocity coupling is %.1f%%\n", devname,
                 tempf*100.0);
     s->coupling = tempf;
commit 3209bd21d00b8673d321f70afb65720588ddacb3
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Jul 23 12:06:34 2008 +0200

    xfree86: perform pointer accel scheme selection by name, not number
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 9a14a4c..fbd10e9 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -174,9 +174,21 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
     int scheme;
     DeviceVelocityPtr pVel;
     LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate;
+    char* schemeStr;
 
     if(dev->valuator){
-        scheme = xf86SetIntOption(local->options, "AccelerationScheme", 1);
+	schemeStr = xf86SetStrOption(local->options, "AccelerationScheme", "");
+
+	scheme = dev->valuator->accelScheme.number;
+
+	if(!xf86NameCmp(schemeStr, "predictable"))
+	    scheme = PtrAccelPredictable;
+
+	if(!xf86NameCmp(schemeStr, "lightweight"))
+	    scheme = PtrAccelLightweight;
+
+	if(!xf86NameCmp(schemeStr, "none"))
+	    scheme = PtrAccelNoOp;
 
         /* reinit scheme if needed */
         if(dev->valuator->accelScheme.number != scheme){
@@ -184,15 +196,24 @@ ApplyAccelerationSettings(DeviceIntPtr dev){
                 dev->valuator->accelScheme.AccelCleanupProc(dev);
             }
 
-            xf86Msg(X_CONFIG, "%s: (accel) init acceleration scheme %i\n", local->name, scheme);
-            InitPointerAccelerationScheme(dev, scheme);
+            if(InitPointerAccelerationScheme(dev, scheme)){
+		xf86Msg(X_CONFIG, "%s: (accel) selected scheme %s/%i\n",
+		        local->name, schemeStr, scheme);
+	    }else{
+        	xf86Msg(X_CONFIG, "%s: (accel) could not init scheme %s\n",
+        	        local->name, schemeStr);
+        	scheme = dev->valuator->accelScheme.number;
+            }
         }else{
-            xf86Msg(X_CONFIG, "%s: (accel) keeping acceleration scheme %i\n", local->name, scheme);
+            xf86Msg(X_CONFIG, "%s: (accel) keeping acceleration scheme %i\n",
+                    local->name, scheme);
         }
 
+        xfree(schemeStr);
+
         /* process special configuration */
         switch(scheme){
-            case 1:
+            case PtrAccelPredictable:
                 pVel = (DeviceVelocityPtr) dev->valuator->accelScheme.accelData;
                 ProcessVelocityConfiguration (local->name, local->options,
                                               pVel);
commit a17cb29f5acdfcdeac929d8c6be3600d44d038ef
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Jul 23 12:03:17 2008 +0200

    dix: preparation change: make runtime exchange of filter chain safe
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 32ba3e1..d6cd8c5 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -30,6 +30,7 @@
 #include <ptrveloc.h>
 #include <inputstr.h>
 #include <assert.h>
+#include <os.h>
 
 /*****************************************************************************
  * Predictable pointer ballistics
@@ -151,6 +152,8 @@ InitFilterChain(DeviceVelocityPtr s, float rdecay, float progression, int stages
 	ErrorF("(dix ptracc) invalid filter chain progression specified\n");
 	return;
     }
+    /* Block here to support runtime filter adjustment */
+    OsBlockSignals();
     for(fn = 0; fn < MAX_VELOCITY_FILTERS; fn++){
 	if(fn < stages){
 	    InitFilterStage(&s->filters[fn], rdecay, lutsize);
@@ -159,6 +162,10 @@ InitFilterChain(DeviceVelocityPtr s, float rdecay, float progression, int stages
 	}
 	rdecay /= progression;
     }
+    /* release again. Should the input loop be threaded, we also need
+     * memory release here (in princliple).
+     */
+    OsReleaseSignals();
 }
 
 
@@ -199,7 +206,6 @@ InitFilterStage(FilterStagePtr s, float rdecay, int lutsize)
     float *oldlut;
 
     s->fading_lut_size  = 0; /* prevent access */
-    /* mb(); concurrency issues may arise */
 
     if(lutsize > 0){
         newlut = xalloc (sizeof(float)* lutsize);
commit 1a9f9ac50f2b0db735789905cc29572a50c8ae4c
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Jul 23 11:49:36 2008 +0200

    dix: optimize precision in device velocity estimation
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index f8f2f26..32ba3e1 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -90,11 +90,12 @@ InitVelocityData(DeviceVelocityPtr s)
     s->corr_mul = 10.0;      /* dots per 10 milisecond should be usable */
     s->const_acceleration = 1.0;   /* no acceleration/deceleration  */
     s->reset_time = 300;
+    s->last_reset = FALSE;
     s->last_dx = 0;
     s->last_dy = 0;
     s->use_softening = 1;
     s->min_acceleration = 1.0; /* don't decelerate */
-    s->coupling = 0.2;
+    s->coupling = 0.25;
     s->profile_private = NULL;
     memset(&s->statistics, 0, sizeof(s->statistics));
     memset(&s->filters, 0, sizeof(s->filters));
@@ -135,6 +136,12 @@ AccelerationDefaultCleanup(DeviceIntPtr pDev){
 /**
 Initialize a filter chain.
 Expected result is a series of filters, each progressively more integrating.
+
+This allows for two strategies: Either you have one filter which is reasonable
+and is being coupled to account for fast-changing input, or you have 'one for
+every situation'. You might want to have loose coupling then, i.e. > 1.
+E.g. you could start around 1/2 of your anticipated delta t and
+scale up until several motion deltas are 'averaged'.
 */
 void
 InitFilterChain(DeviceVelocityPtr s, float rdecay, float progression, int stages, int lutsize)
@@ -164,9 +171,21 @@ CleanupFilterChain(DeviceVelocityPtr s)
 	InitFilterStage(&s->filters[fn], 0, 0);
 }
 
+static inline void
+StuffFilterChain(DeviceVelocityPtr s, float value)
+{
+    int fn;
+
+    for(fn = 0; fn < MAX_VELOCITY_FILTERS; fn++){
+	if(s->filters[fn].rdecay != 0)
+	    s->filters[fn].current = value;
+	else break;
+    }
+}
+
 
 /**
- * Adjust weighting decay and lut in sync
+ * Adjust weighting decay and lut for a stage
  * The weight fn is designed so its integral 0->inf is unity, so we end
  * up with a stable (basically IIR) filter. It always draws
  * towards its more current input values, which have more weight the older
@@ -227,13 +246,12 @@ FeedFilterStage(FilterStagePtr s, float value, int tdiff){
 
 /**
  * Select the most filtered matching result. Also, the first
- * mismatching filter will be set to value (coupling).
+ * mismatching filter may be set to value (coupling).
  */
 static inline float
 QueryFilterChain(
     DeviceVelocityPtr s,
-    float value,
-    float maxdiv)
+    float value)
 {
     int fn, rfn = 0, cfn = -1;
     float cur, result = value;
@@ -246,20 +264,21 @@ QueryFilterChain(
 	cur = s->filters[fn].current;
 
 	if (fabs(value - cur) <= 1.0f ||
-	    fabs(value - cur) / (value + cur) <= maxdiv){
+	    fabs(value - cur) / (value + cur) <= s->coupling){
 	    result = cur;
-	    rfn = fn; /*remember result determining filter */
+	    rfn = fn + 1; /*remember result determining filter */
 	} else if(cfn == -1){
 	    cfn = fn; /* rememeber first mismatching filter */
 	}
     }
 
     s->statistics.filter_usecount[rfn]++;
-#ifdef SERIOUS_DEBUGGING
-    ErrorF("(dix ptraccel) result from filter stage %i,  input %.2f, output %.2f\n", rfn, value, result);
+#ifdef PTRACCEL_DEBUGGING
+    ErrorF("(dix ptraccel) result from stage %i,  input %.2f, output %.2f\n",
+           rfn, value, result);
 #endif
 
-    /* override one current (coupling) so the filter
+    /* override first mismatching current (coupling) so the filter
      * catches up quickly. */
     if(cfn != -1)
         s->filters[cfn].current = result;
@@ -296,7 +315,11 @@ GetAxis(int dx, int dy){
  * return true if non-visible state reset is suggested
  */
 static short
-ProcessVelocityData(DeviceVelocityPtr s, int dx, int dy, int time)
+ProcessVelocityData(
+    DeviceVelocityPtr s,
+    int dx,
+    int dy,
+    int time)
 {
     float cvelocity;
 
@@ -312,7 +335,7 @@ ProcessVelocityData(DeviceVelocityPtr s, int dx, int dy, int time)
         dy += s->last_dy;
         diff += s->last_diff;
         s->last_diff = time - s->lrm_time; /* prevent repeating add-up */
-#ifdef SERIOUS_DEBUGGING
+#ifdef PTRACCEL_DEBUGGING
         ErrorF("(dix ptracc) axial correction\n");
 #endif
     }else{
@@ -320,9 +343,9 @@ ProcessVelocityData(DeviceVelocityPtr s, int dx, int dy, int time)
     }
 
     /*
-     * cvelocity is not a real velocity yet, more a motion delta. contant
+     * cvelocity is not a real velocity yet, more a motion delta. constant
      * acceleration is multiplied here to make the velocity an on-screen
-     * velocity (px/t as opposed to [insert unit]/t). This is intended to
+     * velocity (pix/t as opposed to [insert unit]/t). This is intended to
      * make multiple devices with widely varying ConstantDecelerations respond
      * similar to acceleration controls.
      */
@@ -330,10 +353,10 @@ ProcessVelocityData(DeviceVelocityPtr s, int dx, int dy, int time)
 
     s->lrm_time = time;
 
-    if (s->reset_time < 0 || diff < 0) {     /* disabled or timer overrun? */
+    if (s->reset_time < 0 || diff < 0) { /* reset disabled or timer overrun? */
         /* simply set velocity from current movement, no reset. */
         s->velocity = cvelocity;
-        return 0;
+        return FALSE;
     }
 
     if (diff == 0)
@@ -345,23 +368,38 @@ ProcessVelocityData(DeviceVelocityPtr s, int dx, int dy, int time)
 
     /* short-circuit: when nv-reset the rest can be skipped */
     if(reset == TRUE){
-        s->velocity = cvelocity;
-        return TRUE;
+	StuffFilterChain(s, cvelocity);
+	s->velocity = cvelocity;
+	s->last_reset = TRUE;
+	return TRUE;
+    }
+
+    if(s->last_reset == TRUE){
+	/*
+	 * when here, we're probably processing the second mickey of a starting
+	 * stroke. This happens to be the first time we can reasonably pretend
+	 * that cvelocity is an actual velocity. Thus, to opt precision, we
+	 * stuff that into the filter chain.
+	 */
+	s->last_reset = FALSE;
+	StuffFilterChain(s, cvelocity);
+	s->velocity = cvelocity;
+	return FALSE;
     }
 
     /* feed into filter chain */
     FeedFilterChain(s, cvelocity, diff);
 
     /* perform coupling and decide final value */
-    s->velocity = QueryFilterChain(s, cvelocity, s->coupling);
+    s->velocity = QueryFilterChain(s, cvelocity);
 
-#ifdef SERIOUS_DEBUGGING
+#ifdef PTRACCEL_DEBUGGING
     ErrorF("(dix ptracc) guess: vel=%.3f diff=%d   |%i|%i|%i|%i|\n",
            s->velocity, diff,
            s->statistics.filter_usecount[0], s->statistics.filter_usecount[1],
            s->statistics.filter_usecount[2], s->statistics.filter_usecount[3]);
 #endif
-    return reset;
+    return FALSE;
 }
 
 
@@ -689,15 +727,15 @@ acceleratePointerPredictable(DeviceIntPtr pDev, int first_valuator,
             /* invoke acceleration profile to determine acceleration */
             mult = velocitydata->Profile(velocitydata,
                                 pDev->ptrfeed->ctrl.threshold,
-                                (float)(pDev->ptrfeed->ctrl.num) /
-                                (float)(pDev->ptrfeed->ctrl.den));
+                                (float)pDev->ptrfeed->ctrl.num /
+                                (float)pDev->ptrfeed->ctrl.den);
 
-#ifdef SERIOUS_DEBUGGING
+#ifdef PTRACCEL_DEBUGGING
             ErrorF("(dix ptracc) resulting speed multiplier : %.3f\n", mult);
 #endif
             /* enforce min_acceleration */
             if (mult < velocitydata->min_acceleration) {
-#ifdef SERIOUS_DEBUGGING
+#ifdef PTRACCEL_DEBUGGING
                 ErrorF("(dix ptracc) enforced min multiplier : %.3f\n",
                         velocitydata->min_acceleration);
 #endif
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 8e56e4d..2d42dda 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -27,6 +27,9 @@
 
 #include <input.h> /* DeviceIntPtr */
 
+/* maximum number of filters to approximate velocity.
+ * ABI-breaker!
+ */
 #define MAX_VELOCITY_FILTERS 8
 
 /* constants for acceleration profiles;
@@ -53,7 +56,7 @@ typedef float (*PointerAccelerationProfileFunc)
                float /*threshold*/, float /*acc*/);
 
 /**
- * a filter stage contains the data for the adaptive IIR filtering.
+ * a filter stage contains the data for adaptive IIR filtering.
  * To improve results, one may run several parallel filters
  * which have different decays. Since more integration means more
  * delay, a given filter only does good matches in a specific phase of
@@ -77,7 +80,8 @@ typedef struct _DeviceVelocityRec {
     float   velocity;       /* velocity as guessed by algorithm */
     int     lrm_time;       /* time the last motion event was processed  */
     int     last_dx, last_dy; /* last motion delta */
-    int     last_diff;      /* last time-diff */
+    int     last_diff;      /* last time-difference */
+    Bool    last_reset;     /* whether a nv-reset occurred just before */
     float   corr_mul;       /* config: multiply this into velocity */
     float   const_acceleration;  /* config: (recipr.) const deceleration */
     float   min_acceleration;    /* config: minimum acceleration */
@@ -89,7 +93,7 @@ typedef struct _DeviceVelocityRec {
     void*   profile_private;/* extended data, see  SetAccelerationProfile() */
     struct {   /* to be able to query this information */
         int     profile_number;
-        int     filter_usecount[MAX_VELOCITY_FILTERS];
+        int     filter_usecount[MAX_VELOCITY_FILTERS +1];
     } statistics;
 } DeviceVelocityRec, *DeviceVelocityPtr;
 
commit c184b91d9aa72031c2bac9f379f56633957ded30
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Jul 23 11:33:25 2008 +0200

    dix: improve the driver interface to predictable pointer acceleration
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 8a0959b..f8f2f26 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -616,22 +616,32 @@ SetAccelerationProfile(
  */
 extern void
 SetDeviceSpecificAccelerationProfile(
-	DeviceIntPtr pDev,
+        DeviceVelocityPtr s,
         PointerAccelerationProfileFunc profile)
 {
+    if(s)
+	s->deviceSpecificProfile = profile;
+}
+
+/**
+ * Use this function to obtain a DeviceVelocityPtr for a device. Will return NULL if
+ * the predictable acceleration scheme is not in effect.
+ */
+DeviceVelocityPtr
+GetDevicePredictableAccelData(
+	DeviceIntPtr pDev)
+{
     /*sanity check*/
     if( pDev->valuator &&
 	pDev->valuator->accelScheme.AccelSchemeProc ==
 	    acceleratePointerPredictable &&
 	pDev->valuator->accelScheme.accelData != NULL){
-	((DeviceVelocityPtr)
-	(pDev->valuator->accelScheme.accelData))->deviceSpecificProfile
-		= profile;
+
+	return (DeviceVelocityPtr)pDev->valuator->accelScheme.accelData;
     }
+    return NULL;
 }
 
-
-
 /********************************
  *  acceleration schemes
  *******************************/
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 1b92a07..8e56e4d 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -104,8 +104,11 @@ InitFilterChain(DeviceVelocityPtr s, float rdecay, float degression,
 extern int
 SetAccelerationProfile(DeviceVelocityPtr s, int profile_num);
 
+extern DeviceVelocityPtr
+GetDevicePredictableAccelData(DeviceIntPtr pDev);
+
 extern void
-SetDeviceSpecificAccelerationProfile(DeviceIntPtr s,
+SetDeviceSpecificAccelerationProfile(DeviceVelocityPtr s,
                                      PointerAccelerationProfileFunc profile);
 
 extern void
commit 87aa5298576ed335ac31347e14fb30430288157a
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Jul 23 11:28:09 2008 +0200

    dix: introduce defines for accel profile numbers
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 92e737d..8a0959b 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -98,7 +98,7 @@ InitVelocityData(DeviceVelocityPtr s)
     s->profile_private = NULL;
     memset(&s->statistics, 0, sizeof(s->statistics));
     memset(&s->filters, 0, sizeof(s->filters));
-    SetAccelerationProfile(s, 0);
+    SetAccelerationProfile(s, AccelProfileClassic);
     InitFilterChain(s, (float)1.0/20.0, 1, 1, 40);
 }
 
@@ -551,10 +551,10 @@ LinearProfile(
 /**
  * Set the profile by number.
  * Intended to make profiles exchangeable at runtime.
- * If you created a profile, give it a number here to make it selectable.
- * In case some profile-specific init is needed, here would be a good place,
- * since FreeVelocityData() also calls this with -1.
- * returns FALSE (0) if profile number is unknown.
+ * If you created a profile, give it a number here and in the header to
+ * make it selectable. In case some profile-specific init is needed, here
+ * would be a good place, since FreeVelocityData() also calls this with -1.
+ * returns FALSE (0) if profile number is unavailable.
  */
 int
 SetAccelerationProfile(
@@ -566,29 +566,31 @@ SetAccelerationProfile(
         case -1:
             profile = NULL;  /* Special case to uninit properly */
             break;
-        case 0:
+        case AccelProfileClassic:
             profile = ClassicProfile;
             break;
-        case 1:
+        case AccelProfileDeviceSpecific:
             if(NULL == s->deviceSpecificProfile)
         	return FALSE;
             profile = s->deviceSpecificProfile;
             break;
-        case 2:
+        case AccelProfilePolynomial:
             profile = PolynomialAccelerationProfile;
             break;
-        case 3:
+        case AccelProfileSmoothLinear:
             profile = SmoothLinearProfile;
             break;
-        case 4:
+        case AccelProfileSimple:
             profile = SimpleSmoothProfile;
             break;
-        case 5:
+        case AccelProfilePower:
             profile = PowerProfile;
             break;
-        case 6:
+        case AccelProfileLinear:
             profile = LinearProfile;
             break;
+        case AccelProfileReserved:
+            /* reserved for future use, e.g. a user-defined profile */
         default:
             return FALSE;
     }
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index 30a22bc..1b92a07 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -29,6 +29,19 @@
 
 #define MAX_VELOCITY_FILTERS 8
 
+/* constants for acceleration profiles;
+ * see  */
+
+#define AccelProfileClassic  0
+#define AccelProfileDeviceSpecific 1
+#define AccelProfilePolynomial 2
+#define AccelProfileSmoothLinear 3
+#define AccelProfileSimple 4
+#define AccelProfilePower 5
+#define AccelProfileLinear 6
+#define AccelProfileReserved 7
+
+/* fwd */
 struct _DeviceVelocityRec;
 
 /**
commit 4e32e6fb38d19c9993de86188e4f7e7916a028e2
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Jul 23 11:10:22 2008 +0200

    dix: rename classic accel _scheme_ to lightweight to avoid confusion with
    classic accel _profile_
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/devices.c b/dix/devices.c
index 383c1c7..d8e37d7 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1269,10 +1269,14 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes,
 ValuatorAccelerationRec pointerAccelerationScheme[] = {
     {PtrAccelNoOp,        NULL, NULL, NULL},
     {PtrAccelPredictable, acceleratePointerPredictable, NULL, AccelerationDefaultCleanup},
-    {PtrAccelClassic,     acceleratePointerClassic, NULL, NULL},
+    {PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL},
     {-1, NULL, NULL, NULL} /* terminator */
 };
 
+/**
+ * install an acceleration scheme. retrns TRUE on success, and should not
+ * change anything if unsuccessful.
+ */
 _X_EXPORT Bool
 InitPointerAccelerationScheme(DeviceIntPtr dev,
                               int scheme)
@@ -1281,7 +1285,9 @@ InitPointerAccelerationScheme(DeviceIntPtr dev,
     void* data = NULL;
     ValuatorClassPtr val;
 
-    if(dev->isMaster) /* bail out if called for master devs */
+    val = dev->valuator;
+
+    if(!val || dev->isMaster) /* bail out if called for master devs */
 	return FALSE;
 
     for(x = 0; pointerAccelerationScheme[x].number >= 0; x++) {
@@ -1301,6 +1307,8 @@ InitPointerAccelerationScheme(DeviceIntPtr dev,
         {
             DeviceVelocityPtr s;
             s = (DeviceVelocityPtr)xalloc(sizeof(DeviceVelocityRec));
+            if(!s)
+        	return FALSE;
             InitVelocityData(s);
             data = s;
             break;
@@ -1309,7 +1317,6 @@ InitPointerAccelerationScheme(DeviceIntPtr dev,
             break;
     }
 
-    val = dev->valuator;
     val->accelScheme = pointerAccelerationScheme[i];
     val->accelScheme.accelData = data;
 
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index ce0af22..92e737d 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -722,8 +722,12 @@ acceleratePointerPredictable(DeviceIntPtr pDev, int first_valuator,
  * in-place. Retained mostly for embedded scenarios.
  */
 void
-acceleratePointerClassic(DeviceIntPtr pDev, int first_valuator,
-                         int num_valuators, int *valuators, int ignored)
+acceleratePointerLightweight(
+    DeviceIntPtr pDev,
+    int first_valuator,
+    int num_valuators,
+    int *valuators,
+    int ignored)
 {
     float mult = 0.0;
     int dx = 0, dy = 0;
diff --git a/include/input.h b/include/input.h
index ba44928..2e40272 100644
--- a/include/input.h
+++ b/include/input.h
@@ -66,7 +66,7 @@ SOFTWARE.
 /*int constants for pointer acceleration schemes*/
 #define PtrAccelNoOp            0
 #define PtrAccelPredictable     1
-#define PtrAccelClassic         2
+#define PtrAccelLightweight     2
 #define PtrAccelDefault         PtrAccelPredictable
 
 #define MAX_VALUATORS 36 /* XXX from comment in dix/getevents.c */
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index e496913..30a22bc 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -103,7 +103,7 @@ acceleratePointerPredictable(DeviceIntPtr pDev, int first_valuator,
                              int num_valuators, int *valuators, int evtime);
 
 extern void
-acceleratePointerClassic(DeviceIntPtr pDev, int first_valuator,
+acceleratePointerLightweight(DeviceIntPtr pDev, int first_valuator,
                          int num_valuators, int *valuators, int ignore);
 
 #endif  /* POINTERVELOCITY_H */
commit d40183c665d458ac0a6e7952fbe986776a17fda7
Author: Simon Thum <simon.thum at gmx.de>
Date:   Wed Jul 23 09:28:06 2008 +0200

    dix: add legal statements to ptrvelo.{c|h}
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/COPYING b/COPYING
index ddfb201..6faa4b1 100644
--- a/COPYING
+++ b/COPYING
@@ -12,6 +12,7 @@ Copyright © 2006 Nokia Corporation
 Copyright © 2006-2008 Peter Hutterer
 Copyright © 1999 Keith Packard
 Copyright © 2005-2007 Daniel Stone
+Copyright © 2006-2008 Simon Thum
 Copyright © 2006 Luc Verhaegen
 
 Permission is hereby granted, free of charge, to any person obtaining a
diff --git a/dix/ptrveloc.c b/dix/ptrveloc.c
index 31747a2..ce0af22 100644
--- a/dix/ptrveloc.c
+++ b/dix/ptrveloc.c
@@ -1,3 +1,26 @@
+/*
+ *
+ * Copyright © 2006-2008 Simon Thum             simon dot thum at gmx dot de
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
 
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
diff --git a/include/ptrveloc.h b/include/ptrveloc.h
index dd5ee50..e496913 100644
--- a/include/ptrveloc.h
+++ b/include/ptrveloc.h
@@ -1,6 +1,26 @@
 /*
-*  2006-2008 by Simon Thum
-*/
+ *
+ * Copyright © 2006-2008 Simon Thum             simon dot thum at gmx dot de
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
 
 #ifndef POINTERVELOCITY_H
 #define POINTERVELOCITY_H


More information about the xorg-commit mailing list