[PATCH xf86-input-synaptics 4/6] eventcomm: Read evdev events from mtdev where multitouch is available

Chase Douglas chase.douglas at canonical.com
Thu Jan 19 13:05:49 PST 2012


Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
 src/eventcomm.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/eventcomm.c b/src/eventcomm.c
index 4752568..ada95b2 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -66,6 +66,7 @@ struct eventcomm_proto_data
      */
     BOOL need_grab;
 #ifdef HAVE_MTDEV
+    struct mtdev *mtdev;
     int axis_map[MT_ABS_SIZE];
 #endif
 };
@@ -89,6 +90,16 @@ EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters *para)
 
     proto_data->need_grab = FALSE;
 
+#ifdef HAVE_MTDEV
+    proto_data->mtdev = mtdev_new_open(pInfo->fd);
+    if (!proto_data->mtdev)
+    {
+        xf86IDrvMsg(pInfo, X_WARNING,
+                    "failed to create mtdev instance, ignoring touch events\n");
+        priv->has_touch = FALSE;
+    }
+#endif
+
     return TRUE;
 }
 
@@ -354,10 +365,20 @@ EventQueryHardware(InputInfoPtr pInfo)
 static Bool
 SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
 {
+#ifdef HAVE_MTDEV
+    SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+    struct eventcomm_proto_data *proto_data = priv->proto_data;
+#endif
     int rc = TRUE;
     ssize_t len;
 
-    len = read(pInfo->fd, ev, sizeof(*ev));
+#ifdef HAVE_MTDEV
+    if (proto_data->mtdev)
+        len = mtdev_get(proto_data->mtdev, pInfo->fd, ev, 1) *
+              sizeof(struct input_event);
+    else
+#endif
+        len = read(pInfo->fd, ev, sizeof(*ev));
     if (len <= 0)
     {
         /* We use X_NONE here because it doesn't alloc */
-- 
1.7.8.3



More information about the xorg-devel mailing list