From: Alexandre Bique Date: Wed, 22 Jul 2009 11:46:06 +0000 (+0000) Subject: [dom0-driver] Better switch and added an array for the passthrough keys. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=6edae919724e015cf0a368102d72cdf547aa6f86;p=xenclient%2Fioemu-pq.git [dom0-driver] Better switch and added an array for the passthrough keys. --- diff --git a/master/dom0-driver b/master/dom0-driver index 37eb508..b5a630c 100644 --- a/master/dom0-driver +++ b/master/dom0-driver @@ -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)