[PATCH 12/42] Add the touch input API stubs

Peter Hutterer peter.hutterer at who-t.net
Wed Dec 14 19:01:49 PST 2011


From: Daniel Stone <daniel at fooishbar.org>

xf86PostTouchEvent is the driver API to submit touch events to the server.
This API doesn't do anything yet though but now we can at least bump the
API.

For valuators, drivers should use the existing xf86InitValuatorAxisStruct
function.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 dix/getevents.c                |   48 ++++++++++++++++++++++++++++++++++++++++
 hw/xfree86/common/xf86Xinput.c |   24 ++++++++++++++++++++
 hw/xfree86/common/xf86Xinput.h |    3 ++
 include/input.h                |   14 +++++++++++
 4 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/dix/getevents.c b/dix/getevents.c
index 5bf6658..ec7f5c6 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1603,6 +1603,54 @@ GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type, const Val
 }
 
 /**
+ * Generate internal events representing this touch event and enqueue them
+ * on the event queue.
+ *
+ * This function is not reentrant. Disable signals before calling.
+ *
+ * @param device The device to generate the event for
+ * @param type Event type, one of XI_TouchBegin, XI_TouchUpdate, XI_TouchEnd
+ * @param touchid Touch point ID
+ * @param flags Event modification flags
+ * @param mask Valuator mask for valuators present for this event.
+ */
+void
+QueueTouchEvents(DeviceIntPtr device, int type,
+                 uint32_t ddx_touchid, int flags, const ValuatorMask *mask)
+{
+    int nevents;
+
+    nevents = GetTouchEvents(InputEventList, device, ddx_touchid, type, flags, mask);
+    queueEventList(device, InputEventList, nevents);
+}
+
+/**
+ * Get events for a touch. Generates a TouchBegin event if end is not set and
+ * the touch id is not active. Generates a TouchUpdate event if end is not set
+ * and the touch id is active. Generates a TouchEnd event if end is set and the
+ * touch id is active.
+ *
+ * events is not NULL-terminated; the return value is the number of events.
+ * The DDX is responsible for allocating the event structure in the first
+ * place via GetMaximumEventsNum(), and for freeing it.
+ *
+ * @param[out] events The list of events generated
+ * @param dev The device to generate the events for
+ * @param ddx_touchid The touch ID as assigned by the DDX
+ * @param type XI_TouchBegin, XI_TouchUpdate or XI_TouchEnd
+ * @param flags Event flags
+ * @param mask_in Valuator information for this event
+ */
+int
+GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
+               uint16_t type, uint32_t flags, const ValuatorMask *mask_in)
+{
+    return 0;
+}
+
+
+
+/**
  * Synthesize a single motion event for the core pointer.
  *
  * Used in cursor functions, e.g. when cursor confinement changes, and we need
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index b9753f0..280a6ec 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1410,4 +1410,28 @@ xf86EnableDevice(DeviceIntPtr dev)
     EnableDevice(dev, TRUE);
 }
 
+/**
+ * Post a touch event with optional valuators.  If this is the first touch in
+ * the sequence, at least x & y valuators must be provided. The driver is
+ * responsible for maintaining the correct event sequence (TouchBegin, TouchUpdate,
+ * TouchEnd). Submitting an update or end event for a unregistered touchid will
+ * result in errors.
+ * Touch IDs may be reused by the driver but only after a TouchEnd has been
+ * submitted for that touch ID.
+ *
+ * @param dev The device to post the event for
+ * @param touchid The touchid of the current touch event. Must be an
+ * existing ID for TouchUpdate or TouchEnd events
+ * @param type One of XI_TouchBegin, XI_TouchUpdate, XI_TouchEnd
+ * @param flags Flags for this event
+ * @param The valuator mask with all valuators set for this event.
+ */
+void
+xf86PostTouchEvent(DeviceIntPtr dev, uint32_t touchid, uint16_t type,
+                   uint32_t flags, const ValuatorMask *mask)
+{
+
+    QueueTouchEvents(dev, type, touchid, flags, mask);
+}
+
 /* end of xf86Xinput.c */
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 909fb57..851aeae 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -141,6 +141,9 @@ extern _X_EXPORT void xf86PostKeyEventP(DeviceIntPtr device, unsigned int key_co
 		       const int *valuators);
 extern _X_EXPORT void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
                            int is_down);
+extern _X_EXPORT void xf86PostTouchEvent(DeviceIntPtr dev, uint32_t touchid,
+                                         uint16_t type, uint32_t flags,
+                                         const ValuatorMask *mask);
 extern _X_EXPORT InputInfoPtr xf86FirstLocalDevice(void);
 extern _X_EXPORT int xf86ScaleAxis(int Cx, int to_max, int to_min, int from_max, int from_min);
 extern _X_EXPORT void xf86ProcessCommonOptions(InputInfoPtr pInfo, XF86OptionPtr options);
diff --git a/include/input.h b/include/input.h
index 7a7e16b..a94ff94 100644
--- a/include/input.h
+++ b/include/input.h
@@ -480,6 +480,20 @@ extern _X_EXPORT void QueueKeyboardEvents(
     int key_code,
     const ValuatorMask *mask);
 
+extern int GetTouchEvents(
+    InternalEvent *events,
+    DeviceIntPtr pDev,
+    uint32_t ddx_touchid,
+    uint16_t type,
+    uint32_t flags,
+    const ValuatorMask *mask);
+
+void QueueTouchEvents(DeviceIntPtr device,
+                      int type,
+                      uint32_t ddx_touchid,
+                      int flags,
+                      const ValuatorMask *mask);
+
 extern _X_EXPORT int GetProximityEvents(
     InternalEvent *events,
     DeviceIntPtr pDev,
-- 
1.7.7.1



More information about the xorg-devel mailing list