[PATCH evdev 2/5] Split android axis simulation into a helper function

Peter Hutterer peter.hutterer at who-t.net
Tue Mar 10 22:53:34 PDT 2015


No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c | 69 ++++++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 43 insertions(+), 26 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index af691f5..1b7b7fd 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1167,33 +1167,12 @@ is_blacklisted_axis(int axis)
     }
 }
 
-
 static int
-EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
+EvdevAddFakeSingleTouchAxes(InputInfoPtr pInfo)
 {
-    InputInfoPtr pInfo;
-    EvdevPtr pEvdev;
-    int axis, i = 0;
-    int num_axes = 0; /* number of non-MT axes */
-    int num_mt_axes = 0, /* number of MT-only axes */
-        num_mt_axes_total = 0; /* total number of MT axes, including
-                                  double-counted ones, excluding blacklisted */
-    Atom *atoms;
-    int mapping = 0;
-
-    pInfo = device->public.devicePrivate;
-    pEvdev = pInfo->private;
-
-    if (!libevdev_has_event_type(pEvdev->dev, EV_ABS))
-        goto out;
-
-    /* Find number of absolute axis, including MT ones, will decrease later. */
-    for (i = 0; i < ABS_MAX; i++)
-        if (libevdev_has_event_code(pEvdev->dev, EV_ABS, i))
-            num_axes++;
-
-    if (num_axes < 1)
-        goto out;
+    EvdevPtr pEvdev = pInfo->private;
+    int num_axes = 0;
+    int i;
 
     /* Android drivers often have ABS_MT_POSITION_X but not ABS_X.
        Loop over the MT->legacy axis table and add fake axes. */
@@ -1201,6 +1180,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
     {
         int mt_code = mt_axis_mappings[i].mt_code;
         int code = mt_axis_mappings[i].code;
+
         if (libevdev_has_event_code(pEvdev->dev, EV_ABS, mt_code) &&
             !libevdev_has_event_code(pEvdev->dev, EV_ABS, code))
         {
@@ -1210,7 +1190,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
             {
                 xf86IDrvMsg(pInfo, X_ERROR, "Failed to fake axis %s.\n",
                             libevdev_event_code_get_name(EV_ABS, code));
-                goto out;
+                return -1;
             }
             xf86IDrvMsg(pInfo, X_INFO, "Faking axis %s.\n",
                         libevdev_event_code_get_name(EV_ABS, code));
@@ -1218,6 +1198,43 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
         }
     }
 
+    return num_axes;
+}
+
+static int
+EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
+{
+    InputInfoPtr pInfo;
+    EvdevPtr pEvdev;
+    int axis, i = 0;
+    int num_axes = 0; /* number of non-MT axes */
+    int num_mt_axes = 0, /* number of MT-only axes */
+        num_mt_axes_total = 0; /* total number of MT axes, including
+                                  double-counted ones, excluding blacklisted */
+    int num_faked_axes;
+    Atom *atoms;
+    int mapping = 0;
+
+    pInfo = device->public.devicePrivate;
+    pEvdev = pInfo->private;
+
+    if (!libevdev_has_event_type(pEvdev->dev, EV_ABS))
+        goto out;
+
+    /* Find number of absolute axis, including MT ones, will decrease later. */
+    for (i = 0; i < ABS_MAX; i++)
+        if (libevdev_has_event_code(pEvdev->dev, EV_ABS, i))
+            num_axes++;
+
+    if (num_axes < 1)
+        goto out;
+
+    num_faked_axes = EvdevAddFakeSingleTouchAxes(pInfo);
+    if (num_faked_axes < 0)
+        goto out;
+
+    num_axes += num_faked_axes;
+
     /* Absolute multitouch axes: adjust mapping and axes counts. */
     for (axis = ABS_MT_SLOT; axis < ABS_MAX; axis++)
     {
-- 
2.1.0



More information about the xorg-devel mailing list