On Tue, Mar 29, 2011 at 11:37 PM, Peter Hutterer <peter.hutte...@who-t.net> wrote: > On Tue, Mar 29, 2011 at 11:21:58PM -0700, Jason Gerecke wrote: >> On Tue, Mar 29, 2011 at 9:21 PM, Peter Hutterer >> <peter.hutte...@who-t.net> wrote: >> > On Tue, Mar 29, 2011 at 04:18:38PM -0700, Jason Gerecke wrote: >> >> @@ -1782,41 +1797,118 @@ static int get_special_button_map(Display *dpy, >> >> XDevice *dev, >> >> >> >> TRACE("%s\n", buff); >> >> >> >> - XFree(btnact_data); >> >> + XFree(data); >> >> >> >> print_value(param, "%s", buff); >> >> >> >> return 1; >> >> } >> >> >> >> -static void get_button(Display *dpy, XDevice *dev, param_t *param, int >> >> argc, >> >> - char **argv) >> >> +/** >> >> + * Try to print the value of the raw button mapped to the given >> >> parameter's >> >> + * property. If the property contains data in the wrong format/type then >> >> + * nothing will be printed. >> >> + * >> >> + * @param dpy X11 display to connect to >> >> + * @param dev Device to query >> >> + * @param param Info about parameter to query >> >> + * @param offset Offset into the property specified in param >> >> + * @return 0 on failure, 1 otherwise >> >> + */ >> >> +static int get_button(Display *dpy, XDevice *dev, param_t *param, int >> >> offset) >> >> { >> >> - int nmap = 256; >> >> - unsigned char map[nmap]; >> >> - int button = 0; >> >> + Atom prop, type; >> >> + int format; >> >> + unsigned long nitems, bytes_after; >> >> + unsigned char *data; >> >> >> >> - if (argc < 1 || (sscanf(argv[0], "%d", &button) != 1)) >> >> - return; >> >> + prop = XInternAtom(dpy, param->prop_name, True); >> >> + >> >> + if (!prop) >> >> + return 0; >> >> + >> >> + XGetDeviceProperty(dpy, dev, prop, 0, 100, False, >> >> + AnyPropertyType, &type, &format, &nitems, >> >> + &bytes_after, (unsigned char**)&data); >> >> + >> >> + if (offset >= nitems) >> >> + { >> >> + XFree(data); >> >> + return 0; >> >> + } >> >> + >> >> + prop = data[offset]; >> >> + XFree(data); >> >> + >> >> + if (format != 8 || type != XA_INTEGER || !prop) >> >> + { >> >> + return 0; >> >> + } >> >> + >> >> + print_value(param, "%d", prop); >> >> + >> >> + return 1; >> >> +} >> >> + >> >> +/** >> >> + * Print the current button/wheel/strip mapping, be it a raw button or >> >> + * an action. Button map requests require the button number as the first >> >> + * argument in argv. >> >> + * >> >> + * @param dpy X11 display to connect to >> >> + * @param dev Device to query >> >> + * @param param Info about parameter to query >> >> + * @param argc Length of argv >> >> + * @param argv Command-line arguments >> >> + */ >> >> +static void get_map(Display *dpy, XDevice *dev, param_t *param, int >> >> argc, char** argv) >> >> +{ >> >> + int offset = param->prop_offset; >> >> >> >> TRACE("Getting button map for device %ld.\n", dev->device_id); >> >> >> >> - /* if there's a special map, print it and return */ >> >> - if (get_special_button_map(dpy, dev, param, button)) >> >> - return; >> >> + if (param->prop_name == WACOM_PROP_BUTTON_ACTIONS) >> > >> > in your testing, this should have always been false. you need a strcmp >> > here. >> > Can you please re-test this? >> > applies to 8/9 as well which has the same condition. >> > >> I can test to be sure, though I was pretty sure this worked. Way up >> where parameters[] is defined, we do "prop_name = >> WACOM_PROP_BUTTON_ACTIONS". Unless another function changes the >> prop_name to an identical string at a different location (i.e., they >> ignored the already-defined constant and used a hard-coded string >> instead) I don't see why there'd be a problem. >> >> Though, I can certainly do a strcmp if you want (or if I'm mistaken >> about it working) :) > > have a look at the gcc warning: > xsetwacom.c: In function ‘map_actions’: > xsetwacom.c:1321:23: warning: comparison with string literal results in > unspecified behavior > > problem is simple, WACOM_PROP_BUTTON_ACTIONS is a preprocessor define and > thus replaced before compilation. it's not a constant. That's quite > important here. > it would work if the code was like this (pseudocode): > > char property_name[] = "Wacom prop button actions"; > ... > prop_name = property_name; > ... > if (prop_name == property_name) > > but because it's a preprocessor define and not a constant, the code is more > like this: > > prop_name = "Wacom prop button actions"; > ... > if (prop_name == "Wacom prop button actions") > > and you're not guaranteed that the address is the same. > > Cheers, > Peter >
Ah, I see. That makes total sense. Also looks like I'm not getting all the warnings I'd like... Looks like I'll have to throw -Wall into my CFLAGS. Jason --- Day xee-nee-svsh duu-'ushtlh-ts'it; nuu-wee-ya' duu-xan' 'vm-nvshtlh-ts'it. Huu-chan xuu naa~-gha. ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel