diff options
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/waltop.c | 153 |
2 files changed, 154 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 786e1d5..9bcbce3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,7 +22,7 @@ LIBNAME=libfakedev.a AM_LDFLAGS = $(LIBNAME) -noinst_PROGRAMS=btn0 absrel abs pen dummy synaptics allbtn wacom powermate +noinst_PROGRAMS=btn0 absrel abs pen dummy synaptics allbtn wacom powermate waltop noinst_LIBRARIES=$(LIBNAME) libfakedev_a_SOURCES=fakedev.c fakedev.h diff --git a/src/waltop.c b/src/waltop.c new file mode 100644 index 0000000..e3726ca --- /dev/null +++ b/src/waltop.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 = "WALTOP International Corp. Digital Ink Pad", + .setup = wacom_setup, + .run = wacom_run, +}; + + + +struct test_device* get_device(void) +{ + return &wacom_dev; +} + + |