It makes me dizzy trying to remember differences between
common->nbuttons, priv->nbuttons, and common->npadkeys.

This is definitely the direction we want to be moving and I'm 99% sure
there are no issues in this patch.  I reserve that 1% in case it
crashes and burns. :)

For both patches:

Reviewed-by: Chris Bagwell <ch...@cnpbagwell.com>

On Fri, Feb 3, 2012 at 3:31 AM, Peter Hutterer <peter.hutte...@who-t.net> wrote:
> Previous code had the number of properties for button actions hardcoded to
> 16 (WCM_MAX_MOUSE_BUTTONS). Drop that define and instead initialize the same
> number of properties that we have on the device as well.
>
> X.Org Bug 45557 <http://bugs.freedesktop.org/show_bug.cgi?id=45557>
>
> Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
> ---
>  src/wcmXCommand.c   |   29 ++++++++++++++++-------------
>  src/xf86WacomDefs.h |    7 +------
>  2 files changed, 17 insertions(+), 19 deletions(-)
>
> diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
> index 6613a59..d0963f1 100644
> --- a/src/wcmXCommand.c
> +++ b/src/wcmXCommand.c
> @@ -122,9 +122,9 @@ static Atom InitWcmAtom(DeviceIntPtr dev, char *name, 
> Atom type, int format, int
>  {
>        int i;
>        Atom atom;
> -       uint8_t val_8[WCM_MAX_MOUSE_BUTTONS];
> -       uint16_t val_16[WCM_MAX_MOUSE_BUTTONS];
> -       uint32_t val_32[WCM_MAX_MOUSE_BUTTONS];
> +       uint8_t val_8[WCM_MAX_BUTTONS];
> +       uint16_t val_16[WCM_MAX_BUTTONS];
> +       uint32_t val_32[WCM_MAX_BUTTONS];
>        pointer converted = val_32;
>
>        for (i = 0; i < nvalues; i++)
> @@ -156,7 +156,8 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
>  {
>        WacomDevicePtr priv = (WacomDevicePtr) pInfo->private;
>        WacomCommonPtr common = priv->common;
> -       int values[WCM_MAX_MOUSE_BUTTONS];
> +       int values[WCM_MAX_BUTTONS];
> +       int nbuttons;
>
>        DBG(10, priv, "\n");
>
> @@ -225,9 +226,11 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo)
>        values[0] = MakeAtom(pInfo->type_name, strlen(pInfo->type_name), TRUE);
>        prop_tooltype = InitWcmAtom(pInfo->dev, WACOM_PROP_TOOL_TYPE, XA_ATOM, 
> 32, 1, values);
>
> +
>        /* default to no actions */
> +       nbuttons = min(max(priv->nbuttons + 4, 7), WCM_MAX_BUTTONS);
>        memset(values, 0, sizeof(values));
> -       prop_btnactions = InitWcmAtom(pInfo->dev, WACOM_PROP_BUTTON_ACTIONS, 
> XA_ATOM, 32, WCM_MAX_MOUSE_BUTTONS, values);
> +       prop_btnactions = InitWcmAtom(pInfo->dev, WACOM_PROP_BUTTON_ACTIONS, 
> XA_ATOM, 32, nbuttons, values);
>
>        if (IsPad(priv)) {
>                memset(values, 0, sizeof(values));
> @@ -288,7 +291,7 @@ static int wcmSanityCheckProperty(XIPropertyValuePtr prop)
>                        case AC_KEY:
>                                break;
>                        case AC_BUTTON:
> -                               if (code > WCM_MAX_MOUSE_BUTTONS)
> +                               if (code > WCM_MAX_BUTTONS)
>                                        return BadValue;
>                                break;
>                        case AC_DISPLAYTOGGLE:
> @@ -492,12 +495,12 @@ static int wcmSetWheelOrStripProperty(DeviceIntPtr dev, 
> Atom property,
>        switch (prop->format)
>        {
>                case 8:
> -                       if (values.v8[0] > WCM_MAX_MOUSE_BUTTONS ||
> -                           values.v8[1] > WCM_MAX_MOUSE_BUTTONS ||
> -                           values.v8[2] > WCM_MAX_MOUSE_BUTTONS ||
> -                           values.v8[3] > WCM_MAX_MOUSE_BUTTONS ||
> -                           values.v8[4] > WCM_MAX_MOUSE_BUTTONS ||
> -                           values.v8[5] > WCM_MAX_MOUSE_BUTTONS)
> +                       if (values.v8[0] > WCM_MAX_BUTTONS ||
> +                           values.v8[1] > WCM_MAX_BUTTONS ||
> +                           values.v8[2] > WCM_MAX_BUTTONS ||
> +                           values.v8[3] > WCM_MAX_BUTTONS ||
> +                           values.v8[4] > WCM_MAX_BUTTONS ||
> +                           values.v8[5] > WCM_MAX_BUTTONS)
>                                return BadValue;
>
>                        if (!checkonly) {
> @@ -846,7 +849,7 @@ int wcmSetProperty(DeviceIntPtr dev, Atom property, 
> XIPropertyValuePtr prop,
>  #endif
>        } else if (property == prop_btnactions)
>        {
> -               if (prop->size != WCM_MAX_MOUSE_BUTTONS)
> +               if (prop->size != WCM_MAX_BUTTONS)
>                        return BadMatch;
>                wcmSetPropertyButtonActions(dev, property, prop, checkonly);
>        } else
> diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h
> index 3b79189..167866a 100644
> --- a/src/xf86WacomDefs.h
> +++ b/src/xf86WacomDefs.h
> @@ -188,12 +188,7 @@ struct _WacomModel
>  #define DEFAULT_THRESHOLD (FILTER_PRESSURE_RES / 75)
>
>  #define WCM_MAX_BUTTONS                32      /* maximum number of tablet 
> buttons */
> -#define WCM_MAX_MOUSE_BUTTONS  16      /* maximum number of 
> buttons-on-pointer
> -                                         * (which are treated as mouse 
> buttons,
> -                                         * not as keys like tablet menu 
> buttons).
> -                                        * For backward compability support,
> -                                        * tablet buttons besides the strips 
> are
> -                                        * treated as buttons */
> +
>  #define AXIS_INVERT  0x01               /* Flag describing an axis which 
> increases "downward" */
>  #define AXIS_BITWISE 0x02               /* Flag describing an axis which 
> changes bitwise */
>
> --
> 1.7.7.5
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> Linuxwacom-devel mailing list
> Linuxwacom-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to