On Thu, Feb 28, 2013 at 11:43 AM, Chris Bagwell <ch...@cnpbagwell.com>wrote:

>
> On Tue, Feb 26, 2013 at 3:10 PM, Ping Cheng <pingli...@gmail.com> wrote:
>
>> usbInitToolType retrieves device type from the kernel when tool
>> is on the tablet when X server starts. No need to do it again later.
>>
>> Signed-off-by: Ping Cheng <pi...@wacom.com>
>>
>
> I like the direction this is headed (deleting all that corner case
> logic)...  There are so many different device behavior that its hard to
> guess any issues from review alone though.
>
> From what I recall, PAD's are only devices that can't "fix" themselves
> over time (by moving tool out of prox and back in) and you seem to have
> handled that case.  So I'll at least give:
>
> Acked-by: Chris Bagwell <ch...@cnpbagwell.com>
>

Would you mind if this patch were split in two before merging? It seems
there are really two patches here: one to remove the duplication in
tool-type retrieval, and a second to remove the PAD event corner case. That
second piece took me a while to understand...

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one  /
(That is to say, eight) to the two,     /
But you can’t take seven from three,    /
So you look at the sixty-fours....


>
>
>> ---
>>  src/wcmUSB.c |   72
>> ++++------------------------------------------------------
>>  1 file changed, 5 insertions(+), 67 deletions(-)
>>
>> diff --git a/src/wcmUSB.c b/src/wcmUSB.c
>> index 75caa6b..980dac3 100644
>> --- a/src/wcmUSB.c
>> +++ b/src/wcmUSB.c
>> @@ -1,6 +1,6 @@
>>  /*
>>   * Copyright 1995-2002 by Frederic Lepied, France. <lep...@xfree86.org>
>> - * Copyright 2002-2010 by Ping Cheng, Wacom. <pi...@wacom.com>
>> + * Copyright 2002-2013 by Ping Cheng, Wacom. <pi...@wacom.com>
>>   *
>>   * This program is free software; you can redistribute it and/or
>>   * modify it under the terms of the GNU General Public License
>> @@ -1223,25 +1223,6 @@ static void usbParseAbsMTEvent(WacomCommonPtr
>> common, struct input_event *event)
>>         (&common->wcmChannel[private->wcmMTChannel])->dirty |= change;
>>  }
>>
>> -static struct
>> -{
>> -       unsigned long device_type;
>> -       unsigned long tool_key;
>> -} wcmTypeToKey [] =
>> -{
>> -       { STYLUS_ID, BTN_TOOL_PEN       },
>> -       { STYLUS_ID, BTN_TOOL_PENCIL    },
>> -       { STYLUS_ID, BTN_TOOL_BRUSH     },
>> -       { STYLUS_ID, BTN_TOOL_AIRBRUSH  },
>> -       { ERASER_ID, BTN_TOOL_RUBBER    },
>> -       { CURSOR_ID, BTN_TOOL_MOUSE     },
>> -       { CURSOR_ID, BTN_TOOL_LENS      },
>> -       { TOUCH_ID,  BTN_TOOL_DOUBLETAP },
>> -       { TOUCH_ID,  BTN_TOOL_TRIPLETAP },
>> -       { PAD_ID,    BTN_FORWARD        },
>> -       { PAD_ID,    BTN_0              }
>> -};
>> -
>>  static void usbParseKeyEvent(WacomCommonPtr common,
>>                             struct input_event *event, int channel_number)
>>  {
>> @@ -1434,6 +1415,8 @@ static void usbParseBTNEvent(WacomCommonPtr common,
>>                         }
>>                         if (nkeys >= usbdata->npadkeys)
>>                                 change = 0;
>> +                       else if (!ds->device_type) /* expresskey pressed
>> at startup */
>> +                               ds->device_type = PAD_ID;
>>         }
>>
>>         channel->dirty |= change;
>> @@ -1625,9 +1608,9 @@ static void usbDispatchEvents(InputInfoPtr pInfo)
>>         ds = &common->wcmChannel[channel].work;
>>         dslast = common->wcmChannel[channel].valid.state;
>>
>> -       /* no device type? tool was on the tablet at startup, force type
>> and
>> -          proximity */
>> +       /* no device type? */
>>         if (!ds->device_type && private->wcmDeviceType) {
>> +               /* tool was on tablet at startup, force type and
>> proximity */
>>                 ds->device_type = private->wcmDeviceType;
>>                 ds->proximity = 1;
>>         }
>> @@ -1670,54 +1653,9 @@ static void usbDispatchEvents(InputInfoPtr pInfo)
>>                 {
>>                         usbParseKeyEvent(common, event, channel);
>>                         usbParseBTNEvent(common, event,
>> private->wcmBTNChannel);
>> -
>> -                       /* send PAD events now for generic devices.
>> Otherwise,
>> -                        * they are filtered out when there are no motion
>> events.
>> -                        */
>> -                       if ((common->wcmProtocolLevel ==
>> WCM_PROTOCOL_GENERIC)
>> -                           &&
>> (common->wcmChannel[private->wcmBTNChannel].dirty))
>> -                        {
>> -                               DBG(10, common, "Dirty flag set on
>> channel %d; "
>> -                                   "sending event.\n",
>> private->wcmBTNChannel);
>> -
>> common->wcmChannel[private->wcmBTNChannel].dirty = FALSE;
>> -                               wcmEvent(common, private->wcmBTNChannel,
>> -
>>  &common->wcmChannel[private->wcmBTNChannel].work);
>> -                       }
>>                 }
>>         } /* next event */
>>
>> -       /* device type unknown? Tool may be on the tablet when X starts.
>> */
>> -       if (!ds->device_type && !dslast.proximity)
>> -       {
>> -               unsigned long keys[NBITS(KEY_MAX)] = { 0 };
>> -               int rc;
>> -
>> -               if (!ds->proximity) {
>> -                       DBG(3, common, "Unknown out-of-prox device
>> leaving prox. Ignoring.\n");
>> -                       return;
>> -               }
>> -
>> -               /* Retrieve the type by asking a resend from the kernel */
>> -               rc = ioctl(common->fd, EVIOCGKEY(sizeof(keys)), keys);
>> -               if (rc == -1)
>> -               {
>> -                       LogMessageVerbSigSafe(X_ERROR, 0,
>> -                                             "%s: failed to retrieve key
>> bits\n",
>> -                                             pInfo->name);
>> -                       return;
>> -               }
>> -
>> -               for (i = 0; i < ARRAY_SIZE(wcmTypeToKey); i++)
>> -               {
>> -                       if (ISBITSET(keys, wcmTypeToKey[i].tool_key))
>> -                       {
>> -                               ds->device_type =
>> wcmTypeToKey[i].device_type;
>> -                               ds->proximity = 1;
>> -                               break;
>> -                       }
>> -               }
>> -       }
>> -
>>         /* DTF720 and DTF720a don't support eraser */
>>         if (((common->tablet_id == 0xC0) || (common->tablet_id == 0xC2))
>> &&
>>                 (ds->device_type == ERASER_ID))
>> --
>> 1.7.10.4
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_feb
>> _______________________________________________
>> Linuxwacom-devel mailing list
>> Linuxwacom-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
>>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
>
>
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to