summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-09-23 15:18:23 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-09-23 15:18:23 +1000
commit7f3a30fa36a71dc4009dfdcb2b1baac1e1359cf8 (patch)
tree258ff3599520c0b87546b6a00c1a9e238498fbba
parent84c3a5816878f11fd794d35281a36d736d171e2c (diff)
Add a slew of random testdevices
-rw-r--r--src/33138.c110
-rw-r--r--src/39663.c98
-rw-r--r--src/Makefile.am17
-rw-r--r--src/absrel.c23
-rw-r--r--src/allaxes.c9
-rw-r--r--src/btn_only.c73
-rw-r--r--src/btn_touch.c84
-rw-r--r--src/elantech.c131
-rw-r--r--src/isdv4.c199
-rw-r--r--src/joystick.c86
-rw-r--r--src/keyboardmouse.c3
-rw-r--r--src/mousekbd.c95
-rw-r--r--src/mx_revolution.c93
-rw-r--r--src/no_proximity_tablet.c96
-rw-r--r--src/nobtn.c68
-rw-r--r--src/ntrig_pen.c61
-rw-r--r--src/pressure.c72
-rw-r--r--src/relmisc.c94
-rw-r--r--src/relwheel.c78
-rw-r--r--src/relz.c75
-rw-r--r--src/synaptics.c2
-rw-r--r--src/synaptics_central_edges.c129
-rw-r--r--src/thirdaxis.c84
-rw-r--r--src/wacom.c4
24 files changed, 1773 insertions, 11 deletions
diff --git a/src/33138.c b/src/33138.c
new file mode 100644
index 0000000..57eec66
--- /dev/null
+++ b/src/33138.c
@@ -0,0 +1,110 @@
+/*
+ * 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int mouse_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_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_MSC) == -1) goto error;
+
+ /* buttons */
+ 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_FORWARD) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_BACK) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_TASK) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 280) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 281) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 282) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 283) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 284) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 285) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 286) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 287) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_HWHEEL) == -1) goto error;
+
+ if (ioctl(fd, UI_SET_MSCBIT, 4) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int mouse_run(int fd)
+{
+
+ static int once = 0;
+
+
+ if (once == 0)
+ {
+ sleep(5);
+ once = 1;
+ send_event(fd, EV_MSC, 4, 90001);
+ send_event(fd, EV_KEY, BTN_LEFT, 1);
+ send_event(fd, EV_SYN, SYN_REPORT, 1);
+
+ } else if (once == 1)
+ {
+ once = 2;
+ send_event(fd, EV_MSC, 4, 90001);
+ send_event(fd, EV_KEY, BTN_LEFT, 0);
+ send_event(fd, EV_SYN, SYN_REPORT, 1);
+
+ }
+
+ return 0;
+}
+
+static struct test_device mouse_dev = {
+ .name = "BTN_0 test device",
+ .setup = mouse_setup,
+ .run = mouse_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &mouse_dev;
+}
+
diff --git a/src/39663.c b/src/39663.c
new file mode 100644
index 0000000..6038513
--- /dev/null
+++ b/src/39663.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2011 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 with ABS_X, ABS_Y, BTN_LEFT, BTN_MIDDLE, BTN_RIGHT. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int abs_setup(struct uinput_user_dev* dev, int fd)
+{
+ if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* buttons */
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error;
+
+
+ dev->absmin[ABS_X] = 0;
+ dev->absmax[ABS_X] = 4095;
+
+ dev->absmin[ABS_Y] = 0;
+ dev->absmax[ABS_Y] = 4095;
+
+ return 0;
+
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int abs_run(int fd)
+{
+ sleep(5);
+ printf("now\n");
+
+ send_event(fd, EV_KEY, BTN_TOUCH, 1);
+ absmove(fd, 2093, 968);
+
+ send_event(fd, EV_ABS, ABS_Y, 963);
+ syn(fd);
+
+ send_event(fd, EV_ABS, ABS_Y, 2095);
+ send_event(fd, EV_ABS, ABS_Y, 956);
+ syn(fd);
+
+ send_event(fd, EV_KEY, BTN_TOUCH, 0);
+ syn(fd);
+
+ printf("done\n");
+ sleep(10);
+
+ return 0;
+}
+
+static struct test_device abs_dev = {
+ .name = "Abs test device",
+ .setup = abs_setup,
+ .run = abs_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &abs_dev;
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 189a1dd..d8b941d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,7 +43,22 @@ noinst_PROGRAMS=btn0 \
void \
rumblepad \
xen-vp \
- kvm
+ kvm \
+ isdv4 \
+ 33138 \
+ mousekbd \
+ btn_touch \
+ relmisc \
+ thirdaxis \
+ nobtn \
+ no_proximity_tablet \
+ mx_revolution \
+ btn_only \
+ joystick \
+ relwheel \
+ ntrig_pen \
+ relz \
+ 39663
noinst_LIBRARIES=$(LIBNAME)
libfakedev_a_SOURCES=fakedev.c fakedev.h
diff --git a/src/absrel.c b/src/absrel.c
index e747ff3..416c220 100644
--- a/src/absrel.c
+++ b/src/absrel.c
@@ -55,10 +55,10 @@ static int absrel_setup(struct uinput_user_dev* dev, int fd)
dev->absmin[ABS_X] = 0;
- dev->absmax[ABS_X] = 1000;
+ dev->absmax[ABS_X] = 100;
dev->absmin[ABS_Y] = 0;
- dev->absmax[ABS_Y] = 1000;
+ dev->absmax[ABS_Y] = 100;
return 0;
@@ -69,11 +69,20 @@ error:
static int absrel_run(int fd)
{
- absmove(fd, 100, 100);
- sleep(1);
- absmove(fd, 120, 120);
- sleep(1);
- move(fd, 10, 10);
+ move(fd, 1, 1);
+ usleep(500000);
+ move(fd, 1, 1);
+ usleep(500000);
+ move(fd, 1, 1);
+ usleep(500000);
+ move(fd, 1, 1);
+ usleep(500000);
+ move(fd, 1, 1);
+ usleep(500000);
+ absmove(fd, 50, 50);
+ usleep(500000);
+ absmove(fd, 90, 90);
+ usleep(500000);
return 0;
}
diff --git a/src/allaxes.c b/src/allaxes.c
index 5426583..88541c6 100644
--- a/src/allaxes.c
+++ b/src/allaxes.c
@@ -65,10 +65,19 @@ error:
static int allaxes_run(int fd)
{
+ int i;
+ int val = 100;
absmove(fd, 100, 100);
sleep(1);
absmove(fd, 120, 120);
sleep(1);
+
+ for (i = ABS_X; i < ABS_MAX; i++)
+ send_event(fd, EV_ABS, i, val);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ val = val == 100 ? 200 : 100;
+
return 0;
}
diff --git a/src/btn_only.c b/src/btn_only.c
new file mode 100644
index 0000000..6c300ff
--- /dev/null
+++ b/src/btn_only.c
@@ -0,0 +1,73 @@
+/*
+ * 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int btn_only_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_SYN) == -1) goto error;
+
+ /* buttons */
+ 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, KEY_A) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, KEY_B) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int btn_only_run(int fd)
+{
+ click(fd, BTN_1, 1);
+ usleep(1000);
+ click(fd, BTN_1, 0);
+ printf("clicked\n");
+ sleep(5);
+ return 0;
+}
+
+static struct test_device btn_only_dev = {
+ .name = "button only test device",
+ .setup = btn_only_setup,
+ .run = btn_only_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &btn_only_dev;
+}
+
diff --git a/src/btn_touch.c b/src/btn_touch.c
new file mode 100644
index 0000000..a75a810
--- /dev/null
+++ b/src/btn_touch.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright © 2010 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 has ABS_X ABS_Y BTN_TOUCH
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int btntouch_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_SYN) == -1) goto error;
+
+ /* buttons */
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error;
+
+
+ dev->absmin[ABS_X] = 0;
+ dev->absmax[ABS_X] = 0xFFFF;
+
+ dev->absmin[ABS_Y] = 0;
+ dev->absmax[ABS_Y] = 0xFFFF;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int btntouch_run(int fd)
+{
+ absmove(fd, 100, 100);
+ sleep(1);
+ absmove(fd, 5000, 5000);
+ click(fd, BTN_TOUCH, 1);
+ sleep(1);
+ click(fd, BTN_TOUCH, 0);
+ return 0;
+}
+
+static struct test_device btntouch_dev = {
+ .name = "BTN_TOUCH test device",
+ .setup = btntouch_setup,
+ .run = btntouch_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &btntouch_dev;
+}
diff --git a/src/elantech.c b/src/elantech.c
new file mode 100644
index 0000000..7877415
--- /dev/null
+++ b/src/elantech.c
@@ -0,0 +1,131 @@
+/*
+ * 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)
+ * Alberto Milone (alberto.milone@canonical.com)
+ */
+
+
+/* creates a device that looks like my elantech touchpad */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int elantech_setup(struct uinput_user_dev* dev, int fd)
+{
+
+ if (set_evbit(dev, fd, EV_KEY)) == -1) goto error;
+ if (set_evbit(dev, fd, EV_ABS)) == -1) goto error;
+ if (set_evbit(dev, fd, EV_SYN)) == -1) goto error;
+
+ /* buttons */
+ if (set_keybit(dev, fd, BTN_LEFT) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_MIDDLE) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_RIGHT) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_TOOL_FINGER) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_TOUCH) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_TOOL_DOUBLETAP) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_TOOL_TRIPLETAP) == -1) goto error;
+
+ /* axes */
+ if (set_absbit(dev, fd, ABS_X) == -1) goto error;
+ if (set_absbit(dev, fd, ABS_Y) == -1) goto error;
+ if (set_absbit(dev, fd, ABS_PRESSURE) == -1) goto error;
+ if (set_absbit(dev, fd, ABS_TOOL_WIDTH) == -1) goto error;
+
+ dev->absmin[ABS_X] = 8;
+ dev->absmax[ABS_X] = 1144;
+
+ dev->absmin[ABS_Y] = 8;
+ dev->absmax[ABS_Y] = 760;
+
+ /* Elantech doesn't report pressure */
+ dev->absmin[ABS_PRESSURE] = 0;
+ dev->absmax[ABS_PRESSURE] = 255;
+
+ dev->absmin[ABS_TOOL_WIDTH] = 0;
+ dev->absmax[ABS_TOOL_WIDTH] = 1;
+
+ dev->id.bustype = 0x11;
+ dev->id.vendor = 0x2;
+ dev->id.product = 0xe;
+
+ return 0;
+
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int elantech_run(int fd)
+{
+#define xmin 0
+#define xmax 2000
+#define ymin 0
+#define ymax 1000
+
+ static int x = xmin, y = ymin, direction = 10;
+
+ send_event(fd, EV_KEY, BTN_TOOL_FINGER, 1);
+ send_event(fd, EV_KEY, BTN_TOUCH, 1);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 75);
+ absmove(fd, x, y);
+
+ while(x >= xmin && x <= xmax && y >= ymin && y <= ymax)
+ {
+ x += direction;
+ y += direction;
+ absmove(fd, x, y);
+ usleep(200);
+ }
+
+ x -= direction * 2;
+ y -= direction * 2;
+
+ direction *= -1;
+
+ send_event(fd, EV_KEY, BTN_TOOL_FINGER, 0);
+ send_event(fd, EV_KEY, BTN_TOUCH, 0);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 0);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ sleep(1);
+ return 0;
+}
+
+struct test_device elantech_dev = {
+ .name = "ETPS/2 Elantech TouchPad",
+ .setup = elantech_setup,
+ .run = elantech_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &elantech_dev;
+}
+
diff --git a/src/isdv4.c b/src/isdv4.c
new file mode 100644
index 0000000..34bbce7
--- /dev/null
+++ b/src/isdv4.c
@@ -0,0 +1,199 @@
+/*
+ * 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_SYN) == -1) goto error;
+
+ /* buttons */
+ 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_DOUBLETAP) == -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_ABSBIT, ABS_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_RX) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_RY) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_PRESSURE) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_MISC) == -1) goto error;
+
+ dev->absmin[ABS_X] = 0;
+ dev->absmax[ABS_X] = 26202;
+
+ dev->absmin[ABS_Y] = 0;
+ dev->absmax[ABS_Y] = 16325;
+
+ dev->absmin[ABS_RX] = 0;
+ dev->absmax[ABS_RX] = 1023;
+
+ dev->absmin[ABS_RY] = 0;
+ dev->absmax[ABS_RY] = 1023;
+
+ dev->absmin[ABS_PRESSURE] = 0;
+ dev->absmax[ABS_PRESSURE] = 255;
+
+ dev->absmin[ABS_MISC] = 0;
+ dev->absmax[ABS_MISC] = 1;
+
+ dev->id.bustype = 0x3;
+ dev->id.vendor = 0x56a;
+ dev->id.product = 0x93;
+
+ return 0;
+
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static void testcase2(int fd)
+{
+
+ send_event(fd, EV_ABS, ABS_X, 100);
+ send_event(fd, EV_ABS, ABS_Y, 100);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 100);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ usleep(10000);
+
+ send_event(fd, EV_ABS, ABS_X, 200);
+ send_event(fd, EV_ABS, ABS_Y, 200);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 200);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ usleep(10000);
+}
+static void testcase(int fd)
+{
+ static int idx = 0;
+ static int values[12][3] =
+ { { 0 , 16233, 31000 },
+ { 13422, 100, 8101 },
+ { -500, 0, 784 },
+ { 0, 1033, 4000 },
+ { -288, 0, 708 },
+ { -1000, 10, 1022 },
+ { 0, 484, 1022 },
+ { 0, 484, 1022 },
+ { 0, 33, 63 },
+ { 0, 66, 127 },
+ { 0, 1, 0 }};
+
+
+ send_event(fd, EV_ABS, ABS_X, values[0][idx]);
+ send_event(fd, EV_ABS, ABS_Y, values[1][idx]);
+ send_event(fd, EV_ABS, ABS_Z, values[2][idx]);
+ send_event(fd, EV_ABS, ABS_RX, values[3][idx]);
+ send_event(fd, EV_ABS, ABS_RY, values[4][idx]);
+ send_event(fd, EV_ABS, ABS_THROTTLE, values[5][idx]);
+ send_event(fd, EV_ABS, ABS_WHEEL, values[6][idx]);
+ send_event(fd, EV_ABS, ABS_PRESSURE, values[7][idx]);
+ send_event(fd, EV_ABS, ABS_DISTANCE, values[9][idx]);
+ send_event(fd, EV_ABS, ABS_TILT_X, values[10][idx]);
+ send_event(fd, EV_ABS, ABS_TILT_Y, values[11][idx]);
+ send_event(fd, EV_ABS, ABS_MISC, values[12][idx]);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ idx++;
+ idx = idx % 3;
+
+ usleep(20000);
+}
+
+static void testcase3(int fd)
+{
+
+ send_event(fd, EV_ABS, ABS_X, 21033);
+ send_event(fd, EV_ABS, ABS_Y, 10379);
+ send_event(fd, EV_KEY, BTN_TOOL_PEN, 1);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ send_event(fd, EV_ABS, ABS_X, 21031);
+ send_event(fd, EV_ABS, ABS_Y, 10395);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 100);
+ send_event(fd, EV_KEY, BTN_TOUCH, 1);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ send_event(fd, EV_ABS, ABS_X, 21000);
+ send_event(fd, EV_ABS, ABS_Y, 10000);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 110);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ send_event(fd, EV_ABS, ABS_X, 21033);
+ send_event(fd, EV_ABS, ABS_Y, 10379);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 0);
+ send_event(fd, EV_KEY, BTN_TOUCH, 0);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ send_event(fd, EV_KEY, BTN_TOOL_PEN, 0);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+}
+
+static int wacom_run(int fd)
+{
+ testcase3(fd);
+ sleep(1);
+#if 0
+ absmove(fd, 100, 100);
+ sleep(1);
+ absmove(fd, 120, 120);
+ sleep(1);
+ testcase2(fd);
+#endif
+ return 0;
+}
+
+struct test_device wacom_dev = {
+ .name = "Wacom ISDv4 93",
+ .setup = wacom_setup,
+ .run = wacom_run,
+};
+
+
+
+struct test_device* get_device(void)
+{
+ return &wacom_dev;
+}
+
+
diff --git a/src/joystick.c b/src/joystick.c
new file mode 100644
index 0000000..079e932
--- /dev/null
+++ b/src/joystick.c
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright © 2008 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 with joystick_X, joystick_Y, BTN_LEFT, BTN_MIDDLE, BTN_RIGHT. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int joystick_setup(struct uinput_user_dev* dev, int fd)
+{
+ if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* buttons */
+ 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;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error;
+
+
+ dev->absmin[ABS_X] = 0;
+ dev->absmax[ABS_X] = 120;
+
+ dev->absmin[ABS_Y] = 0;
+ dev->absmax[ABS_Y] = 120;
+
+ return 0;
+
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int joystick_run(int fd)
+{
+ absmove(fd, 100, 100);
+ sleep(1);
+ absmove(fd, 120, 120);
+ sleep(1);
+ return 0;
+}
+
+static struct test_device joystick_dev = {
+ .name = "joystick test device",
+ .setup = joystick_setup,
+ .run = joystick_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &joystick_dev;
+}
diff --git a/src/keyboardmouse.c b/src/keyboardmouse.c
index e7b8c2c..51a6491 100644
--- a/src/keyboardmouse.c
+++ b/src/keyboardmouse.c
@@ -37,6 +37,7 @@ static int keyboardmouse_setup(struct uinput_user_dev *dev, int fd)
if (ioctl(fd, UI_SET_EVBIT, EV_REL) == -1) goto error;
if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+#if 0
/* buttons */
if (ioctl(fd, UI_SET_KEYBIT, BTN_LEFT) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE) == -1) goto error;
@@ -45,6 +46,7 @@ static int keyboardmouse_setup(struct uinput_user_dev *dev, int fd)
if (ioctl(fd, UI_SET_KEYBIT, BTN_EXTRA) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_FORWARD) == -1) goto error;
if (ioctl(fd, UI_SET_KEYBIT, BTN_BACK) == -1) goto error;
+#endif
/* keys */
if (ioctl(fd, UI_SET_KEYBIT, KEY_ESC) == -1) goto error;
@@ -74,6 +76,7 @@ static int keyboardmouse_run(int fd)
usleep(1000);
click(fd, BTN_SIDE, 0);
#endif
+ move(fd, 10, 0);
return 0;
}
diff --git a/src/mousekbd.c b/src/mousekbd.c
new file mode 100644
index 0000000..f3806aa
--- /dev/null
+++ b/src/mousekbd.c
@@ -0,0 +1,95 @@
+/*
+ * 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int mousekbd_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_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* buttons */
+ 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_FORWARD) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_BACK) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
+
+ if (ioctl(fd, UI_SET_KEYBIT, KEY_A) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, KEY_B) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, KEY_C) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int mousekbd_run(int fd)
+{
+#if 0
+ move(fd, -10, 0);
+ usleep(1000);
+ move(fd, 0, -10);
+ usleep(1000);
+ move(fd, 10, 0);
+ usleep(1000);
+ move(fd, 0, 10);
+ usleep(1000);
+#endif
+ click(fd, BTN_LEFT, 1);
+ usleep(1000000);
+ click(fd, BTN_LEFT, 0);
+ usleep(1000000);
+ key(fd, KEY_A, 1);
+ key(fd, KEY_A, 0);
+ return 0;
+}
+
+static struct test_device mousekbd_dev = {
+ .name = "mouse/kbd test device",
+ .setup = mousekbd_setup,
+ .run = mousekbd_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &mousekbd_dev;
+}
+
diff --git a/src/mx_revolution.c b/src/mx_revolution.c
new file mode 100644
index 0000000..08d9fc9
--- /dev/null
+++ b/src/mx_revolution.c
@@ -0,0 +1,93 @@
+/*
+ * 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int mx_revolution_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_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* buttons */
+ 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_FORWARD) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_BACK) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_TASK) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 280) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 281) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 282) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 283) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 284) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 285) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 286) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, 287) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_HWHEEL) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int mx_revolution_run(int fd)
+{
+ click(fd, BTN_LEFT, 1);
+ click(fd, BTN_LEFT, 0);
+ click(fd, 280, 1);
+ click(fd, 280, 0);
+ click(fd, 287, 1);
+ click(fd, 287, 0);
+ usleep(100000);
+ return 0;
+}
+
+static struct test_device mx_revolution_dev = {
+ .name = "BTN_0 test device",
+ .setup = mx_revolution_setup,
+ .run = mx_revolution_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &mx_revolution_dev;
+}
+
diff --git a/src/no_proximity_tablet.c b/src/no_proximity_tablet.c
new file mode 100644
index 0000000..2f18b60
--- /dev/null
+++ b/src/no_proximity_tablet.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright © 2010 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 sends x/y coordinates outside of the BTN_TOOL_PEN
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int tablet_setup(struct uinput_user_dev* dev, int fd)
+{
+ if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* buttons */
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_TOOL_PEN) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error;
+
+
+ dev->absmin[ABS_X] = 0;
+ dev->absmax[ABS_X] = 120;
+
+ dev->absmin[ABS_Y] = 0;
+ dev->absmax[ABS_Y] = 120;
+
+ return 0;
+
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int tablet_run(int fd)
+{
+ sleep(5);
+ absmove(fd, 100, 100);
+ send_event(fd, EV_KEY, BTN_TOOL_PEN, 1);
+ send_event(fd, EV_KEY, BTN_TOUCH, 1);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+ printf("going in at 100/100\n");
+ sleep(1);
+ absmove(fd, 110, 110);
+ sleep(1);
+ absmove(fd, 120, 120);
+ sleep(1);
+ send_event(fd, EV_KEY, BTN_TOOL_PEN, 0);
+ send_event(fd, EV_KEY, BTN_TOUCH, 0);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+ printf("going out at 120/120\n");
+ return 0;
+}
+
+static struct test_device tablet_dev = {
+ .name = "Tablet proximity test device",
+ .setup = tablet_setup,
+ .run = tablet_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &tablet_dev;
+}
diff --git a/src/nobtn.c b/src/nobtn.c
new file mode 100644
index 0000000..62d6805
--- /dev/null
+++ b/src/nobtn.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2010 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int nobtn_setup(struct uinput_user_dev *dev, int fd)
+{
+ if (ioctl(fd, UI_SET_EVBIT, EV_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int nobtn_run(int fd)
+{
+ move(fd, 10, 10);
+ usleep(1000);
+ return 0;
+}
+
+static struct test_device nobtn_dev = {
+ .name = "Axis/no buttons test device",
+ .setup = nobtn_setup,
+ .run = nobtn_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &nobtn_dev;
+}
+
diff --git a/src/ntrig_pen.c b/src/ntrig_pen.c
new file mode 100644
index 0000000..5dbc82c
--- /dev/null
+++ b/src/ntrig_pen.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2011 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int ntrig_pen_setup(struct uinput_user_dev *dev, int fd)
+{
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int ntrig_pen_run(int fd)
+{
+ usleep(1000);
+ return 0;
+}
+
+static struct test_device ntrig_pen_dev = {
+ .name = "N-Trig Pen",
+ .setup = ntrig_pen_setup,
+ .run = ntrig_pen_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &ntrig_pen_dev;
+}
+
diff --git a/src/pressure.c b/src/pressure.c
new file mode 100644
index 0000000..ad6464e
--- /dev/null
+++ b/src/pressure.c
@@ -0,0 +1,72 @@
+/*
+ * 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int relz_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_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Z) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int relz_run(int fd)
+{
+ send_event(fd, EV_REL, REL_X, 1);
+ send_event(fd, EV_REL, REL_Y, 1);
+ send_event(fd, EV_REL, REL_Z, 1);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+ usleep(500);
+ return 0;
+}
+
+static struct test_device relz_dev = {
+ .name = "rel_z test device",
+ .setup = relz_setup,
+ .run = relz_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &relz_dev;
+}
+
diff --git a/src/relmisc.c b/src/relmisc.c
new file mode 100644
index 0000000..4042bf8
--- /dev/null
+++ b/src/relmisc.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2010 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int mouse_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_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_MSC) == -1) goto error;
+
+ /* buttons */
+ 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_FORWARD) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_BACK) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_TASK) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_MISC) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int mouse_run(int fd)
+{
+#if 0
+ move(fd, -10, 0);
+ usleep(1000);
+ move(fd, 0, -10);
+ usleep(1000);
+ move(fd, 10, 0);
+ usleep(1000);
+ move(fd, 0, 10);
+ usleep(1000);
+#endif
+ send_event(fd, EV_REL, REL_MISC, 9);
+ click(fd, BTN_SIDE, 1);
+ usleep(1000);
+ send_event(fd, EV_REL, REL_MISC, 9);
+ click(fd, BTN_SIDE, 0);
+ return 0;
+}
+
+static struct test_device mouse_dev = {
+ .name = "BTN_0 test device",
+ .setup = mouse_setup,
+ .run = mouse_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &mouse_dev;
+}
+
diff --git a/src/relwheel.c b/src/relwheel.c
new file mode 100644
index 0000000..a2cde72
--- /dev/null
+++ b/src/relwheel.c
@@ -0,0 +1,78 @@
+
+/*
+ * 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int rhelwheel_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_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_HWHEEL) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int rhelwheel_run(int fd)
+{
+#if 0
+ move(fd, -10, 0);
+ usleep(1000);
+ move(fd, 0, -10);
+ usleep(1000);
+ move(fd, 10, 0);
+ usleep(1000);
+ move(fd, 0, 10);
+ usleep(1000);
+#endif
+ usleep(1000);
+ return 0;
+}
+
+static struct test_device rhelwheel_dev = {
+ .name = "rhelwheel test device",
+ .setup = rhelwheel_setup,
+ .run = rhelwheel_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &rhelwheel_dev;
+}
+
diff --git a/src/relz.c b/src/relz.c
new file mode 100644
index 0000000..3a64be1
--- /dev/null
+++ b/src/relz.c
@@ -0,0 +1,75 @@
+/*
+ * 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int relz_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_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -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;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Z) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int relz_run(int fd)
+{
+ send_event(fd, EV_REL, REL_X, 1);
+ send_event(fd, EV_REL, REL_Y, 1);
+ send_event(fd, EV_REL, REL_Z, 1);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+ usleep(500);
+ return 0;
+}
+
+static struct test_device relz_dev = {
+ .name = "rel_z test device",
+ .setup = relz_setup,
+ .run = relz_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &relz_dev;
+}
+
diff --git a/src/synaptics.c b/src/synaptics.c
index 056657c..94dc808 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -160,7 +160,7 @@ static int synaptics_run(int fd)
}
struct test_device synaptics_dev = {
- .name = "SynPS/2 Synaptics TouchPad",
+ .name = "test",
.setup = synaptics_setup,
.run = synaptics_run,
};
diff --git a/src/synaptics_central_edges.c b/src/synaptics_central_edges.c
new file mode 100644
index 0000000..f647fa6
--- /dev/null
+++ b/src/synaptics_central_edges.c
@@ -0,0 +1,129 @@
+/*
+ * 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 my synaptics touchpad */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int synaptics_setup(struct uinput_user_dev* dev, int fd)
+{
+
+ if (set_evbit(dev, fd, EV_KEY)) == -1) goto error;
+ if (set_evbit(dev, fd, EV_ABS)) == -1) goto error;
+ if (set_evbit(dev, fd, EV_SYN)) == -1) goto error;
+
+ /* buttons */
+ if (set_keybit(dev, fd, BTN_LEFT) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_MIDDLE) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_RIGHT) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_TOOL_FINGER) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_TOUCH) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_TOOL_DOUBLETAP) == -1) goto error;
+ if (set_keybit(dev, fd, BTN_TOOL_TRIPLETAP) == -1) goto error;
+
+ /* axes */
+ if (set_absbit(dev, fd, ABS_X) == -1) goto error;
+ if (set_absbit(dev, fd, ABS_Y) == -1) goto error;
+ if (set_absbit(dev, fd, ABS_PRESSURE) == -1) goto error;
+ if (set_absbit(dev, fd, ABS_TOOL_WIDTH) == -1) goto error;
+
+ dev->absmin[ABS_X] = 1472;
+ dev->absmax[ABS_X] = 5472;
+
+ dev->absmin[ABS_Y] = 1408;
+ dev->absmax[ABS_Y] = 4448;
+
+ dev->absmin[ABS_PRESSURE] = 0;
+ dev->absmax[ABS_PRESSURE] = 255;
+
+ dev->absmin[ABS_TOOL_WIDTH] = 0;
+ dev->absmax[ABS_TOOL_WIDTH] = 1;
+
+ dev->id.bustype = 0x11;
+ dev->id.vendor = 0x2;
+ dev->id.product = 0x7;
+
+ return 0;
+
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int synaptics_run(int fd)
+{
+#define xmin 1000
+#define xmax 7000
+#define ymin 1000
+#define ymax 5000
+
+ static int x = xmin, y = ymin, direction = 10;
+
+ send_event(fd, EV_KEY, BTN_TOOL_FINGER, 1);
+ send_event(fd, EV_KEY, BTN_TOUCH, 1);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 75);
+ absmove(fd, x, y);
+
+ while(x >= xmin && x <= xmax && y >= ymin && y <= ymax)
+ {
+ x += direction;
+ y += direction;
+ absmove(fd, x, y);
+ usleep(200);
+ }
+
+ x -= direction * 2;
+ y -= direction * 2;
+
+ direction *= -1;
+
+ send_event(fd, EV_KEY, BTN_TOOL_FINGER, 0);
+ send_event(fd, EV_KEY, BTN_TOUCH, 0);
+ send_event(fd, EV_ABS, ABS_PRESSURE, 0);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+
+ sleep(1);
+ return 0;
+}
+
+struct test_device synaptics_dev = {
+ .name = "SynPS/2 Synaptics TouchPad",
+ .setup = synaptics_setup,
+ .run = synaptics_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &synaptics_dev;
+}
+
diff --git a/src/thirdaxis.c b/src/thirdaxis.c
new file mode 100644
index 0000000..f8a70ad
--- /dev/null
+++ b/src/thirdaxis.c
@@ -0,0 +1,84 @@
+/*
+ * 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)
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int thirdaxis_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_REL) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error;
+
+ /* buttons */
+ 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_FORWARD) == -1) goto error;
+ if (ioctl(fd, UI_SET_KEYBIT, BTN_BACK) == -1) goto error;
+
+ /* axes */
+ if (ioctl(fd, UI_SET_RELBIT, REL_X) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Y) == -1) goto error;
+ if (ioctl(fd, UI_SET_RELBIT, REL_Z) == -1) goto error;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int thirdaxis_run(int fd)
+{
+ int val = 100;
+
+ send_event(fd, EV_REL, REL_Z, val);
+ send_event(fd, EV_SYN, SYN_REPORT, 0);
+ usleep(100000);
+
+ val *= -1;
+
+ return 0;
+}
+
+static struct test_device thirdaxis_dev = {
+ .name = "BTN_0 test device",
+ .setup = thirdaxis_setup,
+ .run = thirdaxis_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &thirdaxis_dev;
+}
+
diff --git a/src/wacom.c b/src/wacom.c
index d261cba..0634656 100644
--- a/src/wacom.c
+++ b/src/wacom.c
@@ -185,13 +185,13 @@ static void testcase(int fd)
static int wacom_run(int fd)
{
-#if 0
absmove(fd, 100, 100);
sleep(1);
absmove(fd, 120, 120);
sleep(1);
-#endif
+#if 0
testcase2(fd);
+#endif
return 0;
}