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

Reply via email to