[PATCH] Update synaptics to XInput 7 ABI

Peter Hutterer peter.hutterer at who-t.net
Thu Jun 18 16:49:27 PDT 2009


Thanks for the patch. A few comments though:

On Thu, Jun 18, 2009 at 01:56:49AM -0400, Ben Gamari wrote:
> diff --git a/src/synaptics.c b/src/synaptics.c
> index ff66517..f917d8b 100644
> --- a/src/synaptics.c
> +++ b/src/synaptics.c
> @@ -69,6 +69,11 @@
>  #include <xf86Xinput.h>
>  #include <exevents.h>
>  
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 3
> +#include <X11/Xatom.h>
> +#include <xserver-properties.h>
> +#endif
> +

this should strictly be >= 7, since we don't need these parts in earlier
versions.

>  #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
>  #include "mipointer.h"
>  #endif
> @@ -795,6 +800,20 @@ DeviceInit(DeviceIntPtr dev)
>      SynapticsPrivate *priv = (SynapticsPrivate *) (local->private);
>      unsigned char map[SYN_MAX_BUTTONS + 1];
>      int i;
> +    Atom axis_labels[] = {
> +	    XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X),
> +	    XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y),
> +    };
> +    Atom btn_labels[] = {
> +	    XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT),
> +	    XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE),
> +	    XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT),
> +	    XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP),
> +	    XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN),
> +	    XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_LEFT),
> +	    XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_RIGHT),
> +	    // FIXME: I don't know what the other buttons might be
> +    };

no // comments please.
also, this part is incorrect. SYN_MAX_BUTTONS is 12, so when you pass this
array into InitPointerDeviceStruct, it'll run over the bounds and produce
bogus data.
fwiw, label of 0 ("None") is permitted.

> @@ -805,6 +824,9 @@ DeviceInit(DeviceIntPtr dev)
>  
>      InitPointerDeviceStruct((DevicePtr)dev, map,
>  			    SYN_MAX_BUTTONS,
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> +			    btn_labels,
> +#endif
>  #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
>  			    miPointerGetMotionEvents,
>  #elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3
> @@ -813,21 +835,40 @@ DeviceInit(DeviceIntPtr dev)
>  			    SynapticsCtrl,
>  #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
>  			    miPointerGetMotionBufferSize()
> -#else
> +#elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 7
>  			    GetMotionHistorySize(), 2
> +#else
> +			    GetMotionHistorySize(), 2, axis_labels
>  #endif
>  			    );
>      /* X valuator */
>      if (priv->minx < priv->maxx)
> -	xf86InitValuatorAxisStruct(dev, 0, priv->minx, priv->maxx, 1, 0, 1);
> +	xf86InitValuatorAxisStruct(dev, 0, 
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> +                                   axis_labels[0],
> +#endif
> +				   priv->minx, priv->maxx, 1, 0, 1);
>      else
> -	xf86InitValuatorAxisStruct(dev, 0, 0, -1, 1, 0, 1);
> +	xf86InitValuatorAxisStruct(dev, 0,
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> +                                   axis_labels[0],
> +#endif
> +				   0, -1, 1, 0, 1);
>      xf86InitValuatorDefaults(dev, 0);
> +    
>      /* Y valuator */
>      if (priv->miny < priv->maxy)
> -	xf86InitValuatorAxisStruct(dev, 1, priv->miny, priv->maxy, 1, 0, 1);
> +	xf86InitValuatorAxisStruct(dev, 1,
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> +                                   axis_labels[1],
> +#endif
> +				   priv->miny, priv->maxy, 1, 0, 1);
>      else
> -	xf86InitValuatorAxisStruct(dev, 1, 0, -1, 1, 0, 1);
> +	xf86InitValuatorAxisStruct(dev, 1,
> +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
> +                                   axis_labels[1],
> +#endif
> +				   0, -1, 1, 0, 1);
>      xf86InitValuatorDefaults(dev, 1);
>  
>  #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0

