summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-10-23 13:43:33 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-10-23 13:43:52 +1000
commit6b7dae659315c46ef88225ac0f310aac79cc7bb0 (patch)
tree7cd799c1099cd9014a0dca5898539e7587f1d3f1
parenta191b4a3ec7667b546547ea4cff7ee766c969da1 (diff)
Add xen virtual pointer and American Megatrends KVM.
-rw-r--r--src/Makefile.am4
-rw-r--r--src/kvm.c89
-rw-r--r--src/xen-vp.c100
3 files changed, 192 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3869e84..5046274 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,7 +40,9 @@ noinst_PROGRAMS=btn0 \
trackpoint \
keyboardmouse \
void \
- rumblepad
+ rumblepad \
+ xen-vp \
+ kvm
noinst_LIBRARIES=$(LIBNAME)
libfakedev_a_SOURCES=fakedev.c fakedev.h
diff --git a/src/kvm.c b/src/kvm.c
new file mode 100644
index 0000000..c257deb
--- /dev/null
+++ b/src/kvm.c
@@ -0,0 +1,89 @@
+/*
+ * 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)
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/input.h>
+#include <linux/uinput.h>
+
+#include "fakedev.h"
+
+static int kvm_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;
+ if (ioctl(fd, UI_SET_EVBIT, EV_MSC) == -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;
+
+
+ dev->absmin[ABS_X] = 0;
+ dev->absmax[ABS_X] = 1024;
+
+ dev->absmin[ABS_Y] = 0;
+ dev->absmax[ABS_Y] = 768;
+
+ dev->id.bustype = 0x3;
+ dev->id.vendor = 0x046b;
+ dev->id.product = 0xff10;
+ dev->id.version = 0x0110;
+
+ return 0;
+
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int kvm_run(int fd)
+{
+ absmove(fd, 100, 100);
+ sleep(1);
+ absmove(fd, 120, 120);
+ sleep(1);
+ return 0;
+}
+
+static struct test_device kvm_dev = {
+ .name = "American Megatrends Inc. Virtual Keyboard and Mouse",
+ .setup = kvm_setup,
+ .run = kvm_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &kvm_dev;
+}
diff --git a/src/xen-vp.c b/src/xen-vp.c
new file mode 100644
index 0000000..741619f
--- /dev/null
+++ b/src/xen-vp.c
@@ -0,0 +1,100 @@
+/*
+ * 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)
+ */
+
+
+/* creates a device with ABS_X, ABS_Y, REL_X, REL_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 xenvp_setup(struct uinput_user_dev* dev, int fd)
+{
+ 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;
+
+ /* 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;
+
+ 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] = 100;
+
+ dev->absmin[ABS_Y] = 0;
+ dev->absmax[ABS_Y] = 100;
+
+ return 0;
+
+error:
+ perror("ioctl failed.");
+ return -1;
+}
+
+static int xenvp_run(int fd)
+{
+ move(fd, 1, 1);
+ usleep(500000);
+ move(fd, 1, 1);
+ usleep(500000);
+ move(fd, 1, 1);
+ usleep(500000);
+ move(fd, 1, 1);
+ usleep(500000);
+ move(fd, 1, 1);
+ usleep(500000);
+ absmove(fd, 50, 50);
+ usleep(500000);
+ absmove(fd, 90, 90);
+ usleep(500000);
+ return 0;
+}
+
+static struct test_device xenvp_dev = {
+ .name = "Xen Virtual Pointer",
+ .setup = xenvp_setup,
+ .run = xenvp_run,
+};
+
+
+struct test_device* get_device(void)
+{
+ return &xenvp_dev;
+}
+