summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-12-20 14:40:37 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-12-20 15:06:14 +1000
commitec8404a867de9f3f0ec7fb48f7f4c0688f9cedfe (patch)
treea38ffa868076282084c642f3e513d525389a95f6
parent18170a7bb0375fd8084817faf2a0bea8b72fb0f7 (diff)
Add ntrig multitouch device
-rw-r--r--src/Makefile.am1
-rw-r--r--src/ntrig.c112
2 files changed, 113 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d8b941d..de6d43e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,6 +57,7 @@ noinst_PROGRAMS=btn0 \
joystick \
relwheel \
ntrig_pen \
+ ntrig \
relz \
39663
noinst_LIBRARIES=$(LIBNAME)
diff --git a/src/ntrig.c b/src/ntrig.c
new file mode 100644
index 0000000..401d81e
--- /dev/null
+++ b/src/ntrig.c
@@ -0,0 +1,112 @@
+/*
+ * 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;
+ if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -1) goto error;
+ if (ioctl(fd, UI_SET_EVBIT, EV_KEY) == -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_TOUCH_MAJOR) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_MT_TOUCH_MINOR) == -1) goto error;
+ if (ioctl(fd, UI_SET_ABSBIT, ABS_MT_ORIENTATION) == -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;
+
+ dev->absmin[ABS_X] = 0;
+ dev->absmax[ABS_X] = 9600;
+ dev->absmin[ABS_Y] = 0;
+ dev->absmax[ABS_Y] = 7200;
+ dev->absmin[ABS_MT_ORIENTATION] = 0;
+ dev->absmax[ABS_MT_ORIENTATION] = 1;
+ dev->absmin[ABS_MT_TOUCH_MAJOR] = 0;
+ dev->absmax[ABS_MT_TOUCH_MAJOR] = 9600;
+ dev->absmin[ABS_MT_TOUCH_MINOR] = 0;
+ dev->absmax[ABS_MT_TOUCH_MINOR] = 7200;
+ dev->absmin[ABS_MT_POSITION_X] = 0;
+ dev->absmax[ABS_MT_POSITION_X] = 9600;
+ dev->absmin[ABS_MT_POSITION_Y] = 0;
+ dev->absmax[ABS_MT_POSITION_Y] = 7200;
+
+ return 0;
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int ntrig_pen_run(int fd)
+{
+ send_event(fd, EV_ABS, ABS_MT_POSITION_X, 1000);
+ send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 1000);
+ send_event(fd, EV_SYN, SYN_MT_REPORT, 0);
+ send_event(fd, EV_KEY, BTN_TOUCH, 1);
+ send_event(fd, EV_ABS, ABS_X, 1000);
+ send_event(fd, EV_ABS, ABS_Y, 1000);
+ syn(fd);
+ sleep(1);
+ send_event(fd, EV_ABS, ABS_MT_POSITION_X, 2000);
+ send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 2000);
+ send_event(fd, EV_SYN, SYN_MT_REPORT, 0);
+ send_event(fd, EV_ABS, ABS_X, 2000);
+ send_event(fd, EV_ABS, ABS_Y, 2000);
+ syn(fd);
+ sleep(1);
+ send_event(fd, EV_ABS, ABS_MT_POSITION_X, 3000);
+ send_event(fd, EV_ABS, ABS_MT_POSITION_Y, 3000);
+ send_event(fd, EV_SYN, SYN_MT_REPORT, 0);
+ send_event(fd, EV_KEY, BTN_TOUCH, 0);
+ send_event(fd, EV_ABS, ABS_X, 3000);
+ send_event(fd, EV_ABS, ABS_Y, 3000);
+ syn(fd);
+ sleep(1);
+ return 0;
+}
+
+static struct test_device ntrig_pen_dev = {
+ .name = "N-Trig MultiTouch",
+ .setup = ntrig_pen_setup,
+ .run = ntrig_pen_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &ntrig_pen_dev;
+}
+