On Mon, Jan 26, 2015 at 01:27:59PM -0800, Jason Gerecke wrote:
> Setting a button value requires a slightly different format than most
> other properties. In particular, they require the presence of a button
> number either concatenated onto the prefix 'Button' (for xorg.conf format)
> or as a seperate parameter (for shell format).
> 
> Signed-off-by: Jason Gerecke <killert...@gmail.com>
> ---
>  tools/xsetwacom.c | 36 ++++++++++++++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
> index d78160e..402cc09 100644
> --- a/tools/xsetwacom.c
> +++ b/tools/xsetwacom.c
> @@ -694,6 +694,35 @@ static void print_value(param_t *param, const char *msg, 
> ...)
>       va_end(va_args);
>  }
>  
> +static void print_button_value(param_t *param, int n, const char *msg, ...)

might want to add
__attribute__ ((format (printf, 3, 4)));


> +{
> +     n++; /* Property is 0-indexed, X buttons are 1-indexed */
> +
> +     va_list va_args;
> +     va_start(va_args, msg);
> +     switch(param->printformat)
> +     {
> +             case FORMAT_XORG_CONF:
> +                     printf("Option \"%s%d\" \"", param->name);

you're missing n here

otherwise, Reviewed-by: Peter Hutterer <peter.hutte...@who-t.net> for the
series.

Cheers,
   Peter


> +                     vprintf(msg, va_args);
> +                     printf("\"\n");
> +                     break;
> +             case FORMAT_SHELL:
> +                     printf("xsetwacom set \"%s\" \"%s\" \"%d\" \"",
> +                                     param->device_name, param->name, n);
> +                     vprintf(msg, va_args);
> +                     printf("\"\n");
> +                     break;
> +             case FORMAT_DEFAULT:
> +             default:
> +                     vprintf(msg, va_args);
> +                     printf("\n");
> +                     break;
> +     }
> +
> +     va_end(va_args);
> +}
> +
>  static void usage(void)
>  {
>       printf(
> @@ -1997,7 +2026,10 @@ static int get_actions(Display *dpy, XDevice *dev,
>  
>       XFree(data);
>  
> -     print_value(param, "%s", buff);
> +     if (param->printformat == FORMAT_XORG_CONF)
> +             fprintf(stderr, "%s: Actions are not supported by xorg.conf. 
> Try shell format (-s) instead.\n", param->name);
> +     else
> +             print_button_value(param, offset, "%s", buff);
>  
>       return 1;
>  }
> @@ -2043,7 +2075,7 @@ static int get_button(Display *dpy, XDevice *dev, 
> param_t *param, int offset)
>               return 0;
>       }
>  
> -     print_value(param, "%d", prop);
> +     print_button_value(param, offset, "%d", prop);
>  
>       return 1;
>  }
> -- 
> 2.2.1
> 

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to