Automatic handling of properties that take several items, eg. TVResolution0 and TVResolution1.
Signed-off-by: Peter Hutterer <[email protected]> --- tools/xsetwacom.c | 27 ++++++++++++++++++++------- 1 files changed, 20 insertions(+), 7 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 21f325e..a858372 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -84,6 +84,7 @@ typedef struct _param const char *prop_name; /* property name */ const int prop_format; /* property format */ const int prop_offset; /* offset (index) into the property values */ + const int prop_extra; /* extra number of items after first one */ const unsigned int prop_flags; void (*set_func)(Display *dpy, XDevice *dev, struct _param *param, int argc, char **argv); /* handler function, if appropriate */ void (*get_func)(Display *dpy, XDevice *dev, struct _param *param, int argc, char **argv); /* handler function for getting, if appropriate */ @@ -541,6 +542,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_TWINVIEW_RES, .prop_format = 32, .prop_offset = 0, + .prop_extra = 1, }, { .name = "TVResolution1", @@ -548,6 +550,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_TWINVIEW_RES, .prop_format = 32, .prop_offset = 1, + .prop_extra = 1, }, { .name = "RawFilter", @@ -2414,6 +2417,8 @@ static void get_param(Display *dpy, XDevice *dev, param_t *param, int argc, char int format; unsigned char* data; unsigned long nitems, bytes_after; + int i; + char str[100] = {0}; if (param->prop_name) { @@ -2445,23 +2450,31 @@ static void get_param(Display *dpy, XDevice *dev, param_t *param, int argc, char switch(param->prop_format) { case 8: + for (i = 0; i < 1 + param->prop_extra; i++) { - char str[10] = {0}; - int val = data[param->prop_offset]; + int val = data[param->prop_offset + i]; if (param->prop_flags & PROP_FLAG_BOOLEAN) - sprintf(str, "%s", val ? "on" : "off"); + sprintf(str, "%s%s", str, val ? "on" : "off"); else - sprintf(str, "%d", val); - print_value(param, "%s", str); + sprintf(str, "%s%d", str, val); + + if (i < param->prop_extra) + sprintf(str, "%s ", str); } + print_value(param, "%s", str); break; case 32: + for (i = 0; i < 1 + param->prop_extra; i++) { long *ldata = (long*)data; - print_value(param, "%ld", ldata[param->prop_offset]); - break; + sprintf(str, "%s%ld", str, ldata[param->prop_offset + i]); + + if (i < param->prop_extra) + sprintf(str, "%s ", str); } + print_value(param, "%s", str); + break; } } -- 1.7.2.2 ------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ Linuxwacom-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
