From 7d34a581e79a496e4b734637aee0d40fc0ddfed2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 8 Sep 2009 09:33:32 +1000 Subject: Add void test device. this device doesnt' do anything, it's only useful for void driver testing. A matching HAL configuration is required. --- src/Makefile.am | 3 ++- src/void.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/void.c diff --git a/src/Makefile.am b/src/Makefile.am index 2d97265..240f038 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -38,7 +38,8 @@ noinst_PROGRAMS=btn0 \ mouse \ alps \ trackpoint \ - keyboardmouse + keyboardmouse \ + void noinst_LIBRARIES=$(LIBNAME) libfakedev_a_SOURCES=fakedev.c fakedev.h diff --git a/src/void.c b/src/void.c new file mode 100644 index 0000000..afa9045 --- /dev/null +++ b/src/void.c @@ -0,0 +1,77 @@ +/* + * 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) + */ + +/* simple device named VOID for void driver testing */ + +#include +#include +#include +#include + +#include "fakedev.h" + +static int void_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 void_run(int fd) +{ + return 0; +} + +static struct test_device void_dev = { + .name = "VOID", + .setup = void_setup, + .run = void_run, +}; + + +struct test_device* get_device(void) +{ + return &void_dev; +} + -- cgit v1.2.3