Serial ISDv4 kernel driver, wacom_w8001.ko, provide both pen and
touch events on the same logical port. Filtering touch events when
pen is in proximity while allowing pen events (ABS_X/Y, etc) pass.

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

diff --git a/src/wcmUSB.c b/src/wcmUSB.c
index 9e0f310..3cc8bab 100644
--- a/src/wcmUSB.c
+++ b/src/wcmUSB.c
@@ -33,6 +33,7 @@
 typedef struct {
        int wcmLastToolSerial;
        int wcmBTNChannel;
+       Bool wcmPenTouch;
        Bool wcmUseMT;
        int wcmMTChannel;
        int wcmPrevChannel;
@@ -571,8 +572,14 @@ int usbWcmGetRanges(InputInfoPtr pInfo)
                common->wcmMaxDist = absinfo.maximum;
 
        if (ISBITSET(abs, ABS_MT_SLOT))
+       {
                private->wcmUseMT = 1;
 
+               /* pen and MT on the same logical port */
+               if (ISBITSET(common->wcmKeys, BTN_TOOL_PEN))
+                       private->wcmPenTouch = TRUE;
+       }
+
        /* A generic protocol device does not report ABS_MISC event */
        if (!ISBITSET(abs, ABS_MISC))
                common->wcmProtocolLevel = WCM_PROTOCOL_GENERIC;
@@ -848,6 +855,7 @@ skipEvent:
 static int usbFilterEvent(WacomCommonPtr common, struct input_event *event)
 {
        wcmUSBData* private = common->private;
+       WacomDeviceState dslast = common->wcmChannel[0].valid.state;
 
        /* For devices that report multitouch, the following list is a set of
         * duplicate data from one slot and needs to be filtered out.
@@ -865,12 +873,36 @@ static int usbFilterEvent(WacomCommonPtr common, struct 
input_event *event)
                }
                else if (event->type == EV_ABS)
                {
-                       switch(event->code)
+                       /* When pen and touch are on the same port, we need
+                        * to leave pen data alone.
+                        */
+                       if ((dslast.device_type != STYLUS_ID &&
+                                       dslast.device_type != ERASER_ID) ||
+                                       ((dslast.device_type == STYLUS_ID ||
+                                       dslast.device_type == ERASER_ID) &&
+                                       !dslast.proximity))
                        {
-                               case ABS_X:
-                               case ABS_Y:
-                               case ABS_PRESSURE:
-                                       return 1;
+                               /* filter ST for MT */
+                               switch(event->code)
+                               {
+                                       case ABS_X:
+                                       case ABS_Y:
+                                       case ABS_PRESSURE:
+                                               return 1;
+                               }
+                       }
+                       else
+                       {
+                               /* filter MT for pen */
+                               switch(event->code)
+                               {
+                                       case ABS_MT_SLOT:
+                                       case ABS_MT_TRACKING_ID:
+                                       case ABS_MT_POSITION_X:
+                                       case ABS_MT_POSITION_Y:
+                                       case ABS_MT_PRESSURE:
+                                               return 1;
+                               }
                        }
                }
        }
-- 
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