[PATCH] acecad: Cope with ABI_XINPUT_VERSION 7 - requires button/axes labels.

Peter Hutterer peter.hutterer at who-t.net
Sun Jun 21 20:43:17 PDT 2009


We don't have an atom for relative pressure, so if the device is set to
relative, we export the axis as REL_Z instead.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
compile-tested only.

 src/acecad.c |   46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/acecad.c b/src/acecad.c
index 63c5aaf..24676f5 100644
--- a/src/acecad.c
+++ b/src/acecad.c
@@ -78,6 +78,11 @@
 #endif
 #endif
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+#include <X11/Xatom.h>
+#include <xserver-properties.h>
+#endif
+
 /* Previously found in xf86Xinput.h */
 #ifdef DBG
 #undef DBG
@@ -627,13 +632,36 @@ DeviceInit (DeviceIntPtr dev)
     int rx, ry;
     LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate;
     AceCadPrivatePtr priv = (AceCadPrivatePtr) (local->private);
-    unsigned char map[] =
-    {0, 1, 2, 3};
+    unsigned char map[] = {0, 1, 2, 3};
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+    Atom btn_labels[3];
+    Atom axes_labels[3];
+
+    btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+    btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+    btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+
+    if ((priv->flags & ABSOLUTE_FLAG))
+    {
+        axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
+        axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
+        axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE);
+    } else
+    {
+        axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+        axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+        axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Z);
+    }
+#endif
 
     xf86MsgVerb(X_INFO, 4, "%s Init\n", local->name);
 
     /* 3 boutons */
-    if (InitButtonClassDeviceStruct (dev, 3, map) == FALSE)
+    if (InitButtonClassDeviceStruct (dev, 3,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+                btn_labels,
+#endif
+                map) == FALSE)
     {
         xf86Msg(X_ERROR, "%s: unable to allocate ButtonClassDeviceStruct\n", local->name);
         return !Success;
@@ -653,6 +681,9 @@ DeviceInit (DeviceIntPtr dev)
 
     /* 3 axes */
     if (InitValuatorClassDeviceStruct (dev, 3,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+                axes_labels,
+#endif
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3
                 xf86GetMotionEvents,
 #endif
@@ -668,6 +699,9 @@ DeviceInit (DeviceIntPtr dev)
 
         InitValuatorAxisStruct(dev,
                 0,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+                axes_labels[0],
+#endif
                 0,			/* min val */
 #if XORG_BOTCHED_INPUT
                 screenInfo.screens[0]->width,
@@ -679,6 +713,9 @@ DeviceInit (DeviceIntPtr dev)
                 1000);			/* max_res */
         InitValuatorAxisStruct(dev,
                 1,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+                axes_labels[1],
+#endif
                 0,			/* min val */
 #if XORG_BOTCHED_INPUT
                 screenInfo.screens[0]->height,
@@ -690,6 +727,9 @@ DeviceInit (DeviceIntPtr dev)
                 1000);			/* max_res */
         InitValuatorAxisStruct(dev,
                 2,
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
+                axes_labels[2],
+#endif
                 0,			/* min val */
                 priv->acecadMaxZ,	/* max val */
                 1000,			/* resolution */
-- 
1.6.3.rc1.2.g0164.dirty


More information about the xorg-devel mailing list