aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2018-02-22 08:05:11 +0100
committerGerd Hoffmann <kraxel@redhat.com>2018-02-22 10:35:22 +0100
commit6b71ea1138307a0fbc0273df8866ca9879b7ba4c (patch)
tree71130b1e6761a065c57e3a8c4ef2a556f07cde05 /ui
parentd713e3fd4c1da510a31313e1d3cc51c89b8036f3 (diff)
downloadqemu-6b71ea1138307a0fbc0273df8866ca9879b7ba4c.zip
qemu-6b71ea1138307a0fbc0273df8866ca9879b7ba4c.tar.gz
qemu-6b71ea1138307a0fbc0273df8866ca9879b7ba4c.tar.bz2
keymap: numpad keysyms and keycodes are fixed
No need to figure them at runtime from the keymap. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-id: 20180222070513.8740-4-kraxel@redhat.com
Diffstat (limited to 'ui')
-rw-r--r--ui/keymaps.c61
1 files changed, 9 insertions, 52 deletions
diff --git a/ui/keymaps.c b/ui/keymaps.c
index 449c3de..cbdd65c 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -28,20 +28,12 @@
#include "trace.h"
#include "qemu/error-report.h"
-struct key_range {
- int start;
- int end;
- struct key_range *next;
-};
-
struct keysym2code {
uint16_t keycode;
};
struct kbd_layout_t {
GHashTable *hash;
- struct key_range *keypad_range;
- struct key_range *numlock_range;
};
static int get_keysym(const name2keysym_t *table,
@@ -64,29 +56,6 @@ static int get_keysym(const name2keysym_t *table,
}
-static void add_to_key_range(struct key_range **krp, int code) {
- struct key_range *kr;
- for (kr = *krp; kr; kr = kr->next) {
- if (code >= kr->start && code <= kr->end) {
- break;
- }
- if (code == kr->start - 1) {
- kr->start--;
- break;
- }
- if (code == kr->end + 1) {
- kr->end++;
- break;
- }
- }
- if (kr == NULL) {
- kr = g_malloc0(sizeof(*kr));
- kr->start = kr->end = code;
- kr->next = *krp;
- *krp = kr;
- }
-}
-
static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *k)
{
struct keysym2code *keysym2code;
@@ -160,13 +129,6 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
const char *rest = line + offset + 1;
int keycode = strtol(rest, NULL, 0);
- if (strstr(rest, "numlock")) {
- add_to_key_range(&k->keypad_range, keycode);
- add_to_key_range(&k->numlock_range, keysym);
- /* fprintf(stderr, "keypad keysym %04x keycode %d\n",
- keysym, keycode); */
- }
-
if (strstr(rest, "shift")) {
keycode |= SCANCODE_SHIFT;
}
@@ -228,24 +190,19 @@ int keysym2scancode(kbd_layout_t *k, int keysym)
int keycode_is_keypad(kbd_layout_t *k, int keycode)
{
- struct key_range *kr;
-
- for (kr = k->keypad_range; kr; kr = kr->next) {
- if (keycode >= kr->start && keycode <= kr->end) {
- return 1;
- }
+ if (keycode >= 0x47 && keycode <= 0x53) {
+ return true;
}
- return 0;
+ return false;
}
int keysym_is_numlock(kbd_layout_t *k, int keysym)
{
- struct key_range *kr;
-
- for (kr = k->numlock_range; kr; kr = kr->next) {
- if (keysym >= kr->start && keysym <= kr->end) {
- return 1;
- }
+ switch (keysym) {
+ case 0xffb0 ... 0xffb9: /* KP_0 .. KP_9 */
+ case 0xffac: /* KP_Separator */
+ case 0xffae: /* KP_Decimal */
+ return true;
}
- return 0;
+ return false;
}