diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-06-30 11:23:24 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-06-30 11:23:24 +1000 |
commit | e6a09f8caa8617aa6efb4af133f560be5aa670c4 (patch) | |
tree | e2fa95b2c63874fe27ced297718fb447bb5bc3ed | |
parent | 399ce681febcdcdc68169ada487720efa3a96045 (diff) |
Add test device with all axes set.
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/allaxes.c | 85 |
2 files changed, 86 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 5046274..189a1dd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,6 +25,7 @@ AM_LDFLAGS = $(LIBNAME) noinst_PROGRAMS=btn0 \ absrel \ abs \ + allaxes \ pen \ dummy \ synaptics \ diff --git a/src/allaxes.c b/src/allaxes.c new file mode 100644 index 0000000..5426583 --- /dev/null +++ b/src/allaxes.c @@ -0,0 +1,85 @@ +/* + * 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 with all abs axes */ + +#include <stdio.h> +#include <unistd.h> +#include <linux/input.h> +#include <linux/uinput.h> + +#include "fakedev.h" + +static int allaxes_setup(struct uinput_user_dev* dev, int fd) +{ + int i; + + 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 */ + + for (i = ABS_X; i < ABS_MAX; i++) { + if (ioctl(fd, UI_SET_ABSBIT, i) == -1) goto error; + dev->absmin[i] = 0; + dev->absmax[i] = 1000; + + } + + return 0; + +error: + perror("ioctl failed."); + return -1; +} + +static int allaxes_run(int fd) +{ + absmove(fd, 100, 100); + sleep(1); + absmove(fd, 120, 120); + sleep(1); + return 0; +} + +static struct test_device allaxes_dev = { + .name = "allaxes test device", + .setup = allaxes_setup, + .run = allaxes_run, +}; + + +struct test_device* get_device(void) +{ + return &allaxes_dev; +} |