[PATCH 2/9] input: add valuator_get_mode() helper.

Peter Hutterer peter.hutterer at who-t.net
Thu Oct 21 23:29:29 PDT 2010


Returns the mode of the specified valuator.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/devices.c   |   22 ++++++++++++++++++++++
 include/input.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/dix/devices.c b/dix/devices.c
index 3548be4..45edd37 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2570,3 +2570,25 @@ AllocDevicePair (ClientPtr client, char* name,
     return Success;
 }
 
+/**
+ * Return Relative or Absolute for the device.
+ */
+int valuator_get_mode(DeviceIntPtr dev, int axis)
+{
+    return (dev->valuator->axes[axis].mode & DeviceMode);
+}
+
+/**
+ * Set the given mode for the axis. If axis is VALUATOR_MODE_ALL_AXES, then
+ * set the mode for all axes.
+ */
+void valuator_set_mode(DeviceIntPtr dev, int axis, int mode)
+{
+    if (axis != VALUATOR_MODE_ALL_AXES)
+        dev->valuator->axes[axis].mode = mode;
+    else {
+        int i;
+        for (i = 0; i < dev->valuator->numAxes; i++)
+            dev->valuator->axes[axis].mode = mode;
+    }
+}
diff --git a/include/input.h b/include/input.h
index 76df4ff..8feac28 100644
--- a/include/input.h
+++ b/include/input.h
@@ -546,6 +546,10 @@ extern _X_EXPORT void DDXRingBell(
     int pitch,
     int duration);
 
+#define VALUATOR_MODE_ALL_AXES -1
+extern _X_HIDDEN int valuator_get_mode(DeviceIntPtr dev, int axis);
+extern _X_HIDDEN void valuator_set_mode(DeviceIntPtr dev, int axis, int mode);
+
 /* Set to TRUE by default - os/utils.c sets it to FALSE on user request,
    xfixes/cursor.c uses it to determine if the cursor is enabled */
 extern Bool EnableCursor;
-- 
1.7.2.3



More information about the xorg-devel mailing list