If argv contains only a single numeric argument, we assume the
intent is to perform a button press. We add the necessary keywords
to make the parser happy, and then parse as normal.

This allows map_wheels to handle the "raw button" case that it has
been missing. While map_button_simple also does the same* thing,
that's another commit :)

*Actually, map_button_simple does /almost/ the same thing, but I
highly doubt anyone relies on the subtle difference in behavior.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 tools/xsetwacom.c |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index f545f95..7eb95d7 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1133,13 +1133,30 @@ static int convert_wheel_prop(Display *dpy, XDevice 
*dev, Atom btnact_prop)
  */
 static Bool parse_actions(Display *dpy, int argc, char **argv, unsigned long* 
data, unsigned long *nitems)
 {
-       int  i;
+       int  i = 0;
        int  nwords = 0;
        char **words = NULL;
 
        /* translate cmdline commands */
        words = strjoinsplit(argc, argv, &nwords);
 
+       if (nwords==1 && sscanf(words[0], "%d", &i) == 1)
+       { //Mangle "simple" button maps into proper actions
+               char **new_words = realloc(words, 2);
+               if (new_words == NULL)
+               {
+                       fprintf(stderr, "Unable to reallocate memory.\n");
+                       return False;
+               }
+
+               sprintf(new_words[0], "+%d", i);
+               new_words[1] = new_words[0];
+               new_words[0] = "button";
+
+               words  = new_words;
+               nwords = 2;
+       }
+
        for (i = 0; i < nwords; i++)
        {
                int j = 0;
@@ -1284,10 +1301,6 @@ static void map_wheels(Display *dpy, XDevice *dev, 
param_t* param, int argc, cha
 
        TRACE("Mapping wheel %s for device %ld.\n", param->name, 
dev->device_id);
 
-       /* FIXME:
-          if value is simple number, change back to 8 bit integer
-        */
-
        special_map_wheels(dpy, dev, param, argc, argv);
 }
 
-- 
1.7.4.1


------------------------------------------------------------------------------
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