]> xenbits.xensource.com Git - xenclient/ioemu-pq.git/commitdiff
[dom0-driver] Better switch and added an array for the passthrough keys.
authorAlexandre Bique <alexandre.bique@citrix.com>
Wed, 22 Jul 2009 11:46:06 +0000 (11:46 +0000)
committerAlexandre Bique <alexandre.bique@citrix.com>
Wed, 22 Jul 2009 11:46:06 +0000 (11:46 +0000)
master/dom0-driver

index 37eb5085b8e246c08367ca647f380ee55c72a3f2..b5a630cbe0fb180f0b36a8516b332f8854d91f9b 100644 (file)
@@ -742,10 +742,10 @@ index 0000000..a747911
 +}
 diff --git a/hid-linux.c b/hid-linux.c
 new file mode 100644
-index 0000000..9e09f97
+index 0000000..8b1a477
 --- /dev/null
 +++ b/hid-linux.c
-@@ -0,0 +1,557 @@
+@@ -0,0 +1,574 @@
 +/*
 + * QEMU hid-linux /dev/input driver
 + *
@@ -839,6 +839,17 @@ index 0000000..9e09f97
 +    KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z
 +};
 +
++static const uint32_t keycodes_pt[] = {
++    KEY_LEFTALT, KEY_RIGHTALT,
++    KEY_LEFTCTRL, KEY_RIGHTCTRL,
++    KEY_MSDOS,
++};
++
++static uint32_t const * const keycodes_pt_end =
++    keycodes_pt + sizeof (keycodes_pt) / sizeof (keycodes_pt[0]);
++
++
++
 +static void hid_linux_secure_read(void *opaque);
 +
 +static char keycode2ascii(int keycode)
@@ -989,10 +1000,10 @@ index 0000000..9e09f97
 +    if (!hid_linux_driver.has_mouse)
 +        return false;
 +
-+    /* If Alt is pressed or just released, pass through */
-+    if (hid_linux_driver.key_status[KEY_LEFTALT] ||
-+        keycode == KEY_LEFTALT)
-+        return true;
++    for (const uint32_t * k = keycodes_pt; k != keycodes_pt_end; k++)
++        /* If Alt is pressed or just released, pass through */
++        if (hid_linux_driver.key_status[*k] || keycode == *k)
++            return true;
 +    return false;
 +}
 +
@@ -1121,14 +1132,20 @@ index 0000000..9e09f97
 +
 +void hid_linux_reset_keyboard(void)
 +{
-+    int i = 0;
-+
-+    for (i = 0; i < 256; i++)
++    for (int i = 0; i < 256; i++)
++    {
++        for (const uint32_t * k = keycodes_pt; k != keycodes_pt_end; k++)
++            if (i == *k)
++                goto no_reset;
 +      if (hid_linux_driver.key_status[i])
 +      {
 +          hid_linux_key_inject(0, i);
 +          hid_linux_driver.key_status[i] = 0;
 +      }
++
++      no_reset:
++        continue;
++    }
 +}
 +
 +static void hid_linux_redirect_fds(int *fd, IOHandler *cb)