[PATCH evdev 1/3] Split initializing one axis label out into a helper function

Peter Hutterer peter.hutterer at who-t.net
Wed Mar 28 17:09:50 PDT 2012


We need this for mixed axis devices. No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 8cf630c..dcb1aee 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -121,6 +121,8 @@ static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int cal
 static int EvdevOpenDevice(InputInfoPtr pInfo);
 
 static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms);
+static void EvdevInitOneAxisLabel(EvdevPtr pEvdev, int axis,
+                                  char **labels, int label_idx, Atom *atoms);
 static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
 static void EvdevInitProperty(DeviceIntPtr dev);
 static int EvdevSetProperty(DeviceIntPtr dev, Atom atom,
@@ -2701,9 +2703,23 @@ static char* btn_labels[][16] = {
     }
 };
 
-static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms)
+static void EvdevInitOneAxisLabel(EvdevPtr pEvdev, int axis,
+                                  char **labels, int label_idx, Atom *atoms)
 {
     Atom atom;
+
+    if (pEvdev->axis_map[axis] == -1)
+        return;
+
+    atom = XIGetKnownProperty(labels[label_idx]);
+    if (!atom) /* Should not happen */
+        return;
+
+    atoms[pEvdev->axis_map[axis]] = atom;
+}
+
+static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms)
+{
     int axis;
     char **labels;
     int labels_len = 0;
@@ -2723,16 +2739,7 @@ static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *ato
 
     /* Now fill the ones we know */
     for (axis = 0; axis < labels_len; axis++)
-    {
-        if (pEvdev->axis_map[axis] == -1)
-            continue;
-
-        atom = XIGetKnownProperty(labels[axis]);
-        if (!atom) /* Should not happen */
-            continue;
-
-        atoms[pEvdev->axis_map[axis]] = atom;
-    }
+        EvdevInitOneAxisLabel(pEvdev, axis, labels, axis, atoms);
 }
 
 static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms)
-- 
1.7.7.6



More information about the xorg-devel mailing list