#endif
diff --git a/dom0_driver.c b/dom0_driver.c
new file mode 100644
-index 0000000..1b5cd06
+index 0000000..fdd24ab
--- /dev/null
+++ b/dom0_driver.c
@@ -0,0 +1,697 @@
+}
diff --git a/hid-linux.c b/hid-linux.c
new file mode 100644
-index 0000000..4ec6bdd
+index 0000000..59dfec8
--- /dev/null
+++ b/hid-linux.c
-@@ -0,0 +1,513 @@
+@@ -0,0 +1,527 @@
+/*
+ * QEMU hid-linux /dev/input driver
+ *
+
+void hid_linux_probe(int grab)
+{
-+ int i = 0, j = 0, c = 0;
-+ int fd = -1;
-+ int keyboard = 0, mouse = 0;
-+ char path[strlen(EVENT_PATH) + 3];
-+ char name[128];
-+ int *controllers;
++ int i = 0, j = 0, c = 0;
++ int fd = -1;
++ int keyboard = 0, mouse = 0;
++ char path[strlen(EVENT_PATH) + 3];
++ char name[128];
++ int *controllers;
++ struct input_id id;
+ struct stat st;
+
+ while (1)
+ {
++ if (fd != -1)
++ close(fd);
++
+ sprintf(path, "%s%i", EVENT_PATH, i++);
+
+ if (stat(path, &st) == -1)
+ if (ioctl(fd, EVIOCGNAME(128), name) == -1)
+ {
+ DEBUG("Input get name failed on %s\n", path);
-+ break;
++ break;
+ }
+
-+ if (strcasestr(name, "keyboard"))
++ if (ioctl(fd, EVIOCGID, &id) == -1)
+ {
-+ DEBUG("Add %s %s as a keyboard, fd=%d\n", path, name, fd);
-+ controllers = hid_linux_driver.keyboard_fds;
-+ }
-+ else
-+ {
-+ DEBUG("Add %s %s as a mouse, fd=%d\n", path, name, fd);
-+ controllers = hid_linux_driver.mouse_fds;
++ DEBUG("Input get id failed on %s\n", path);
++ continue;
+ }
+
++ /* Only get devices on usb and i8042 */
++ if (id.bustype != BUS_I8042 && id.bustype != BUS_USB)
++ continue;
++
++ if (strcasestr(name, "keyboard"))
++ {
++ DEBUG("Add %s %s as a keyboard, fd=%d, bus=%d\n", path, name, fd, id.bustype);
++ controllers = hid_linux_driver.keyboard_fds;
++ }
++ else
++ {
++ DEBUG("Add %s %s as a mouse, fd=%d, bus=%d\n", path, name, fd, id.bustype);
++ controllers = hid_linux_driver.mouse_fds;
++ }
++
+ for ( j = 0; j < (HID_LINUX_MAX_DEV / 2) && controllers[j] != -1; j++)
+ ;
+ assert(j != (HID_LINUX_MAX_DEV / 2));
main_loop();
diff --git a/xen-hooks.mak b/xen-hooks.mak
-index 7c94718..f243df1 100644
+index d171928..15ba4d1 100644
--- a/xen-hooks.mak
+++ b/xen-hooks.mak
@@ -37,6 +37,8 @@ OBJS += helper2.o
+OBJS += dom0_driver.o
+OBJS += hid-linux.o
- ifdef CONFIG_STUBDOM
- CPPFLAGS += $(TARGET_CPPFLAGS) -DNEED_CPU_H \
+ CONFIG_AUDIO=1
+
diff --git a/xenstore.c b/xenstore.c
index 01afcf0..20ca8cf 100644
--- a/xenstore.c