diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-10-27 09:25:29 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-05-20 14:28:57 +1000 |
commit | fc9042441abce778fc6931b325ef87145a66fa28 (patch) | |
tree | 60f2f07f1b89592df0fcdb3fd68dff6c2da16abc | |
parent | 05fe92c71bfd7d95476cc35d66924f2cfc5e18ae (diff) | |
download | xf86-input-wacom-fc9042441abce778fc6931b325ef87145a66fa28.tar.gz |
xsetwacom: handle special button mappings.
As with keystrokes, this handles usecases like
"button +5 4 -5" for a button 5 down, button 4 click, button 5 up.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Ping Cheng <pinglinux@gmail.com>
Conflicts:
tools/xsetwacom.c
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | tools/xsetwacom.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index ed12f83..9fe75b8 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1164,6 +1164,7 @@ out: return kc; } static int special_map_keystrokes(Display*, int argc, char **argv, unsigned long *ndata, unsigned long* data); +static int special_map_button(Display*, int argc, char **argv, unsigned long *ndata, unsigned long* data); /* Valid keywords for the --set ButtonX options */ struct keywords { @@ -1171,6 +1172,7 @@ struct keywords { int (*func)(Display*, int, char **, unsigned long*, unsigned long *); } keywords[] = { {"key", special_map_keystrokes}, + {"button", special_map_button}, { NULL, NULL } }; @@ -1187,6 +1189,50 @@ static inline int is_valid_keyword(const char *keyword) return 0; } +static int special_map_button(Display* dpy, int argc, char **argv, unsigned long *ndata, unsigned long *data) +{ + int nitems = 0; + int i; + + for (i = 0; i < argc; i++) + { + char *btn = argv[i]; + int button; + int need_press = 0, need_release = 0; + + if (strlen(btn) > 1) + { + if (is_valid_keyword(btn)) + break; + + if (sscanf(btn, "%d", &button) != 1) + return nitems; + + switch (btn[0]) + { + case '+': need_press = 1; break; + case '-': need_release= 1; break; + default: + need_press = need_release = 1; + break; + } + } else + need_press = need_release = 1; + + TRACE("Button map %d [%s,%s]\n", abs(button), + need_press ? "press" : "", + need_release ? "release" : ""); + + if (need_press) + data[*ndata + nitems++] = AC_BUTTON | AC_KEYBTNPRESS | abs(button); + if (need_release) + data[*ndata + nitems++] = AC_BUTTON | abs(button); + } + + *ndata += nitems; + return nitems; +} + /* Map gibberish like "ctrl alt f2" into the matching AC_KEY values. Returns 1 on success or 0 otherwise. |