diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-11-29 10:02:27 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-11-29 10:15:32 +1000 |
commit | fe885ead4804111b08bac13b523bfa3b58c17251 (patch) | |
tree | 79c9c2d61a16fca9ee47f3f6f61007dc64980d78 | |
parent | 7fa8cfd25392fbdceaf72268d2010509daa48810 (diff) |
Add a whole bunch of testdevices that accumulated over the months
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/Makefile.am | 10 | ||||
-rw-r--r-- | src/abs.c | 2 | ||||
-rw-r--r-- | src/abs_throttle.c | 75 | ||||
-rw-r--r-- | src/alps.c | 5 | ||||
-rw-r--r-- | src/darwin_tablet.c | 126 | ||||
-rw-r--r-- | src/egalax.c | 118 | ||||
-rw-r--r-- | src/hwheel_only.c | 11 | ||||
-rw-r--r-- | src/hwheel_scroll.c | 75 | ||||
-rw-r--r-- | src/printf-device.c | 88 | ||||
-rw-r--r-- | src/qemu.c | 104 | ||||
-rw-r--r-- | src/scroll_down.c | 78 | ||||
-rw-r--r-- | src/touch-protocol-b.c | 111 |
12 files changed, 799 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 613828d..304a39d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -61,8 +61,16 @@ noinst_PROGRAMS=btn0 \ relz \ 39663 \ touch \ + touch-protocol-b \ hwheel_only \ - 44655 + hwheel_scroll \ + 44655 \ + darwin_tablet \ + abs_throttle \ + printf-device \ + scroll_down \ + egalax \ + qemu noinst_LIBRARIES=$(LIBNAME) @@ -65,7 +65,7 @@ error: static int abs_run(int fd) { - absmove(fd, 100, 100); + absmove(fd, 150, 150); sleep(1); absmove(fd, 120, 120); sleep(1); diff --git a/src/abs_throttle.c b/src/abs_throttle.c new file mode 100644 index 0000000..3d14da5 --- /dev/null +++ b/src/abs_throttle.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 abs_throttle_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; + + /* axes */ + if (ioctl(fd, UI_SET_ABSBIT, ABS_THROTTLE) == -1) goto error; + + dev->absmin[ABS_THROTTLE] = 0; + dev->absmax[ABS_THROTTLE] = 120; + + /* keys */ + if (ioctl(fd, UI_SET_KEYBIT, KEY_ENTER) == -1) goto error; + + + return 0; +error: + perror("ioctl failed."); + return -1; +} + +static int abs_throttle_run(int fd) +{ + send_event(fd, EV_ABS, ABS_THROTTLE, -1); + syn(fd); + usleep(1000); + return 0; +} + +static struct test_device abs_throttle_dev = { + .name = "abs_throttle-only test device", + .setup = abs_throttle_setup, + .run = abs_throttle_run, +}; + + +struct test_device* get_device(void) +{ + return &abs_throttle_dev; +} + @@ -90,12 +90,13 @@ static int alps_run(int fd) send_event(fd, EV_ABS, ABS_PRESSURE, 75); absmove(fd, x, y); - while(x >= xmin && x <= xmax && y >= ymin && y <= ymax) + while(x >= xmin && x <= xmax/2 && y >= ymin && y <= ymax) { x += direction; y += direction; absmove(fd, x, y); - usleep(200); + printf("absmove %d/%d\n", x, y); + usleep(4000); } x -= direction * 2; diff --git a/src/darwin_tablet.c b/src/darwin_tablet.c new file mode 100644 index 0000000..dde8451 --- /dev/null +++ b/src/darwin_tablet.c @@ -0,0 +1,126 @@ +/* + * Copyright © 2012 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 the darwinTablet */ + +#include <stdio.h> +#include <unistd.h> +#include <linux/input.h> +#include <linux/uinput.h> + +#include "fakedev.h" + +static int darwinTablet_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_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_STYLUS) == -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_PRESSURE) == -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; + + dev->absmin[ABS_X] = 0; + dev->absmax[ABS_X] = 1 << 16; + + dev->absmin[ABS_Y] = 0; + dev->absmax[ABS_Y] = 1 << 16; + + dev->absmin[ABS_PRESSURE] = 0; + dev->absmax[ABS_PRESSURE] = 1 << 16; + + dev->absmin[ABS_TILT_X] = -(1 << 16); + dev->absmax[ABS_TILT_X] = (1 << 16); + + dev->absmin[ABS_TILT_Y] = -(1 << 16); + dev->absmax[ABS_TILT_Y] = (1 << 16); + + dev->id.bustype = 0x3; + dev->id.vendor = 0x56a; + dev->id.product = 0xb7; + + return 0; + +error: + perror("ioctl failed."); + return -1; +} + +static void testcase(int fd) +{ + static int idx = 0; + static int values[4][5] = + { { 32777, 0, 0, 22526, 0 }, + { 32777, 65510, 0, 23552, 12288 }, + { 65526, 21, 0, 39935, 3070 }, + { 65526, 65471, 0, 61439, -21504 } }; + + + send_event(fd, EV_ABS, ABS_X, values[idx][0]); + send_event(fd, EV_ABS, ABS_Y, values[idx][1]); + send_event(fd, EV_ABS, ABS_PRESSURE, values[idx][2]); + send_event(fd, EV_ABS, ABS_TILT_X, values[idx][3]); + send_event(fd, EV_ABS, ABS_TILT_Y, values[idx][4]); + send_event(fd, EV_SYN, SYN_REPORT, 0); + + idx++; + idx = idx % 3; + + usleep(20000); +} + + +static int darwinTablet_run(int fd) +{ + testcase(fd); + return 0; +} + +struct test_device darwinTablet_dev = { + .name = "darwinTablet test device", + .setup = darwinTablet_setup, + .run = darwinTablet_run, +}; + + + +struct test_device* get_device(void) +{ + return &darwinTablet_dev; +} + + diff --git a/src/egalax.c b/src/egalax.c new file mode 100644 index 0000000..8ebcf27 --- /dev/null +++ b/src/egalax.c @@ -0,0 +1,118 @@ +/* + * Copyright © 2012 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; + if (ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_X) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_MT_SLOT) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID) == -1) goto error; + + dev->absmin[ABS_X] = 0; + dev->absmax[ABS_X] = 32767; + + dev->absmin[ABS_Y] = 0; + dev->absmax[ABS_Y] = 32767; + + dev->absmin[ABS_MT_POSITION_X] = 0; + dev->absmax[ABS_MT_POSITION_X] = 32767; + + dev->absmin[ABS_MT_POSITION_Y] = 0; + dev->absmax[ABS_MT_POSITION_Y] = 32767; + + dev->absmin[ABS_MT_SLOT] = 0; + dev->absmax[ABS_MT_SLOT] = 9; + + dev->absmin[ABS_MT_TRACKING_ID] = 0; + dev->absmax[ABS_MT_TRACKING_ID] = 65535; + + return 0; + + +error: + perror("ioctl failed."); + return -1; +} + +static int abs_run(int fd) +{ + static int slot = 0; + printf("sleep 5\n"); + sleep(5); + send_event(fd, EV_ABS, ABS_MT_SLOT, slot); + send_event(fd, EV_ABS, ABS_MT_TRACKING_ID, 16); + send_event(fd, EV_ABS, ABS_MT_POSITION_X, 22496); + send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 18016); + send_event(fd, EV_KEY, BTN_TOUCH, 1); + send_event(fd, EV_ABS, ABS_X, 22496); + send_event(fd, EV_ABS, ABS_Y, 18016); + syn(fd); + + send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 18032); + send_event(fd, EV_ABS, ABS_Y, 18032); + syn(fd); + + send_event(fd, EV_ABS, ABS_MT_TRACKING_ID, -1); + send_event(fd, EV_KEY, BTN_TOUCH, 0); + syn(fd); + + slot = !slot; + printf("slot is now %d\n", slot); + + return 0; +} + +static struct test_device abs_dev = { + .name = "eGalax_eMPIA Technology Inc. PCAP MultiTouch Controller", + .setup = abs_setup, + .run = abs_run, +}; + + +struct test_device* get_device(void) +{ + return &abs_dev; +} diff --git a/src/hwheel_only.c b/src/hwheel_only.c index be69b31..76c64a7 100644 --- a/src/hwheel_only.c +++ b/src/hwheel_only.c @@ -35,11 +35,22 @@ static int hwheel_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_ABS) == -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_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; + /* keys */ /* need some keys, otherwise evdev doesn't know how to use it */ if (ioctl(fd, UI_SET_KEYBIT, KEY_ENTER) == -1) goto error; diff --git a/src/hwheel_scroll.c b/src/hwheel_scroll.c new file mode 100644 index 0000000..e1bf251 --- /dev/null +++ b/src/hwheel_scroll.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 hwheel_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_HWHEEL) == -1) goto error; + + /* keys */ + /* need some keys, otherwise evdev doesn't know how to use it */ + if (ioctl(fd, UI_SET_KEYBIT, KEY_ENTER) == -1) goto error; + + + return 0; +error: + perror("ioctl failed."); + return -1; +} + +static int hwheel_run(int fd) +{ + send_event(fd, EV_REL, REL_HWHEEL, -1); + syn(fd); + usleep(1000); + return 0; +} + +static struct test_device hwheel_dev = { + .name = "HWHEEL-only test device", + .setup = hwheel_setup, + .run = hwheel_run, +}; + + +struct test_device* get_device(void) +{ + return &hwheel_dev; +} + diff --git a/src/printf-device.c b/src/printf-device.c new file mode 100644 index 0000000..c66f8f1 --- /dev/null +++ b/src/printf-device.c @@ -0,0 +1,88 @@ +/* + * Copyright © 2012 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; + + /* 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; + + 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 + click(fd, BTN_SIDE, 1); + usleep(1000); + click(fd, BTN_SIDE, 0); + return 0; +} + +static struct test_device mouse_dev = { + .name = "%n%n%n%n%n%n%n", + .setup = mouse_setup, + .run = mouse_run, +}; + + +struct test_device* get_device(void) +{ + return &mouse_dev; +} + diff --git a/src/qemu.c b/src/qemu.c new file mode 100644 index 0000000..3cde749 --- /dev/null +++ b/src/qemu.c @@ -0,0 +1,104 @@ +/* + * Copyright © 2012 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 QEMU tablet */ + +#include <stdio.h> +#include <unistd.h> +#include <linux/input.h> +#include <linux/uinput.h> + +#include "fakedev.h" + +static int qemu_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_REL) == -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; + if (ioctl(fd, UI_SET_RELBIT, REL_WHEEL) == -1) goto error; + + + dev->absmin[ABS_X] = 0; + dev->absmax[ABS_X] = 32767; + + dev->absmin[ABS_Y] = 0; + dev->absmax[ABS_Y] = 32767; + + return 0; + +error: + perror("ioctl failed."); + return -1; +} + +static int qemu_run(int fd) +{ + send_event(fd, EV_ABS, ABS_X, 10500); + syn(fd); + sleep(1); + send_event(fd, EV_ABS, ABS_Y, 12500); + syn(fd); + sleep(1); + click(fd, BTN_LEFT, 1); + syn(fd); + sleep(1); + send_event(fd, EV_ABS, ABS_Y, 10500); + syn(fd); + click(fd, BTN_LEFT, 0); + syn(fd); + sleep(1); + send_event(fd, EV_ABS, ABS_X, 14500); + syn(fd); + sleep(1); +#if 0 + absmove(fd, 12000, 12000); +#endif + sleep(1); + return 0; +} + +static struct test_device qemu_dev = { + .name = "QEMU 0.12.1 QEMU USB Tablet", + .setup = qemu_setup, + .run = qemu_run, +}; + + +struct test_device* get_device(void) +{ + return &qemu_dev; +} diff --git a/src/scroll_down.c b/src/scroll_down.c new file mode 100644 index 0000000..525db35 --- /dev/null +++ b/src/scroll_down.c @@ -0,0 +1,78 @@ +/* + * Copyright © 2012 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; + + /* 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_WHEEL) == -1) goto error; + + return 0; +error: + perror("ioctl failed."); + return -1; +} + +static int mouse_run(int fd) +{ + send_event(fd, EV_REL, REL_WHEEL, -100000); + syn(fd); + return 0; +} + +static struct test_device mouse_dev = { + .name = "scroll test device", + .setup = mouse_setup, + .run = mouse_run, +}; + + +struct test_device* get_device(void) +{ + return &mouse_dev; +} + diff --git a/src/touch-protocol-b.c b/src/touch-protocol-b.c new file mode 100644 index 0000000..5e5a300 --- /dev/null +++ b/src/touch-protocol-b.c @@ -0,0 +1,111 @@ +/* + * 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 multitouch_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_MT_SLOT) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y) == -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; + + dev->absmin[ABS_X] = 0; + dev->absmax[ABS_X] = 120; + + dev->absmin[ABS_Y] = 0; + dev->absmax[ABS_Y] = 120; + + dev->absmin[ABS_MT_POSITION_X] = 0; + dev->absmax[ABS_MT_POSITION_X] = 120; + + dev->absmin[ABS_MT_POSITION_Y] = 0; + dev->absmax[ABS_MT_POSITION_Y] = 120; + + dev->absmin[ABS_MT_SLOT] = 0; + dev->absmax[ABS_MT_SLOT] = 2; + + dev->absmin[ABS_MT_TRACKING_ID] = -1; + dev->absmax[ABS_MT_TRACKING_ID] = 5; + + return 0; + +error: + perror("ioctl failed."); + return -1; +} + +static int multitouch_run(int fd) +{ + send_event(fd, EV_ABS, ABS_MT_POSITION_X, 10); + send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 10); + send_event(fd, EV_SYN, SYN_MT_REPORT, 0); + send_event(fd, EV_ABS, ABS_MT_POSITION_X, 110); + send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 110); + send_event(fd, EV_SYN, SYN_MT_REPORT, 0); + syn(fd); + sleep(1); + send_event(fd, EV_ABS, ABS_MT_POSITION_X, 20); + send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 20); + send_event(fd, EV_SYN, SYN_MT_REPORT, 0); + send_event(fd, EV_ABS, ABS_MT_POSITION_X, 120); + send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 120); + send_event(fd, EV_SYN, SYN_MT_REPORT, 0); + syn(fd); + send_event(fd, EV_SYN, SYN_MT_REPORT, 0); + syn(fd); + sleep(1); + return 0; +} + +static struct test_device multitouch_dev = { + .name = "multitouch test device", + .setup = multitouch_setup, + .run = multitouch_run, +}; + + +struct test_device* get_device(void) +{ + return &multitouch_dev; +} |