This patch will need to be updated when XInput 2.1 is ready to
process MT events.

Signed-off-by: Ping Cheng <[email protected]>
---
 src/wcmUSB.c |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index 3cc8bab..6fe5926 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -1251,6 +1251,47 @@ static int usbParseBTNEvent(WacomCommonPtr common,
        return change;
 }
 
+/***
+ * Retrieve the tool type from an USB data packet.
+ *
+ * @param private A poitner to struct wcmUSBData to access device specific 
data.
+ *
+ * @return devcie_type The device type comes with the data packet.
+ * 0 is returned when type is found.
+ */
+static int usbGetToolType(wcmUSBData *private)
+{
+       int i, device_type = 0;
+       struct input_event* event;
+
+       for (i=0; i<private->wcmEventCnt; ++i)
+       {
+               event = private->wcmEvents + i;
+
+               switch (event->code)
+               {
+                       case BTN_TOOL_PEN:
+                       case BTN_TOOL_PENCIL:
+                       case BTN_TOOL_BRUSH:
+                       case BTN_TOOL_AIRBRUSH:
+                               device_type = STYLUS_ID;
+                               break;
+
+                       case BTN_TOOL_FINGER:
+                       case ABS_MT_SLOT:
+                       case ABS_MT_TRACKING_ID:
+                               device_type = TOUCH_ID;
+                               break;
+
+                       case BTN_TOOL_RUBBER:
+                               device_type = ERASER_ID;
+                               break;
+               }
+       }
+       return device_type;
+}
+
+
 static void usbDispatchEvents(InputInfoPtr pInfo)
 {
        int i;
@@ -1258,13 +1299,30 @@ static void usbDispatchEvents(InputInfoPtr pInfo)
        struct input_event* event;
        WacomDevicePtr priv = (WacomDevicePtr)pInfo->private;
        WacomCommonPtr common = priv->common;
-       int channel;
+       int channel, device_type = 0;
        int channel_change = 0, btn_channel_change = 0, mt_channel_change = 0;
-       WacomDeviceState dslast;
+       WacomDeviceState dslast = common->wcmChannel[0].valid.state;
        wcmUSBData* private = common->private;
 
        DBG(6, common, "%d events received\n", private->wcmEventCnt);
 
+       if (private->wcmPenTouch)
+       {
+               device_type = usbGetToolType(private);
+
+               /* don't process touch event when pen is in-prox.
+                * Touch events will be posted to the userland when XInput 2.1
+                * is ready.
+                */
+               if ((device_type == TOUCH_ID) &&
+                       ((dslast.device_type == STYLUS_ID ||
+                       dslast.device_type == ERASER_ID) && dslast.proximity))
+               {
+                       private->wcmEventCnt = 0;
+                       return;
+               }
+       }
+
        channel = usbChooseChannel(common);
 
        /* couldn't decide channel? invalid data */
-- 
1.7.4


------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to