diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-09 10:52:35 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-26 10:17:01 +1000 |
commit | fa83ab8780d6ee359b839c0205b093e7e7e592b2 (patch) | |
tree | 9ab85ef2cba96bcb8698b02e0de715fbfa8e882c | |
parent | b846b83e3013577bb389bfe096feeeb6d50d39bc (diff) |
Add wacom Intuos test device.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/wacom.c | 153 |
2 files changed, 157 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ffc97fa..e66d51f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -noinst_PROGRAMS=fakedev btn0 absrel abs dummy synaptics allbtn +noinst_PROGRAMS=fakedev btn0 absrel abs dummy synaptics allbtn wacom fakedev_SOURCES=fakedev.c fakedev.h fakedev_LDFLAGS=$(DLOPEN_LIBS) -rdynamic @@ -42,3 +42,6 @@ synaptics_LDFLAGS=$(LFLAGS) allbtn_SOURCES=allbtn.c allbtn_LDFLAGS=$(LFLAGS) + +wacom_SOURCES=wacom.c +wacom_LDFLAGS=$(LFLAGS) diff --git a/src/wacom.c b/src/wacom.c new file mode 100644 index 0000000..ebd6338 --- /dev/null +++ b/src/wacom.c @@ -0,0 +1,153 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Red Hat + * not be used in advertising or publicity pertaining to distribution + * of the software without specific, written prior permission. Red + * Hat makes no representations about the suitability of this software + * for any purpose. It is provided "as is" without express or implied + * warranty. + * + * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: + * Peter Hutterer (peter.hutterer@redhat.com) + */ + + +/* creates a device that looks like a Wacom Intuous 4x6 */ + +#include <stdio.h> +#include <unistd.h> +#include <linux/input.h> +#include <linux/uinput.h> + +#include "fakedev.h" + +static int wacom_setup(struct uinput_user_dev* dev, int fd) +{ + + if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -1) goto error; + if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -1) goto error; + if (ioctl(fd, UI_SET_EVBIT, EV_REL) == -1) goto error; + if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error; + + /* buttons */ + if (ioctl(fd, UI_SET_KEYBIT, BTN_0) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_1) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_2) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_3) == -1) goto error; + + if (ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_SIDE) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_EXTRA) == -1) goto error; + + if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_PEN) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_RUBBER) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_BRUSH) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_PENCIL) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_AIRBRUSH) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_FINGER) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_MOUSE) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_STYLUS) == -1) goto error; + if (ioctl(fd, UI_SET_KEYBIT, BTN_STYLUS2) == -1) goto error; + + /* axes */ + if (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) == -1) goto error; + + if (ioctl(fd, UI_SET_ABSBIT, ABS_X) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_Z) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_RX) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_RZ) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_THROTTLE) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_WHEEL) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_PRESSURE) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_DISTANCE) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_TILT_X) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_TILT_Y) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_MISC) == -1) goto error; + + dev->absmin[ABS_X] = 0; + dev->absmax[ABS_X] = 31496; + + dev->absmin[ABS_Y] = 0; + dev->absmax[ABS_Y] = 19685; + + dev->absmin[ABS_Z] = -900; + dev->absmax[ABS_Z] = 899; + + dev->absmin[ABS_RX] = 0; + dev->absmax[ABS_RX] = 4096; + + dev->absmin[ABS_RZ] = -900; + dev->absmax[ABS_RZ] = 899; + + dev->absmin[ABS_THROTTLE] = -1023; + dev->absmax[ABS_THROTTLE] = 1023; + + dev->absmin[ABS_WHEEL] = 0; + dev->absmax[ABS_WHEEL] = 1023; + + dev->absmin[ABS_PRESSURE] = 0; + dev->absmax[ABS_PRESSURE] = 1023; + + dev->absmin[ABS_DISTANCE] = 0; + dev->absmax[ABS_DISTANCE] = 63; + + dev->absmin[ABS_TILT_X] = 0; + dev->absmax[ABS_TILT_X] = 127; + + dev->absmin[ABS_TILT_Y] = 0; + dev->absmax[ABS_TILT_Y] = 127; + + dev->absmin[ABS_MISC] = 0; + dev->absmax[ABS_MISC] = 1; + + dev->id.bustype = 0x3; + dev->id.vendor = 0x56a; + dev->id.product = 0xb7; + + return 0; + +error: + perror("ioctl failed."); + return -1; +} + +static int wacom_run(int fd) +{ + absmove(fd, 100, 100); + sleep(1); + absmove(fd, 120, 120); + sleep(1); + return 0; +} + +struct test_device wacom_dev = { + .name = "Wacom Intuos3 4x6", + .setup = wacom_setup, + .run = wacom_run, +}; + + + +struct test_device* get_device(void) +{ + return &wacom_dev; +} + + |