messy, hence the need for fd939a37d7df320f76fc772eb1f18eb6ba1d54b9.
How about this one (obviously on top of fd939)?

>From bb74e1a12896998a9f328f3cf53b2f31679b3ce5 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu, 18 Jun 2009 11:22:48 +1000
Subject: [PATCH] Cope with ABI_XINPUT_VERSION 7.

Version 7 requires button and axes labels.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/synaptics.c |   70 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/src/synaptics.c b/src/synaptics.c
index 6b902e9..e1e3646 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -77,6 +77,11 @@
 #include "synapticsstr.h"
 #include "synaptics-properties.h"
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+#include <X11/Xatom.h>
+#include <xserver-properties.h>
+#endif
+
 typedef enum {
     BOTTOM_EDGE = 1,
     TOP_EDGE = 2,
@@ -788,6 +793,46 @@ DeviceClose(DeviceIntPtr dev)
     return RetValue;
 }
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+static void InitAxesLabels(Atom *labels, int nlabels)
+{
+    memset(labels, 0, nlabels * sizeof(Atom));
+    switch(nlabels)
+    {
+        default:
+        case 2:
+            labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+        case 1:
+            labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+            break;
+    }
+}
+
+static void InitButtonLabels(Atom *labels, int nlabels)
+{
+    memset(labels, 0, nlabels * sizeof(Atom));
+    switch(nlabels)
+    {
+        default:
+        case 7:
+            labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+        case 6:
+            labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+        case 5:
+            labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+        case 4:
+            labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+        case 3:
+            labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+        case 2:
+            labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+        case 1:
+            labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+            break;
+    }
+}
+#endif
+
 static Bool
 DeviceInit(DeviceIntPtr dev)
 {
@@ -796,6 +841,13 @@ DeviceInit(DeviceIntPtr dev)
     unsigned char map[SYN_MAX_BUTTONS + 1];
     int i;
     int min, max;
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+    Atom btn_labels[SYN_MAX_BUTTONS] = { 0 };
+    Atom axes_labels[2] = { 0 };
+
+    InitAxesLabels(axes_labels, 2);
+    InitButtonLabels(btn_labels, SYN_MAX_BUTTONS);
+#endif
 
     DBG(3, ErrorF("Synaptics DeviceInit called\n"));
 
@@ -806,6 +858,9 @@ DeviceInit(DeviceIntPtr dev)
 
     InitPointerDeviceStruct((DevicePtr)dev, map,
 			    SYN_MAX_BUTTONS,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+                            btn_labels,
+#endif
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
 			    miPointerGetMotionEvents,
 #elif GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3
@@ -817,6 +872,9 @@ DeviceInit(DeviceIntPtr dev)
 #else
 			    GetMotionHistorySize(), 2
 #endif
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+                            , axes_labels
+#endif
 			    );
     /* X valuator */
     if (priv->minx < priv->maxx)
@@ -829,7 +887,11 @@ DeviceInit(DeviceIntPtr dev)
         max = -1;
     }
 
-    xf86InitValuatorAxisStruct(dev, 0, min, max, 1, 0, 1);
+    xf86InitValuatorAxisStruct(dev, 0,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+            axes_labels[0],
+#endif
+            min, max, 1, 0, 1);
     xf86InitValuatorDefaults(dev, 0);
 
     /* Y valuator */
@@ -843,7 +905,11 @@ DeviceInit(DeviceIntPtr dev)
         max = -1;
     }
 
-    xf86InitValuatorAxisStruct(dev, 1, min, max, 1, 0, 1);
+    xf86InitValuatorAxisStruct(dev, 1,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+            axes_labels[1],
+#endif
+            min, max, 1, 0, 1);
     xf86InitValuatorDefaults(dev, 1);
 
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
-- 
1.6.3.rc1.2.g0164.dirty




More information about the xorg mailing list