summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2010-03-25 14:30:33 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-05-20 14:28:57 +1000
commitae200162f7aacc3a28245c3575309ffe556cc551 (patch)
treef187dbf99a29ce9af8c8deebee098e7914afa770 /tools
parentc3cbc31aba1206afc26771574686668a67414c77 (diff)
downloadxf86-input-wacom-ae200162f7aacc3a28245c3575309ffe556cc551.tar.gz
xsetwacom: refacture button mapping code.
This loses the ability do do "xsetwacom --set Button1 button 5" to make Button1 do what button 5 does. Really, just run the command twice... Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Ping Cheng <pinglinux@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/xsetwacom.c64
1 files changed, 26 insertions, 38 deletions
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 73b019a..3551f0f 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1361,39 +1361,12 @@ static void special_map_buttons(Display *dpy, XDevice *dev, param_t* param, int
XFlush(dpy);
}
-/*
- Supports three variations.
- xsetwacom set device Button1 1
- - maps button 1 to logical button 1
- xsetwacom set device Button1 "Button 5"
- - maps button 1 to the same logical button button 5 is mapped
- xsetwacom set device Button1 "key a b c d"
- - maps button 1 to key events a b c d
- */
-static void map_button(Display *dpy, XDevice *dev, param_t* param, int argc, char **argv)
+
+static void map_button_simple(Display *dpy, XDevice *dev, param_t* param, int button)
{
int nmap = 256;
unsigned char map[nmap];
- int i, btn_no = 0;
- int ref_button = -1; /* xsetwacom set <name> Button1 "Button 5" */
-
- if (argc <= 0)
- return;
-
- TRACE("Mapping %s for device %ld.\n", param->name, dev->device_id);
-
- for(i = 0; i < strlen(argv[0]); i++)
- {
- if (!isdigit(argv[0][i]))
- {
- ref_button = get_button_number_from_string(argv[0]);
- if (ref_button != -1)
- break;
-
- special_map_buttons(dpy, dev, param, argc, argv);
- return;
- }
- }
+ int btn_no = 0;
btn_no = get_button_number_from_string(param->name);
if (btn_no == -1)
@@ -1404,19 +1377,34 @@ static void map_button(Display *dpy, XDevice *dev, param_t* param, int argc, cha
{
fprintf(stderr, "Button number does not exist on device.\n");
return;
- } else if (ref_button >= nmap)
- {
- fprintf(stderr, "Reference button number does not exist on device.\n");
- return;
}
- if (ref_button != -1)
- map[btn_no - 1] = map[ref_button - 1];
- else
- map[btn_no - 1] = atoi(argv[0]);
+ map[btn_no - 1] = button;
XSetDeviceButtonMapping(dpy, dev, map, nmap);
XFlush(dpy);
}
+/*
+ Supports three variations.
+ xsetwacom set device Button1 1
+ - maps button 1 to logical button 1
+ xsetwacom set device Button1 "key a b c d"
+ - maps button 1 to key events a b c d
+ */
+static void map_button(Display *dpy, XDevice *dev, param_t* param, int argc, char **argv)
+{
+ int button;
+
+ if (argc <= 0)
+ return;
+
+ TRACE("Mapping %s for device %ld.\n", param->name, dev->device_id);
+
+ /* --set "device" Button1 3 */
+ if (sscanf(argv[0], "%d", &button) == 1)
+ map_button_simple(dpy, dev, param, button);
+ else
+ special_map_buttons(dpy, dev, param, argc, argv);
+}
static void set_xydefault(Display *dpy, XDevice *dev, param_t* param, int argc, char **argv)
{