]> xenbits.xen.org Git - xenclient/ioemu-pq.git/commitdiff
[dom0-driver] we can now connect and disconnect mouse and keyboad.
authorAlexandre Bique <alexandre.bique@citrix.com>
Tue, 21 Jul 2009 16:30:08 +0000 (16:30 +0000)
committerAlexandre Bique <alexandre.bique@citrix.com>
Tue, 21 Jul 2009 16:30:08 +0000 (16:30 +0000)
master/dom0-driver

index bcd84f43650af15b6ee1e77c6a5d279ea09420d5..7bcd95b25a8d10c46acf7b0f41a4943820301386 100644 (file)
@@ -748,10 +748,10 @@ index 0000000..bdfe37c
 +}
 diff --git a/hid-linux.c b/hid-linux.c
 new file mode 100644
-index 0000000..00790b5
+index 0000000..51f70c2
 --- /dev/null
 +++ b/hid-linux.c
-@@ -0,0 +1,501 @@
+@@ -0,0 +1,538 @@
 +/*
 + * QEMU hid-linux /dev/input driver
 + *
@@ -796,6 +796,7 @@ index 0000000..00790b5
 +#include <assert.h>
 +#include <time.h>
 +#include <sys/time.h>
++#include <poll.h>
 +
 +#define HID_LINUX_XS_PATH             "/local/domain/0/hid_linux"
 +#define ABS(x)                        ((x) > 0 ? (x) : -(x))
@@ -1007,6 +1008,8 @@ index 0000000..00790b5
 +    int                 fd = *(int *)opaque;
 +
 +    read_sz = read(fd, event, sizeof (event));
++    if (read_sz <= 0)
++        return;
 +    for (i = 0; i < read_sz / (sizeof (struct input_event)); i++)
 +    {
 +      if (event[i].type == EV_KEY &&
@@ -1090,6 +1093,8 @@ index 0000000..00790b5
 +    int                 fd = *(int *)opaque;
 +
 +    read_sz = read(fd, event, sizeof (event));
++    if (read_sz <= 0)
++        return;
 +    for (i = 0; i < read_sz / (sizeof (struct input_event)); i++)
 +    {
 +      if (event[i].type == EV_KEY &&
@@ -1134,6 +1139,8 @@ index 0000000..00790b5
 +    assert(hid_linux_driver.secure_key);
 +
 +    read_sz = read(fd, event, sizeof (event));
++    if (read_sz <= 0)
++        return;
 +    for (i = 0; i < read_sz / (sizeof (struct input_event)); i++)
 +      if (event[i].type == EV_KEY && event[i].code < BTN_MOUSE &&
 +              event[i].value > 0)
@@ -1180,8 +1187,38 @@ index 0000000..00790b5
 +   return 1;
 +}
 +
++static void hid_linux_check_dead_fd(void)
++{
++    struct pollfd pfds[HID_LINUX_MAX_DEV];
++
++    for (int i = 0; i < HID_LINUX_MAX_DEV; i++)
++    {
++        pfds[i].fd = hid_linux_driver.evdev_fds[i];
++        pfds[i].events = 0;
++    }
++
++    int ret = poll(pfds, HID_LINUX_MAX_DEV, 1 /* timeout */);
++    if (ret == 0) // nothing to tell
++        return;
++    if (ret < 0) // error
++    {
++        DEBUG("poll failed: %s\n", strerror(errno));
++        return;
++    }
++
++    for (int i = 0; i < HID_LINUX_MAX_DEV; i++)
++        if (pfds[i].revents & POLLERR)
++        {
++            DEBUG("dead fd: %d\n", hid_linux_driver.evdev_fds[i]);
++            close(hid_linux_driver.evdev_fds[i]);
++            hid_linux_driver.evdev_fds[i] = -1;
++        }
++}
++
 +void hid_linux_probe(int grab __attribute__((unused)))
 +{
++    hid_linux_check_dead_fd();
++
 +    for (int i = 0; i < HID_LINUX_MAX_DEV; i++)
 +    {
 +        int             fd;
@@ -1342,7 +1379,7 @@ index 1738aa5..45e03c1 100644
  
  #ifndef CONFIG_STUBDOM
 diff --git a/xen-hooks.mak b/xen-hooks.mak
-index 3b60724..8dc3885 100644
+index d171928..15ba4d1 100644
 --- a/xen-hooks.mak
 +++ b/xen-hooks.mak
 @@ -37,6 +37,8 @@ OBJS += helper2.o