Nit: patch title mis-spells "known"

With that change
Reviewed-by: Jason Gerecke <killert...@gmail.com>

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



On Tue, Mar 11, 2014 at 12:31 PM, Egbert Eich <e...@freedesktop.org> wrote:
> From: Egbert Eich <e...@suse.com>
>
> This is the last bit of clean up and consolidation in tool type detection:
> usbParseAbsEvent() sets the tool type if it recognized a button or key
> event and the tool type has not been set before.
> Before we get to usbParseAbsEvent() channel mapping must have failed most
> certainly so we must have gotten a new channel for each button or key
> sequence.
> Since this seems to be a last resort attempt to determine the tool type
> we only do this when all other methods have failed before. The newly
> introduced function deriveDeviceTypeFromButtonEvent() mimics the behavior
> of usbParseAbsEvent().
>
> Signed-off-by: Egbert Eich <e...@suse.com>
> ---
>  src/wcmUSB.c | 62 
> ++++++++++++++++++++++++++++++++----------------------------
>  1 file changed, 33 insertions(+), 29 deletions(-)
>
> diff --git a/src/wcmUSB.c b/src/wcmUSB.c
> index 1cbfa80..8e64f61 100644
> --- a/src/wcmUSB.c
> +++ b/src/wcmUSB.c
> @@ -1112,28 +1112,6 @@ static int usbFindDeviceTypeById(int device_id)
>         return 0;
>  }
>
> -/**
> - * Find the tool type (STYLUS_ID, etc.) based on the device_id or the
> - *  current tool serial number if the device_id is unknown (0).
> - *
> - * Protocol 5 devices report different IDs for different styli and pucks,
> - * Protocol 4 devices simply report STYLUS_DEVICE_ID, etc.
> - *
> - * @param ds The current device state received from the kernel.
> - * @return The tool type associated with the tool id or the current
> - * tool serial number.
> - */
> -static int usbFindDeviceType(const WacomCommonPtr common,
> -                         const WacomDeviceState *ds)
> -{
> -       int device_type = 0;
> -
> -       if (!ds->device_id) return 0;
> -
> -       device_type = usbFindDeviceTypeById(ds->device_id);
> -       return device_type;
> -}
> -
>  static void usbParseAbsEvent(WacomCommonPtr common,
>                             struct input_event *event, int channel_number)
>  {
> @@ -1189,10 +1167,7 @@ static void usbParseAbsEvent(WacomCommonPtr common,
>                 case ABS_MISC:
>                         ds->proximity = (event->value != 0);
>                         if (event->value)
> -                       {
>                                 ds->device_id = event->value;
> -                               ds->device_type = usbFindDeviceType(common, 
> ds);
> -                       }
>                         break;
>                 default:
>                         change = 0;
> @@ -1467,10 +1442,6 @@ static void usbParseBTNEvent(WacomCommonPtr common,
>         }
>
>         channel->dirty |= change;
> -
> -       /* expresskey pressed at startup or missing type */
> -       if (!ds->device_type && channel->dirty)
> -               ds->device_type = PAD_ID;
>  }
>
>  /**
> @@ -1568,6 +1539,35 @@ static int refreshDeviceType(WacomCommonPtr common)
>         return 0;
>  }
>
> +static int deriveDeviceTypeFromButtonEvent(WacomCommonPtr common,
> +                                          const struct input_event 
> *event_ptr)
> +{
> +       wcmUSBData *usbdata = common->private;
> +       int nkeys;
> +
> +       if (event_ptr->type == EV_KEY) {
> +
> +               switch (event_ptr->code) {
> +               case BTN_LEFT:
> +               case BTN_MIDDLE:
> +               case BTN_RIGHT:
> +               case BTN_SIDE:
> +               case BTN_BACK:
> +               case BTN_EXTRA:
> +               case BTN_FORWARD:
> +                       return PAD_ID;
> +               default:
> +                       for (nkeys = 0; nkeys < usbdata->npadkeys; nkeys++)
> +                       {
> +                               if (event_ptr->code == 
> usbdata->padkey_code[nkeys]) {
> +                                       return PAD_ID;
> +                               }
> +                       }
> +               }
> +       }
> +       return 0;
> +}
> +
>  /***
>   * Retrieve the tool type from an USB data packet by looking at the event
>   * codes. Refer to linux/input.h for event codes that define tool types.
> @@ -1599,6 +1599,10 @@ static int usbInitToolType(WacomCommonPtr common, 
> const struct input_event *even
>         if (!device_type)
>                 device_type = refreshDeviceType(common);
>
> +       if (!device_type) /* expresskey pressed at startup or missing type */
> +               for (i = 0; (i < nevents) && !device_type; ++i, event_ptr++)
> +                       device_type = deriveDeviceTypeFromButtonEvent(common, 
> event_ptr);
> +
>         return device_type;
>  }
>
> --
> 1.8.4.5
>

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to