Re: [Linuxwacom-devel] [PATCH 9/9] Revamp button/wheel/strip getters
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) :) + { + if (argc == 0) + { + fprintf(stderr, Too few arguments provided.\n); + return; + } - nmap = XGetDeviceButtonMapping(dpy, dev, map, nmap); + if (sscanf(argv[0], %d, offset) != 1) + { + fprintf(stderr, '%s' is not a valid button number.\n, argv[0]); + return; + } - if (button nmap) - { - fprintf(stderr, Button number does not exist on device.\n); - return; + offset--; //Property is 0-indexed, X buttons are 1-indexed + argc--; //Trim off the target button argument + argv = argv[1]; //... ditto ... no // comments please, just use /* */ instead. Will do. 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
Re: [Linuxwacom-devel] [PATCH 1/9] Fix buttons must be set twice bug from d650b139
On Tue, Mar 29, 2011 at 9:03 PM, Peter Hutterer peter.hutte...@who-t.net wrote: applied, but from a cursory glance I'm not sure why. In fact, I would have guessed the other way round. anyway, I've added a comment to avoid this in the future (at least until we find the reason why and fixed it). Cheers, Peter I thought it was curious as well. I tried things both ways around and was surprised to see that this was the order that worked. 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
Re: [Linuxwacom-devel] [PATCH 9/9] Revamp button/wheel/strip getters
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 -- 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
Re: [Linuxwacom-devel] [PATCH 9/9] Revamp button/wheel/strip getters
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
Re: [Linuxwacom-devel] [PATCH v2] usb: count the number of buttons instead of hardcoding them.
On Tue, Mar 29, 2011 at 10:53 PM, Peter Hutterer peter.hutte...@who-t.net wrote: Signed-off-by: Peter Hutterer peter.hutte...@who-t.net --- Chris, can you comment on the fixme I have added here. The current code seems to increase the number of buttons on the device when mouse buttons are found but I don't understand why. As I understand this, the code is still overlapping, so you get one pad code and one mouse code to map to the same internal button number. If this is the case, we don't actually need more buttons since the driver appears to only ever have one. Shouldn't this set nbuttons to max(pad keys, mouse keys)? I haven't been able to review this closely yet but here is some initial feedback. Yes, there should be some kind of max(pad keys,mouse keys). There are two classes of button reports. 1) pad buttons - They may be mislabeled because I think I've seen stylus send these but still useful to have class. Those can go from button 0 to max detected. This means their button mapping is dynamically computed based on order of wcmKeys (although its static for a given kernel driver). 2) mouse buttons - Again probably mislabeled since BTN_STYLUS falls in thise case but still useful to have class name. These can go from button 0 to button 4 max and their is a static mapping always. See usbParseBTNEvent() and usbParseKeyEvent() for more info but some examples: BTN_TOUCH == BTN_LEFT == 0 BTN_STYLUS == BTN_MIDDLE == 1 BTN_STYLUS == BTN_RIGHT == 2 So I believe your patch is detecting to high of button counts for overlaping static maps. The code around the FIXME area is related to MT Bamboo driver have mouse-like LEFT/RIGHT buttons on pad while the mouse pucks on cursors device for non-MT Bamboos also have mouse-like buttons. So we need to detect to increment pad or cursors button count. Really, the tablet buttons on MT Bamboo come in as if they are with touch device (their is no channel concept) but we route them over to pad device because today's logic can't handle button presses on touch devices while the tool is out of proximity (is same true for xf86-input-evdev?). So we keep pad always in proximity to work around that. On the FIXME mapping question, the reason it isn't updating mapping[] is because it would be ignored because we do hardcoded BTN_* checks with static mappings before looping threw mapping[]. It may be a good idea to loop threw mapping[] first though. I need to think about that one some more (make sure it works for all the weird cases we are handling). Changes to v1: - count BTN_TOUCH as button now. - count pad buttons too (plus tests) src/wcmUSB.c | 102 +--- test/Makefile.am | 4 +- test/usb-tests.c | 152 ++ 3 files changed, 227 insertions(+), 31 deletions(-) create mode 100644 test/usb-tests.c diff --git a/src/wcmUSB.c b/src/wcmUSB.c index d4382ef..208f10e 100644 --- a/src/wcmUSB.c +++ b/src/wcmUSB.c @@ -162,7 +162,6 @@ static unsigned short padkey_codes [] = { /* Fixed mapped stylus and mouse buttons */ #define WCM_USB_MAX_MOUSE_BUTTONS 5 -#define WCM_USB_MAX_STYLUS_BUTTONS 3 static unsigned short mouse_codes [] = { BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, BTN_BACK, BTN_FORWARD, @@ -309,6 +308,74 @@ static struct { LENOVO_VENDOR_ID, 0x6004, 2540, 2540, usbTabletPC } /* Pen-only */ }; +/** + * Count the number of buttons on the device. + * + * @param keys An array large enough to hold KEY_MAX bits. + * No size check is performed, the caller must ensure it is large enough. + * @return The number of buttons we interpret. + */ +static int usbCountButtons(const unsigned long *keys) +{ + int nbuttons = 0; + + if (ISBITSET(keys, BTN_LEFT)) nbuttons++; + if (ISBITSET(keys, BTN_MIDDLE)) nbuttons++; + if (ISBITSET(keys, BTN_RIGHT)) nbuttons++; + if (ISBITSET(keys, BTN_SIDE)) nbuttons++; + if (ISBITSET(keys, BTN_EXTRA)) nbuttons++; + if (ISBITSET(keys, BTN_STYLUS)) nbuttons++; + if (ISBITSET(keys, BTN_STYLUS2)) nbuttons++; + if (ISBITSET(keys, BTN_TOUCH)) nbuttons++; + + return nbuttons; +} +/** + * Count the number of pad buttons on the device. + * For any button that is found on the device, a mapping is set up, with the + * index being the (X button number - 1) and the value being the kernel + * event code. + * + * @param keys An array large enough to hold KEY_MAX bits. + * No size check is performed, the caller must ensure it is large enough. + * @param[out] mapping Filled with the kernel event code to X button number + * mapping.The return value specifies the number of set elements in this + * array, remaining elements are undefined. + * @return The number of pad buttons we interpret and the number of elements + * in mappping. + */ + +static int usbCountPadButtons(const unsigned long *keys, + int
[Linuxwacom-devel] [PATCH 8v2/9] Merge 'map_wheels' and 'map_button' into a unified 'map_actions'
These two functions are very similar, and have been merged together to provide a single conduit for all action mappings. Button-handling code requires a little bit of special-casing (we need to be sure to get a button to modify, and to change the arguments appropriately), but nothing remotely worthy of breaking into its own function. Signed-off-by: Jason Gerecke killert...@gmail.com --- Changes from v1: * Use strcmp instead of == tools/xsetwacom.c | 98 - 1 files changed, 52 insertions(+), 46 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 2ff3b22..18155aa 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -98,8 +98,7 @@ typedef struct _param /* get_func/set_func calls for special parameters */ -static void map_button(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); -static void map_wheels(Display *dpy, XDevice *dev, param_t* param, int argc, char **argv); +static void map_actions(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); static void set_mode(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); static void get_mode(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); static void get_button(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); @@ -127,7 +126,7 @@ static param_t parameters[] = .name = Button, .desc = X11 event to which the given button should be mapped. , .prop_name = WACOM_PROP_BUTTON_ACTIONS, - .set_func = map_button, + .set_func = map_actions, .get_func = get_button, }, { @@ -259,7 +258,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_WHEELBUTTONS, .prop_format = 8, .prop_offset = 0, - .set_func = map_wheels, + .set_func = map_actions, }, { .name = RelWheelDown, @@ -267,7 +266,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_WHEELBUTTONS, .prop_format = 8, .prop_offset = 1, - .set_func = map_wheels, + .set_func = map_actions, }, { .name = AbsWheelUp, @@ -275,7 +274,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_WHEELBUTTONS, .prop_format = 8, .prop_offset = 2, - .set_func = map_wheels, + .set_func = map_actions, }, { .name = AbsWheelDown, @@ -283,7 +282,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_WHEELBUTTONS, .prop_format = 8, .prop_offset = 3, - .set_func = map_wheels, + .set_func = map_actions, }, { .name = StripLeftUp, @@ -291,7 +290,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_STRIPBUTTONS, .prop_format = 8, .prop_offset = 0, - .set_func = map_wheels, + .set_func = map_actions, }, { .name = StripLeftDown, @@ -299,7 +298,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_STRIPBUTTONS, .prop_format = 8, .prop_offset = 1, - .set_func = map_wheels, + .set_func = map_actions, }, { .name = StripRightUp, @@ -307,7 +306,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_STRIPBUTTONS, .prop_format = 8, .prop_offset = 2, - .set_func = map_wheels, + .set_func = map_actions, }, { .name = StripRightDown, @@ -315,7 +314,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_STRIPBUTTONS, .prop_format = 8, .prop_offset = 3, - .set_func = map_wheels, + .set_func = map_actions, }, { .name = Threshold, @@ -1280,49 +1279,56 @@ static void special_map_property(Display *dpy, XDevice *dev, Atom btnact_prop, i XFlush(dpy); } -static void map_wheels(Display *dpy, XDevice *dev, param_t* param, int argc, char **argv) -{ - Atom wheel_prop; - - if (argc = 0) - return; - - TRACE(Mapping wheel %s for device %ld.\n, param-name, dev-device_id); - - wheel_prop = XInternAtom(dpy, param-prop_name, True); - if (!wheel_prop) - return; - - TRACE(Wheel property %s (%ld)\n, param-prop_name, wheel_prop); - - special_map_property(dpy, dev, wheel_prop, param-prop_offset, argc, argv); -} - -/* - Supports two variations, simple mapping and special mapping: - xsetwacom set device Button 1 1 - - maps button 1 to
[Linuxwacom-devel] [PATCH 9v2/9] Revamp button/wheel/strip getters
'get_map' is the new getter entrypoint and attempts to determine the mapping present on buttons, wheels, and strips. It calls on 'get_actions' (essentially get_special_button_map) and 'get_button' (an 8-bit XA_INTEGER version of the same) to determine this. If both fail to find a mapping, it falls back to the method originally used for non-actions: punt and ask XGetDeviceButtonMapping for something. When raw buttons are removed from the driver, it should be possible to replace 'get_map' with 'get_actions' (since everything will be an action at that point). Signed-off-by: Jason Gerecke killert...@gmail.com --- Changes since v1: * Use strcmp instead of == * Change comment style tools/xsetwacom.c | 188 +++-- 1 files changed, 140 insertions(+), 48 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 18155aa..41e4ced 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -101,7 +101,7 @@ typedef struct _param static void map_actions(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); static void set_mode(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); static void get_mode(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); -static void get_button(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); +static void get_map(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); static void set_rotate(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); static void get_rotate(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); static void set_xydefault(Display *dpy, XDevice *dev, param_t *param, int argc, char **argv); @@ -127,7 +127,7 @@ static param_t parameters[] = .desc = X11 event to which the given button should be mapped. , .prop_name = WACOM_PROP_BUTTON_ACTIONS, .set_func = map_actions, - .get_func = get_button, + .get_func = get_map, }, { .name = ToolDebugLevel, @@ -259,6 +259,7 @@ static param_t parameters[] = .prop_format = 8, .prop_offset = 0, .set_func = map_actions, + .get_func = get_map, }, { .name = RelWheelDown, @@ -267,6 +268,7 @@ static param_t parameters[] = .prop_format = 8, .prop_offset = 1, .set_func = map_actions, + .get_func = get_map, }, { .name = AbsWheelUp, @@ -275,6 +277,7 @@ static param_t parameters[] = .prop_format = 8, .prop_offset = 2, .set_func = map_actions, + .get_func = get_map, }, { .name = AbsWheelDown, @@ -283,6 +286,7 @@ static param_t parameters[] = .prop_format = 8, .prop_offset = 3, .set_func = map_actions, + .get_func = get_map, }, { .name = StripLeftUp, @@ -291,6 +295,7 @@ static param_t parameters[] = .prop_format = 8, .prop_offset = 0, .set_func = map_actions, + .get_func = get_map, }, { .name = StripLeftDown, @@ -299,6 +304,7 @@ static param_t parameters[] = .prop_format = 8, .prop_offset = 1, .set_func = map_actions, + .get_func = get_map, }, { .name = StripRightUp, @@ -307,6 +313,7 @@ static param_t parameters[] = .prop_format = 8, .prop_offset = 2, .set_func = map_actions, + .get_func = get_map, }, { .name = StripRightDown, @@ -315,6 +322,7 @@ static param_t parameters[] = .prop_format = 8, .prop_offset = 3, .set_func = map_actions, + .get_func = get_map, }, { .name = Threshold, @@ -1691,50 +1699,57 @@ static void get_rotate(Display *dpy, XDevice *dev, param_t* param, int argc, cha return; } -static int get_special_button_map(Display *dpy, XDevice *dev, - param_t *param, int btn_no) +/** + * Try to print the value of the action mapped to the given parameter's + * property. If the property contains data in the wrong format/type then + * nothing will be printed. + * + * @param dpyX11 display to connect to + * @param devDevice to query + * @param param Info about parameter to query + * @param offset Offset into property specified in param + * @return 0 on failure, 1 otherwise + */ +static int get_actions(Display *dpy, XDevice *dev, + param_t *param, int offset) { - Atom btnact_prop, action_prop; - unsigned long
Re: [Linuxwacom-devel] [PATCH 1/9] Fix buttons must be set twice bug from d650b139
Hi I join the discussion, because I have to deal with Array of Atom constructs also for my OLED Images. 2011/3/30 Peter Hutterer peter.hutte...@who-t.net: applied, but from a cursory glance I'm not sure why. In fact, I would have guessed the other way round. anyway, I've added a comment to avoid this in the future (at least until we find the reason why and fixed it). How about that: When XChangeDeviceProperty(dpy, dev, btnact_prop, ...) is called for the first time with a fresh Action, IMHO the following chall chain is to be observed for the new Atom in the array of Atoms: wcmXCommand.c: wcmSetProperty = wcmSetPropertyButtonActions = wcmCheckActionProp = XIGetDeviceProperty(fresh Action) = BadValue which means that the wcmUpdateActionPropHandlers is not called. Since priv-btn_actions is then not up-to-date, setting the actual action value will not be noticed. This is just based on speculation, not gdb usage. Cheers, Eduard -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
[Linuxwacom-devel] [PATCH 7/7] Fix get_map to return proper wheel/strip button number
Adding to the only-kinda-hackish use of XGetDeviceButtonMapping, in get_map, this total hackjob of a patch fixes the problem with us having no way of knowing the driver's defaults for wheels and strips. Thankfully, the defaults aren't changing anytime soon so its not likely to break. Additionally, once the raw button path is removed from the driver, the entire 'get_map' function can go the way of the dodo. Signed-off-by: Jason Gerecke killert...@gmail.com --- tools/xsetwacom.c | 36 1 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 38002cb..1c0f43f 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1884,22 +1884,34 @@ static void get_map(Display *dpy, XDevice *dev, param_t *param, int argc, char** else if (get_button(dpy, dev, param, offset)) return; else - { - int nmap = 256; - unsigned char map[nmap]; + { /* FIXME: Ugly hack because there's no way to get default buttons */ + if (strcmp(param-prop_name, WACOM_PROP_BUTTON_ACTIONS) == 0) + { + int nmap = 256; + unsigned char map[nmap]; - nmap = XGetDeviceButtonMapping(dpy, dev, map, nmap); + nmap = XGetDeviceButtonMapping(dpy, dev, map, nmap); - if (offset = nmap) - { - fprintf(stderr, Button number does not exist on device.\n); - return; - } + if (offset = nmap) + { + fprintf(stderr, Button number does not exist on device.\n); + return; + } - print_value(param, %d, map[offset]); + print_value(param, %d, map[offset]); - XSetDeviceButtonMapping(dpy, dev, map, nmap); - XFlush(dpy); + XSetDeviceButtonMapping(dpy, dev, map, nmap); + XFlush(dpy); + } + else + { + switch (offset) { + case 0: print_value(param, 4); break; + case 1: print_value(param, 5); break; + case 2: print_value(param, 4); break; + case 3: print_value(param, 5); break; + } + } } } -- 1.7.4.1 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
[Linuxwacom-devel] [PATCH 0/7] Patchset summary
Patches 1-4 improve argument validation and make xsetwacom noiser when it fails. Patches 5-7 finish up the remaining raw button removal from xsetwacom. Jason Gerecke (7): Fail with warnings where possible More explicit input check for set_rotate Change from prop_extra to arg_count More strict argument-count checking Decrease minimum number of args to 'set' [allow wheels/strips reset] Have wheel and strip properties be actions instead of buttons Fix get_map to return proper wheel/strip button number src/wcmXCommand.c | 28 +++ tools/xsetwacom.c | 245 - 2 files changed, 141 insertions(+), 132 deletions(-) -- 1.7.4.1 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
[Linuxwacom-devel] [PATCH 1/7] Fail with warnings where possible
For many commands, improper arguments cause a silent failure. The user is often given no indication if their command succeeded or failed. I've tried to find all the silent return; statements and provide some kind of warning message where possible. In some cases I've added in new checks to ensure that we have the correct number of arguments. I've tried to make checks as pedantic as possible, e.g. throwing errors about number of arguments even if the function ignores arguments. Signed-off-by: Jason Gerecke killert...@gmail.com --- tools/xsetwacom.c | 31 +++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 41e4ced..337aa88 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1234,7 +1234,10 @@ static void special_map_property(Display *dpy, XDevice *dev, Atom btnact_prop, i bytes_after, (unsigned char**)btnact_data); if (offset btnact_nitems) + { + fprintf(stderr, Invalid offset into %s property.\n, XGetAtomName(dpy, btnact_prop)); return; + } if (format == 8 type == XA_INTEGER) { @@ -1242,7 +1245,10 @@ static void special_map_property(Display *dpy, XDevice *dev, Atom btnact_prop, i * mappings. Convert to 32 bit Atom actions first. */ if (convert_wheel_prop(dpy, dev, btnact_prop)) + { + fprintf(stderr, Error creating wheel action.\n); return; + } XGetDeviceProperty(dpy, dev, btnact_prop, 0, 100, False, AnyPropertyType, type, format, @@ -1347,6 +1353,12 @@ static void set_xydefault(Display *dpy, XDevice *dev, param_t* param, int argc, unsigned long nitems, bytes_after; long *ldata; + if (argc != 0) + { + fprintf(stderr, Incorrect number of arguments supplied.\n); + return; + } + prop = XInternAtom(dpy, param-prop_name, True); if (!prop) { @@ -1632,7 +1644,10 @@ static void get_mode(Display *dpy, XDevice *dev, param_t* param, int argc, char } if (!ndevices) /* device id 0 is reserved and can't be our device */ + { + fprintf(stderr, Unable to locate device.\n); return; + } TRACE(Getting mode for device %ld.\n, dev-device_id); @@ -1658,6 +1673,12 @@ static void get_rotate(Display *dpy, XDevice *dev, param_t* param, int argc, cha unsigned char* data; unsigned long nitems, bytes_after; + if (argc != 0) + { + fprintf(stderr, Incorrect number of arguments supplied.\n); + return; + } + prop = XInternAtom(dpy, param-prop_name, True); if (!prop) { @@ -1937,7 +1958,11 @@ static void _set_matrix_prop(Display *dpy, XDevice *dev, const float fmatrix[9]) bytes_after, (unsigned char**)data); if (format != 32 || type != XInternAtom(dpy, FLOAT, True)) + { + fprintf(stderr, Property for '%s' has unexpected type - this is a bug.\n, + Coordinate Transformation Matrix); return; + } XChangeDeviceProperty(dpy, dev, matrix_prop, type, format, PropModeReplace, (unsigned char*)matrix, 9); @@ -1954,6 +1979,12 @@ static void set_output(Display *dpy, XDevice *dev, param_t *param, int argc, cha XRROutputInfo *output_info; XRRCrtcInfo *crtc_info; + if (argc != 1) + { + fprintf(stderr, Incorrect number of arguments supplied.\n); + return; + } + output_name = argv[0]; if (!XRRQueryExtension(dpy, maj, min)) /* using min/maj as dummy */ -- 1.7.4.1 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
[Linuxwacom-devel] [PATCH 4/7] More strict argument-count checking
Add/replace checks in functions to ensure that they have the right number of arguments to do their job properly. The worst offender here was the set() function -- providing too many arguments would result in it walking off the end of data structures (often resulting in a segfault) Signed-off-by: Jason Gerecke killert...@gmail.com --- tools/xsetwacom.c | 60 +++- 1 files changed, 36 insertions(+), 24 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index ae35996..d99a671 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1349,14 +1349,14 @@ static void map_actions(Display *dpy, XDevice *dev, param_t* param, int argc, ch return; } - if (strcmp(param-prop_name, WACOM_PROP_BUTTON_ACTIONS) == 0) + if (argc param-arg_count) { - if (argc == 0) - { - fprintf(stderr, Too few arguments provided.\n); - return; - } + fprintf(stderr, Too few arguments provided.\n); + return; + } + if (strcmp(param-prop_name, WACOM_PROP_BUTTON_ACTIONS) == 0) + { if (sscanf(argv[0], %d, offset) != 1) { fprintf(stderr, '%s' is not a valid button number.\n, argv[0]); @@ -1379,9 +1379,10 @@ static void set_xydefault(Display *dpy, XDevice *dev, param_t* param, int argc, unsigned long nitems, bytes_after; long *ldata; - if (argc != 0) + if (argc != param-arg_count) { - fprintf(stderr, Incorrect number of arguments supplied.\n); + fprintf(stderr, '%s' requires exactly %d value(s).\n, param-name, + param-arg_count); return; } @@ -1418,9 +1419,11 @@ out: static void set_mode(Display *dpy, XDevice *dev, param_t* param, int argc, char **argv) { int mode = Absolute; - if (argc 1) + + if (argc != param-arg_count) { - usage(); + fprintf(stderr, '%s' requires exactly %d value(s).\n, param-name, + param-arg_count); return; } @@ -1449,8 +1452,12 @@ static void set_rotate(Display *dpy, XDevice *dev, param_t* param, int argc, cha unsigned char* data; unsigned long nitems, bytes_after; - if (argc != 1) - goto error; + if (argc != param-arg_count) + { + fprintf(stderr, '%s' requires exactly %d value(s).\n, param-name, + param-arg_count); + return; + } TRACE(Rotate '%s' for device %ld.\n, argv[0], dev-device_id); @@ -1493,10 +1500,6 @@ static void set_rotate(Display *dpy, XDevice *dev, param_t* param, int argc, cha XFlush(dpy); return; - -error: - fprintf(stderr, Usage: xsetwacom device name Rotate [none | cw | ccw | half]\n); - return; } @@ -1607,6 +1610,13 @@ static void set(Display *dpy, int argc, char **argv) values = strjoinsplit(argc - 2, argv[2], nvals); + if (nvals != param-arg_count) + { + fprintf(stderr, '%s' requires exactly %d value(s).\n, param-name, + param-arg_count); + goto out; + } + for (i = 0; i nvals; i++) { Bool success; @@ -1914,14 +1924,15 @@ static void get_map(Display *dpy, XDevice *dev, param_t *param, int argc, char** TRACE(Getting button map for device %ld.\n, dev-device_id); - if (strcmp(param-prop_name, WACOM_PROP_BUTTON_ACTIONS) == 0) + if (argc != param-arg_count) { - if (argc == 0) - { - fprintf(stderr, Too few arguments provided.\n); - return; - } + fprintf(stderr, '%s' requires exactly %d value(s).\n, param-name, + param-arg_count); + return; + } + if (strcmp(param-prop_name, WACOM_PROP_BUTTON_ACTIONS) == 0) + { if (sscanf(argv[0], %d, offset) != 1) { fprintf(stderr, '%s' is not a valid button number.\n, argv[0]); @@ -2005,9 +2016,10 @@ static void set_output(Display *dpy, XDevice *dev, param_t *param, int argc, cha XRROutputInfo *output_info; XRRCrtcInfo *crtc_info; - if (argc != 1) + if (argc != param-arg_count) { - fprintf(stderr, Incorrect number of arguments supplied.\n); + fprintf(stderr, '%s' requires exactly %d value(s).\n, param-name, + param-arg_count); return; } -- 1.7.4.1 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself;
[Linuxwacom-devel] [PATCH 5/7] Decrease minimum number of args to 'set' [allow wheels/strips reset]
Since the worker functions now check that they have the appropriate number of arguments, its possible to decrease the number of arguments required by 'set'. Since all it really needs is a device number and a property, the minimum argc is now 2. A handy side-effect of this change is that its now possible to run e.g. `xsetwacom --set $ID StripLeftDown` to reset the action to its default. Doing the same with buttons has been supported, but wheels and strips were out of luck because they would require too few arguments to 'set'. Signed-off-by: Jason Gerecke killert...@gmail.com --- tools/xsetwacom.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index d99a671..59b0cb1 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1554,7 +1554,7 @@ static void set(Display *dpy, int argc, char **argv) char **values; int nvals; - if (argc 3) + if (argc 2) { usage(); return; -- 1.7.4.1 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
[Linuxwacom-devel] [PATCH 6/7] Have wheel and strip properties be actions instead of buttons
Continuing with removing raw button code, we create the wheel and strip properties ready to hold actions. Prior to this, the properties would be initialized with the raw buttons; before xsetwacom could set them to actions they would need to be converted. This does away with the conversion step by following the mold already in place for buttons. With no more need for conversion, we can also nuke the conversion-related bits from xsetwacom. Signed-off-by: Jason Gerecke killert...@gmail.com --- src/wcmXCommand.c | 28 tools/xsetwacom.c | 74 +++-- 2 files changed, 15 insertions(+), 87 deletions(-) diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c index 64ebb8d..f1228b2 100644 --- a/src/wcmXCommand.c +++ b/src/wcmXCommand.c @@ -165,23 +165,6 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo) values[3] = priv-serial; prop_serials = InitWcmAtom(pInfo-dev, WACOM_PROP_SERIALIDS, 32, 4, values); - if (IsPad(priv)) { - values[0] = priv-striplup; - values[1] = priv-stripldn; - values[2] = priv-striprup; - values[3] = priv-striprdn; - prop_strip_buttons = InitWcmAtom(pInfo-dev, WACOM_PROP_STRIPBUTTONS, 8, 4, values); - } - - if (IsPad(priv) || IsCursor(priv)) - { - values[0] = priv-relup; - values[1] = priv-reldn; - values[2] = priv-wheelup; - values[3] = priv-wheeldn; - prop_wheel_buttons = InitWcmAtom(pInfo-dev, WACOM_PROP_WHEELBUTTONS, 8, 4, values); - } - if (IsCursor(priv)) { values[0] = common-wcmCursorProxoutDist; prop_cursorprox = InitWcmAtom(pInfo-dev, WACOM_PROP_PROXIMITY_THRESHOLD, 32, 1, values); @@ -220,6 +203,17 @@ void InitWcmDeviceProperties(InputInfoPtr pInfo) memset(values, 0, sizeof(values)); prop_btnactions = InitWcmAtom(pInfo-dev, WACOM_PROP_BUTTON_ACTIONS, -32, WCM_MAX_MOUSE_BUTTONS, values); + if (IsPad(priv)) { + memset(values, 0, sizeof(values)); + prop_strip_buttons = InitWcmAtom(pInfo-dev, WACOM_PROP_STRIPBUTTONS, -32, 4, values); + } + + if (IsPad(priv) || IsCursor(priv)) + { + memset(values, 0, sizeof(values)); + prop_wheel_buttons = InitWcmAtom(pInfo-dev, WACOM_PROP_WHEELBUTTONS, -32, 4, values); + } + #ifdef DEBUG values[0] = priv-debugLevel; values[1] = common-debugLevel; diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 59b0cb1..38002cb 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1093,62 +1093,6 @@ static char** strjoinsplit(int argc, char **argv, int *nwords) return words; } -static const char *wheel_act_prop[] = { - Wacom Rel Wheel Up Action, - Wacom Rel Wheel Down Action, - Wacom Abs Wheel Up Action, - Wacom Abs Wheel Down Action, -}; - -/** - * Convert the given property from an 8 bit integer property into an action - * atom property. In the default case, this means that a property with - * values 4 5 4 5 ends up to have the values - * Wacom RHU Action Wacom RHW Action Wacom AWU Action Wacom AWD - * Action - * with each of the properties having : - * AC_BUTTON | AC_KEYBTNPRESS | 4 (or 5) - * AC_BUTTON | 4 (or 5) - * - * return 0 on success or 1 on failure. - */ -static int convert_wheel_prop(Display *dpy, XDevice *dev, Atom btnact_prop) -{ - int i; - Atom type; - int format; - unsigned long btnact_nitems, bytes_after; - unsigned char *btnact_data; /* current values (button mappings) */ - unsigned long *btnact_new_data; /* new values (action atoms) */ - - XGetDeviceProperty(dpy, dev, btnact_prop, 0, 100, False, - AnyPropertyType, type, format, btnact_nitems, - bytes_after, (unsigned char**)btnact_data); - - btnact_new_data = calloc(btnact_nitems, sizeof(Atom)); - if (!btnact_new_data) - return 1; - - for (i = 0; i btnact_nitems; i++) { - unsigned long action_data[2]; - Atom prop = XInternAtom(dpy, wheel_act_prop[i], False); - - action_data[0] = AC_BUTTON | AC_KEYBTNPRESS | btnact_data[i]; - action_data[1] = AC_BUTTON | btnact_data[i]; - - XChangeDeviceProperty(dpy, dev, prop, XA_INTEGER, 32, - PropModeReplace, - (unsigned char*)action_data, 2); - - btnact_new_data[i] = prop; - } - - XChangeDeviceProperty(dpy, dev, btnact_prop, XA_ATOM, 32, - PropModeReplace, - (unsigned char*)btnact_new_data, btnact_nitems); - return 0; -} - /** * This function parses the given strings to produce a list of actions that * the driver can carry out. We
[Linuxwacom-devel] [PATCH 1/3] Check predefined serial number as early as we can
Don't wait before we can post the events. Verify the serial number as soon as the information is accessible. Signed-off-by: Ping Cheng pingli...@gmail.com --- src/wcmCommon.c | 16 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 338bc9a..106b741 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -662,14 +662,6 @@ void wcmSendEvents(InputInfoPtr pInfo, const WacomDeviceState* ds) int v3, v4, v5; int valuators[priv-naxes]; - if (priv-serial serial != priv-serial) - { - DBG(10, priv, serial number -is %u but your system configured %u, - serial, (int)priv-serial); - return; - } - /* don't move the cursor when going out-prox */ if (!ds-proximity) { @@ -1138,6 +1130,14 @@ static void commonDispatchDevice(WacomCommonPtr common, unsigned int channel, /* Device transformations come first */ priv = pInfo-private; + if (priv-serial filtered.serial_num != priv-serial) + { + DBG(10, priv, serial number +is %u but your system configured %u, + filtered.serial_num, priv-serial); + return; + } + /* send a touch out for USB Tablet PCs */ if (IsUSBDevice(common) !IsTouch(priv) common-wcmTouchDefault !priv-oldProximity) -- 1.7.4 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
[Linuxwacom-devel] [PATCH 2/3] Add IsPen to cover both IsStylus and IsEraser
It will be used more often when we need to compare touch events with pen events. Signed-off-by: Ping Cheng pingli...@gmail.com --- src/wcmCommon.c |2 +- src/xf86WacomDefs.h |2 ++ 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 106b741..a370389 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -1164,7 +1164,7 @@ static void commonDispatchDevice(WacomCommonPtr common, unsigned int channel, } } - if (IsStylus(priv) || IsEraser(priv)) + if (IsPen(priv)) { priv-minPressure = rebasePressure(priv, filtered); filtered.pressure = normalizePressure(priv, filtered); diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h index 7740820..43348fc 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -184,6 +184,8 @@ struct _WacomModel #define IsTouch(priv) (DEVICE_ID((priv)-flags) == TOUCH_ID) #define IsEraser(priv) (DEVICE_ID((priv)-flags) == ERASER_ID) #define IsPad(priv)(DEVICE_ID((priv)-flags) == PAD_ID) +#define IsPen(priv)((DEVICE_ID((priv)-flags) == STYLUS_ID) || \ + (DEVICE_ID((priv)-flags) == ERASER_ID)) #define IsUSBDevice(common) ((common)-wcmDevCls == gWacomUSBDevice) -- 1.7.4 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH 1/3] Check predefined serial number as early as we can
On Wed, Mar 30, 2011 at 04:24:15PM -0700, Ping Cheng wrote: Don't wait before we can post the events. Verify the serial number as soon as the information is accessible. Signed-off-by: Ping Cheng pingli...@gmail.com --- src/wcmCommon.c | 16 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 338bc9a..106b741 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -662,14 +662,6 @@ void wcmSendEvents(InputInfoPtr pInfo, const WacomDeviceState* ds) int v3, v4, v5; int valuators[priv-naxes]; - if (priv-serial serial != priv-serial) - { - DBG(10, priv, serial number - is %u but your system configured %u, - serial, (int)priv-serial); - return; - } - /* don't move the cursor when going out-prox */ if (!ds-proximity) { @@ -1138,6 +1130,14 @@ static void commonDispatchDevice(WacomCommonPtr common, unsigned int channel, /* Device transformations come first */ priv = pInfo-private; + if (priv-serial filtered.serial_num != priv-serial) + { + DBG(10, priv, serial number + is %u but your system configured %u, + filtered.serial_num, priv-serial); + return; + } + /* send a touch out for USB Tablet PCs */ if (IsUSBDevice(common) !IsTouch(priv) common-wcmTouchDefault !priv-oldProximity) -- 1.7.4 merged, thanks. Cheers, Peter -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH 2/3] Add IsPen to cover both IsStylus and IsEraser
On Wed, Mar 30, 2011 at 04:24:43PM -0700, Ping Cheng wrote: It will be used more often when we need to compare touch events with pen events. Signed-off-by: Ping Cheng pingli...@gmail.com --- src/wcmCommon.c |2 +- src/xf86WacomDefs.h |2 ++ 2 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/wcmCommon.c b/src/wcmCommon.c index 106b741..a370389 100644 --- a/src/wcmCommon.c +++ b/src/wcmCommon.c @@ -1164,7 +1164,7 @@ static void commonDispatchDevice(WacomCommonPtr common, unsigned int channel, } } - if (IsStylus(priv) || IsEraser(priv)) + if (IsPen(priv)) { priv-minPressure = rebasePressure(priv, filtered); filtered.pressure = normalizePressure(priv, filtered); diff --git a/src/xf86WacomDefs.h b/src/xf86WacomDefs.h index 7740820..43348fc 100644 --- a/src/xf86WacomDefs.h +++ b/src/xf86WacomDefs.h @@ -184,6 +184,8 @@ struct _WacomModel #define IsTouch(priv) (DEVICE_ID((priv)-flags) == TOUCH_ID) #define IsEraser(priv) (DEVICE_ID((priv)-flags) == ERASER_ID) #define IsPad(priv)(DEVICE_ID((priv)-flags) == PAD_ID) +#define IsPen(priv)((DEVICE_ID((priv)-flags) == STYLUS_ID) || \ + (DEVICE_ID((priv)-flags) == ERASER_ID)) this should probably use IsStylus() || IsEraser() instead of duplicating the check Cheers, Peter #define IsUSBDevice(common) ((common)-wcmDevCls == gWacomUSBDevice) -- 1.7.4 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH 3/7] Change from prop_extra to arg_count
On Wed, Mar 30, 2011 at 01:54:43PM -0700, Jason Gerecke wrote: When setting an XInternAtom property, 'prop_extra' listed the number of extra properties beyond the first that needed to be set. For instance WACOM_PROP_TABLET_AREA had a total of 4 properties, so prop_extra=3. To provide better argument validation though, we change this to 'arg_count' and list the total number of arguments expected. This doesn't really do anything for normal properties (since arg_count = prop_extra + 1), but does let us check for the proper number of arguments in odd cases (e.g. ResetArea takes 0 arguments). Signed-off-by: Jason Gerecke killert...@gmail.com --- tools/xsetwacom.c | 40 +--- 1 files changed, 33 insertions(+), 7 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 4194781..ae35996 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -86,7 +86,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 int arg_count; /* extra number of items after first one */ I've updated the comment here. merged otherwise. Cheers, Peter 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 */ @@ -120,12 +120,13 @@ static param_t parameters[] = .prop_name = WACOM_PROP_TABLET_AREA, .prop_format = 32, .prop_offset = 0, - .prop_extra = 3 + .arg_count = 4, }, { .name = Button, .desc = X11 event to which the given button should be mapped. , .prop_name = WACOM_PROP_BUTTON_ACTIONS, + .arg_count = 1, .set_func = map_actions, .get_func = get_map, }, @@ -136,6 +137,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_DEBUGLEVELS, .prop_format = 8, .prop_offset = 0, + .arg_count = 1, }, { .name = TabletDebugLevel, @@ -145,6 +147,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_DEBUGLEVELS, .prop_format = 8, .prop_offset = 1, + .arg_count = 1, }, { .name = Suppress, @@ -152,6 +155,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_SAMPLE, .prop_format = 32, .prop_offset = 0, + .arg_count = 1, }, { .name = RawSample, @@ -160,6 +164,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_SAMPLE, .prop_format = 32, .prop_offset = 1, + .arg_count = 1, }, { .name = PressureCurve, @@ -167,11 +172,12 @@ static param_t parameters[] = .prop_name = WACOM_PROP_PRESSURECURVE, .prop_format = 32, .prop_offset = 0, - .prop_extra = 3, + .arg_count = 4, }, { .name = Mode, .desc = Switches cursor movement mode (default is absolute). , + .arg_count = 1, .set_func = set_mode, .get_func = get_mode, }, @@ -183,6 +189,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_HOVER, .prop_format = 8, .prop_offset = 0, + .arg_count = 1, .prop_flags = PROP_FLAG_BOOLEAN }, { @@ -191,6 +198,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_TOUCH, .prop_format = 8, .prop_offset = 0, + .arg_count = 1, .prop_flags = PROP_FLAG_BOOLEAN }, { @@ -200,6 +208,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_ENABLE_GESTURE, .prop_format = 8, .prop_offset = 0, + .arg_count = 1, .prop_flags = PROP_FLAG_BOOLEAN }, { @@ -209,6 +218,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_GESTURE_PARAMETERS, .prop_format = 32, .prop_offset = 0, + .arg_count = 1, }, { .name = ScrollDistance, @@ -217,6 +227,7 @@ static param_t parameters[] = .prop_name = WACOM_PROP_GESTURE_PARAMETERS, .prop_format = 32, .prop_offset = 1, + .arg_count = 1, }, {
Re: [Linuxwacom-devel] [PATCH 5/7] Decrease minimum number of args to 'set' [allow wheels/strips reset]
On Wed, Mar 30, 2011 at 01:54:45PM -0700, Jason Gerecke wrote: Since the worker functions now check that they have the appropriate number of arguments, its possible to decrease the number of arguments required by 'set'. Since all it really needs is a device number and a property, the minimum argc is now 2. A handy side-effect of this change is that its now possible to run e.g. `xsetwacom --set $ID StripLeftDown` to reset the action to its default. is that because we delete the property then so it falls back to using the button mapping? this formulation is a bit unfortunate, since it doesn't actually set to the default. if I map the button to say 8, then run the above command it would revert back to 8, not to the default (4 or whatever it is), right? Cheers, Peter Doing the same with buttons has been supported, but wheels and strips were out of luck because they would require too few arguments to 'set'. Signed-off-by: Jason Gerecke killert...@gmail.com --- tools/xsetwacom.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index d99a671..59b0cb1 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1554,7 +1554,7 @@ static void set(Display *dpy, int argc, char **argv) char **values; int nvals; - if (argc 3) + if (argc 2) { usage(); return; -- 1.7.4.1 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [RFC] wdaemon on linuxwacom.sf.net
Hi Peter, That sounds reasonable to me given that we are still linking to Aris' repository in the mediawiki's Linuxwacom HOWTO and FAQ: http://sourceforge.net/apps/mediawiki/linuxwacom/index.php?title=Linuxwacom_HOWTO#Hotplugging_the_device Favux -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel
Re: [Linuxwacom-devel] [PATCH 7/7] Fix get_map to return proper wheel/strip button number
On Wed, Mar 30, 2011 at 01:54:47PM -0700, Jason Gerecke wrote: Adding to the only-kinda-hackish use of XGetDeviceButtonMapping, in get_map, this total hackjob of a patch fixes the problem with us having no way of knowing the driver's defaults for wheels and strips. Thankfully, the defaults aren't changing anytime soon so its not likely to break. Additionally, once the raw button path is removed from the driver, the entire 'get_map' function can go the way of the dodo. This seems to solve the wrong problem. How about we decide that xsetwacom controls the physical buttons on the device? That way, anyone wanting to configure logical mapping can use the X tools and xsetwacom is driver-specific and stays (documented so!) driver-specific. which of course also means we need to check that the Button xorg.conf option does the right thing. --- tools/xsetwacom.c | 36 1 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index 38002cb..1c0f43f 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1884,22 +1884,34 @@ static void get_map(Display *dpy, XDevice *dev, param_t *param, int argc, char** else if (get_button(dpy, dev, param, offset)) return; else - { - int nmap = 256; - unsigned char map[nmap]; + { /* FIXME: Ugly hack because there's no way to get default buttons */ + if (strcmp(param-prop_name, WACOM_PROP_BUTTON_ACTIONS) == 0) + { + int nmap = 256; + unsigned char map[nmap]; - nmap = XGetDeviceButtonMapping(dpy, dev, map, nmap); + nmap = XGetDeviceButtonMapping(dpy, dev, map, nmap); - if (offset = nmap) - { - fprintf(stderr, Button number does not exist on device.\n); - return; - } + if (offset = nmap) + { + fprintf(stderr, Button number does not exist on device.\n); + return; + } - print_value(param, %d, map[offset]); + print_value(param, %d, map[offset]); - XSetDeviceButtonMapping(dpy, dev, map, nmap); - XFlush(dpy); + XSetDeviceButtonMapping(dpy, dev, map, nmap); I didn't pick this up in 155a4b9 but I don't think the XSetDeviceButtonMapping actually does anything here. Not sure why it's there, looks like a copy paste error (4d2c3d19dce4). Cheers, Peter + XFlush(dpy); + } + else + { + switch (offset) { + case 0: print_value(param, 4); break; + case 1: print_value(param, 5); break; + case 2: print_value(param, 4); break; + case 3: print_value(param, 5); break; + } + } } } -- 1.7.4.1 -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel