summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2008-12-19 08:27:47 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2008-12-19 16:45:22 +1000
commit268038270593aae45e2740ad2151243383743c1d (patch)
treed69b2f368e0e93a35ca259b52f1f375e2d42a98a /test
parent0f36384d0636d6a8d3a8f182be69c72cccd1ff5c (diff)
Add dummy test device - simple device that doesn't move at all.
Good for filling up the device list without getting distracted by spurious events all the time.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am5
-rw-r--r--test/dummy.c77
2 files changed, 81 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 4b417b8..09a1979 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -18,7 +18,7 @@
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-noinst_PROGRAMS=fakedev btn0 absrel abs
+noinst_PROGRAMS=fakedev btn0 absrel abs dummy
fakedev_SOURCES=fakedev.c fakedev.h
fakedev_LDFLAGS=$(DLOPEN_LIBS) -rdynamic
@@ -33,3 +33,6 @@ absrel_LDFLAGS=$(LFLAGS)
abs_SOURCES=abs.c
abs_LDFLAGS=$(LFLAGS)
+
+dummy_SOURCES=dummy.c
+dummy_LDFLAGS=$(LFLAGS)
diff --git a/test/dummy.c b/test/dummy.c
new file mode 100644
index 0000000..ffb5fe5
--- /dev/null
+++ b/test/dummy.c
@@ -0,0 +1,77 @@
+/*
+ * 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)
+ */
+
+/* dummy device, looks like a mouse but doesn't do anything.
+ * Good for filling up the device list.
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+int dummy_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;
+
+ /* 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;
+}
+
+int dummy_run(int fd)
+{
+ usleep(1000);
+ return 0;
+}
+
+struct test_device dummy_dev = {
+ .name = "dummy_ test device",
+ .setup = dummy_setup,
+ .run = dummy_run,
+};
+
+
+struct test_device* get_device()
+{
+ return &dummy_dev;
+}
+