On Wed, Mar 16, 2011 at 03:55:27PM -0700, Ping Cheng wrote:
> 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.

should this be a configurable behaviour?

> 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;
> +     }

we don't seem to do anything with this field.

> +
>       /* 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))

we already go past 78 characters in much of the code, I think we
should afford to here as well. this condition makes it really hard to read.

if ((dslast.device_type != STYLUS_ID && dslast.device_type != ERASER_ID) ||
    ((dslast.device_type == STYLUS_ID || dslast.device_type == ERASER_ID) && 
!dslast.proximity))

also, generally the rule is if you're three if conditions down, then it's
time to refactor and split into smaller functions :)

Cheers,
  Peter

>                       {
> -                             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
> 

------------------------------------------------------------------------------
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