summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-11-06 16:38:42 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-12-10 14:39:42 +1000
commit08613765c18bc1dc8c14a7e3fed3e95e7f879973 (patch)
tree2cdf4ea3454949fa7cb88053fac16e59eb0d062d
parent1efdc8606b59c90167967b074230c9e2a76c9edf (diff)
downloadxf86-input-wacom-08613765c18bc1dc8c14a7e3fed3e95e7f879973.tar.gz
xsetwacom: Add property hooks for xsetwacom set/get support.
This uses a similar principle as synclient, the option table contains the offsets into the matching properties, these are automatically changed. One exception - some options xsetwacom provides don't map into a concreate property, for these special functions are required (e.g. all the ButtonX options). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/wcmXCommand.c1
-rw-r--r--tools/Makefile.am2
-rw-r--r--tools/xsetwacom.c210
3 files changed, 208 insertions, 5 deletions
diff --git a/src/wcmXCommand.c b/src/wcmXCommand.c
index 0cacb8b..a535548 100644
--- a/src/wcmXCommand.c
+++ b/src/wcmXCommand.c
@@ -317,6 +317,7 @@ int xf86WcmSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
area.bottomX = values[2];
area.bottomY = values[3];
+ /* FIXME: this will always be the case? */
if (xf86WcmAreaListOverlap(&area, priv->tool->arealist))
return BadValue;
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 3132384..5bce44b 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -24,5 +24,5 @@ bin_PROGRAMS = \
INCLUDES=-I$(top_srcdir)/include/
-xsetwacom_LDFLAGS = $(X11_LIBS)
+xsetwacom_LDFLAGS = $(X11_LIBS) -lm
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 4760151..e907387 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -21,12 +21,16 @@
#include "config.h"
#endif
+#include <wacom-properties.h>
+
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
+#include <math.h>
#include <X11/Xlib.h>
+#include <X11/Xatom.h>
#include <X11/extensions/XInput.h>
static int verbose = False;
@@ -35,203 +39,260 @@ typedef struct _param
{
const char *name; /* param name as specified by the user */
const char *desc; /* description */
+ const char *prop_name; /* property name */
+ const int prop_format; /* property format */
+ const int prop_offset; /* offset (index) into the property values */
+ void (*func)(Display *dpy, XDevice *dev, int argc, char **argv); /* handler function, if appropriate */
} param_t;
+static void map_button(Display *dpy, XDevice *dev, int argc, char **argv);
+static void not_implemented(Display *dpy, XDevice *dev, int argc, char **argv)
+{
+ printf("Not implemented.\n");
+}
+
static param_t parameters[] =
{
{ "TopX",
"Bounding rect left coordinate in tablet units. ",
+ WACOM_PROP_TABLET_AREA, 32, 0, NULL,
},
{ "TopY",
"Bounding rect top coordinate in tablet units . ",
+ WACOM_PROP_TABLET_AREA, 32, 1, NULL,
},
{ "BottomX",
"Bounding rect right coordinate in tablet units. ",
+ WACOM_PROP_TABLET_AREA, 32, 2, NULL,
},
{ "BottomY",
"Bounding rect bottom coordinate in tablet units. ",
+ WACOM_PROP_TABLET_AREA, 32, 3, NULL,
},
{ "Button1",
"X11 event to which button 1 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button2",
"X11 event to which button 2 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button3",
"X11 event to which button 3 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button4",
"X11 event to which button 4 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button5",
"X11 event to which button 5 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button6",
"X11 event to which button 6 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button7",
"X11 event to which button 7 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button8",
"X11 event to which button 8 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button9",
"X11 event to which button 9 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button10",
"X11 event to which button 10 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button11",
"X11 event to which button 11 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button12",
"X11 event to which button 12 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button13",
"X11 event to which button 13 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button14",
"X11 event to which button 14 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button15",
"X11 event to which button 15 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button16",
"X11 event to which button 16 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button17",
"X11 event to which button 17 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button18",
"X11 event to which button 18 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button19",
"X11 event to which button 19 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button20",
"X11 event to which button 20 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button21",
"X11 event to which button 21 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button22",
"X11 event to which button 22 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button23",
"X11 event to which button 23 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button24",
"X11 event to which button 24 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button25",
"X11 event to which button 25 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button26",
"X11 event to which button 26 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button27",
"X11 event to which button 27 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button28",
"X11 event to which button 28 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button29",
"X11 event to which button 29 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button30",
"X11 event to which button 30 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button31",
"X11 event to which button 31 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "Button32",
"X11 event to which button 32 should be mapped. ",
+ NULL, 0, 0, map_button
},
{ "DebugLevel",
"Level of debugging trace for individual devices, "
"default is 0 (off). ",
+ NULL, 0, 0, not_implemented
},
{ "CommonDBG",
"Level of debugging statements applied to all devices "
"associated with the same tablet. default is 0 (off). ",
+ NULL, 0, 0, not_implemented
},
{ "Suppress",
"Number of points trimmed, default is 2. ",
+ WACOM_PROP_SAMPLE, 32, 1,
},
{ "RawSample",
"Number of raw data used to filter the points, "
"default is 4. ",
+ WACOM_PROP_SAMPLE, 32, 0,
},
{ "Screen_No",
"Sets/gets screen number the tablet is mapped to, "
"default is -1. ",
+ WACOM_PROP_DISPLAY_OPTS, 8, 0,
},
{ "PressCurve",
"Bezier curve for pressure (default is 0 0 100 100). ",
+ WACOM_PROP_PRESSURECURVE, 0, 0, NULL, /* FIXME: handler func */
},
{ "TwinView",
"Sets the mapping to TwinView horizontal/vertical/none. "
"Values = none, vertical, horizontal (default is none).",
+ WACOM_PROP_TWINVIEW_RES, 8, 1, NULL
},
{ "Mode",
"Switches cursor movement mode (default is absolute/on). ",
+ NULL, 0, 0, not_implemented
},
{ "TPCButton",
"Turns on/off Tablet PC buttons. "
"default is off for regular tablets, "
"on for Tablet PC. ",
+ NULL, 0, 0, not_implemented
},
{ "Touch",
"Turns on/off Touch events (default is enable/on). ",
+ WACOM_PROP_TOUCH, 8, 0
},
{ "Capacity",
"Touch sensitivity level (default is 3, "
"-1 for none capacitive tools).",
+ WACOM_PROP_CAPACITY, 8, 0,
},
{ "CursorProx",
@@ -239,79 +300,97 @@ static param_t parameters[] =
"in distance from the tablet. "
"(default is 10 for Intuos series, "
"42 for Graphire series).",
+ WACOM_PROP_PROXIMITY_THRESHOLD, 32, 0,
},
{ "Rotate",
"Sets the rotation of the tablet. "
"Values = NONE, CW, CCW, HALF (default is NONE).",
+ WACOM_PROP_ROTATION, 8, 0,
},
{ "RelWUp",
"X11 event to which relative wheel up should be mapped. ",
+ WACOM_PROP_WHEELBUTTONS, 8, 0,
},
{ "RelWDn",
"X11 event to which relative wheel down should be mapped. ",
+ WACOM_PROP_WHEELBUTTONS, 8, 1,
},
{ "AbsWUp",
"X11 event to which absolute wheel up should be mapped. ",
+ WACOM_PROP_WHEELBUTTONS, 8, 2,
},
{ "AbsWDn",
"X11 event to which absolute wheel down should be mapped. ",
+ WACOM_PROP_WHEELBUTTONS, 8, 3,
},
{ "StripLUp",
"X11 event to which left strip up should be mapped. ",
+ WACOM_PROP_STRIPBUTTONS, 8, 0,
},
{ "StripLDn",
"X11 event to which left strip down should be mapped. ",
+ WACOM_PROP_STRIPBUTTONS, 8, 1,
},
{ "StripRUp",
"X11 event to which right strip up should be mapped. ",
+ WACOM_PROP_STRIPBUTTONS, 8, 2,
},
{ "StripRDn",
"X11 event to which right strip down should be mapped. ",
+ WACOM_PROP_STRIPBUTTONS, 8, 3,
},
{ "TVResolution0",
"Sets MetaModes option for TwinView Screen 0. ",
+ WACOM_PROP_TWINVIEW_RES, 32, 0,
},
{ "TVResolution1",
"Sets MetaModes option for TwinView Screen 1. ",
+ WACOM_PROP_TWINVIEW_RES, 32, 1,
},
{ "RawFilter",
"Enables and disables filtering of raw data, "
"default is true/on.",
+ NULL, 0, 0, not_implemented
},
{ "SpeedLevel",
"Sets relative cursor movement speed (default is 6). ",
+ NULL, 0, 0, not_implemented
},
{ "ClickForce",
"Sets tip/eraser pressure threshold = ClickForce*MaxZ/100 "
"(default is 6)",
+ NULL, 0, 0, not_implemented
},
{ "Accel",
"Sets relative cursor movement acceleration "
"(default is 1)",
+ NULL, 0, 0, not_implemented
},
{ "xyDefault",
"Resets the bounding coordinates to default in tablet units. ",
+ NULL, 0, 0, not_implemented
},
{ "mmonitor",
"Turns on/off across monitor movement in "
"multi-monitor desktop, default is on ",
+ WACOM_PROP_DISPLAY_OPTS, 8, 2,
},
{ "CoreEvent",
@@ -321,159 +400,207 @@ static param_t parameters[] =
{ "STopX0",
"Screen 0 left coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 0, NULL
},
{ "STopY0",
"Screen 0 top coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 1, NULL
},
{ "SBottomX0",
"Screen 0 right coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 2, NULL
},
{ "SBottomY0",
"Screen 0 bottom coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 3, NULL
},
{ "STopX1",
"Screen 1 left coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 4, NULL
},
{ "STopY1",
"Screen 1 top coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 5, NULL
},
{ "SBottomX1",
"Screen 1 right coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 6, NULL
},
{ "SBottomY1",
"Screen 1 bottom coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 7, NULL
},
{ "STopX2",
"Screen 2 left coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 8, NULL
},
{ "STopY2",
"Screen 2 top coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 9, NULL
},
{ "SBottomX2",
"Screen 2 right coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 10, NULL
},
{ "SBottomY2",
"Screen 2 bottom coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 11, NULL
},
{ "STopX3",
"Screen 3 left coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 12, NULL
},
{ "STopY3",
"Screen 3 top coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 13, NULL
},
{ "SBottomX3",
"Screen 3 right coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 14, NULL
},
{ "SBottomY3",
"Screen 3 bottom coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 15, NULL
},
{ "STopX4",
"Screen 4 left coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 16, NULL
},
{ "STopY4",
"Screen 4 top coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 17, NULL
},
{ "SBottomX4",
"Screen 4 right coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 18, NULL
},
{ "SBottomY4",
"Screen 4 bottom coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 19, NULL
},
{ "STopX5",
"Screen 5 left coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 20, NULL
},
{ "STopY5",
"Screen 5 top coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 21, NULL
},
{ "SBottomX5",
"Screen 5 right coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 22, NULL
},
{ "SBottomY5",
"Screen 5 bottom coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 23, NULL
},
{ "STopX6",
"Screen 6 left coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 24, NULL
},
{ "STopY6",
"Screen 6 top coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 25, NULL
},
{ "SBottomX6",
"Screen 6 right coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 26, NULL
},
{ "SBottomY6",
"Screen 6 bottom coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 27, NULL
},
{ "STopX7",
"Screen 7 left coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 28, NULL
},
{ "STopY7",
"Screen 7 top coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 29, NULL
},
{ "SBottomX7",
"Screen 7 right coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 30, NULL
},
{ "SBottomY7",
"Screen 7 bottom coordinate in pixels. ",
+ WACOM_PROP_SCREENAREA, 32, 31, NULL
},
{ "ToolID",
"Returns the ID of the associated device. ",
+ WACOM_PROP_TOOL_TYPE, 32, 0, NULL
},
{ "ToolSerial",
"Returns the serial number of the associated device. ",
+ WACOM_PROP_SERIALIDS, 32, 3, NULL
},
{ "TabletID",
"Returns the tablet ID of the associated device. ",
+ WACOM_PROP_SERIALIDS, 32, 0, NULL
},
{ "GetTabletID",
"Returns the tablet ID of the associated device. ",
+ WACOM_PROP_SERIALIDS, 32, 0, NULL
},
{ "NumScreen",
"Returns number of screens configured for the desktop. ",
+ NULL, 0, 0, not_implemented
},
{ "XScaling",
"Returns the status of XSCALING is set or not. ",
+ NULL, 0, 0, not_implemented
},
{ NULL }
};
+static param_t* find_parameter(char *name)
+{
+ param_t *param = NULL;
+
+ for (param = parameters; param->name; param++)
+ if (strcmp(name, param->name) == 0)
+ break;
+ return param->name ? param : NULL;
+}
+
static void usage(void)
{
@@ -651,11 +778,86 @@ static void list(Display *dpy, int argc, char **argv)
printf("unknown argument to list.\n");
}
-static void set(Display *dpy)
+static void set(Display *dpy, int argc, char **argv)
{
+ param_t *param;
+ XDevice *dev = NULL;
+ Atom prop, type;
+ int format;
+ unsigned char* data;
+ unsigned long nitems, bytes_after;
+ double val;
+ long *n;
+ char *b;
+
+ if (argc < 3)
+ {
+ usage();
+ return;
+ }
+
+ dev = find_device(dpy, argv[0]);
+ if (!dev)
+ {
+ printf("Cannot find device '%s'.\n", argv[0]);
+ return;
+ }
+
+ param = find_parameter(argv[1]);
+ if (!param)
+ {
+ printf("Unknown parameter name '%s'.\n", argv[1]);
+ goto out;
+ } else if (param->func)
+ {
+ param->func(dpy, dev, argc - 2, &argv[2]);
+ goto out;
+ }
+
+ prop = XInternAtom(dpy, param->prop_name, True);
+ if (!prop)
+ {
+ fprintf(stderr, "Property for '%s' not available.\n",
+ param->name);
+ goto out;
+ }
+
+ val = atof(argv[2]);
+
+ XGetDeviceProperty(dpy, dev, prop, 0, 1000, False, AnyPropertyType,
+ &type, &format, &nitems, &bytes_after, &data);
+
+ switch(param->prop_format)
+ {
+ case 8:
+ if (format != param->prop_format || type != XA_INTEGER) {
+ fprintf(stderr, " %-23s = format mismatch (%d)\n",
+ param->name, format);
+ break;
+ }
+ b = (char*)data;
+ b[param->prop_offset] = rint(val);
+ break;
+ case 32:
+ if (format != param->prop_format || type != XA_INTEGER) {
+ fprintf(stderr, " %-23s = format mismatch (%d)\n",
+ param->name, format);
+ break;
+ }
+ n = (long*)data;
+ n[param->prop_offset] = rint(val);
+ break;
+ }
+
+ XChangeDeviceProperty(dpy, dev, prop, type, format,
+ PropModeReplace, data, nitems);
+ XFlush(dpy);
+
+out:
+ XCloseDevice(dpy, dev);
}
-static void get(Display *dpy)
+static void get(Display *dpy, int argc, char **argv)
{
}
@@ -733,9 +935,9 @@ int main (int argc, char **argv)
if (strcmp(argv[optind], "list") == 0)
list(dpy, argc - (optind + 1), &argv[optind + 1]);
else if (strcmp(argv[optind], "set") == 0)
- set(dpy);
+ set(dpy, argc - (optind + 1), &argv[optind + 1]);
else if (strcmp(argv[optind], "get") == 0)
- get(dpy);
+ get(dpy, argc - (optind + 1), &argv[optind + 1]);
else if (strcmp(argv[optind], "getdefault") == 0)
getdefault(dpy);
else