Blame 03-display-keymaps.patch

Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/Makefile
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- qemu-kvm-0.10.orig/qemu/Makefile
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/Makefile
Glauber Costa 47b075
@@ -141,6 +141,7 @@ endif
Glauber Costa 47b075
 AUDIO_OBJS+= wavcapture.o
Glauber Costa 47b075
 OBJS+=$(addprefix audio/, $(AUDIO_OBJS))
Glauber Costa 47b075
 
Glauber Costa 47b075
+OBJS+=keymaps.o
Glauber Costa 47b075
 ifdef CONFIG_SDL
Glauber Costa 47b075
 OBJS+=sdl.o x_keymap.o
Glauber Costa 47b075
 endif
Glauber Costa 47b075
@@ -165,15 +166,17 @@ LIBS+=$(VDE_LIBS)
Glauber Costa 47b075
 
Glauber Costa 47b075
 cocoa.o: cocoa.m
Glauber Costa 47b075
 
Glauber Costa 47b075
-sdl.o: sdl.c keymaps.c sdl_keysym.h
Glauber Costa 47b075
+keymaps.o: keymaps.c keymaps.h
Glauber Costa 47b075
+
Glauber Costa 47b075
+sdl.o: sdl.c keymaps.h sdl_keysym.h
Glauber Costa 47b075
 
Glauber Costa 47b075
 sdl.o audio/sdlaudio.o: CFLAGS += $(SDL_CFLAGS)
Glauber Costa 47b075
 
Glauber Costa 47b075
-vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h d3des.c d3des.h
Glauber Costa 47b075
+vnc.o: vnc.c keymaps.h sdl_keysym.h vnchextile.h d3des.c d3des.h
Glauber Costa 47b075
 
Glauber Costa 47b075
 vnc.o: CFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
Glauber Costa 47b075
 
Glauber Costa 47b075
-curses.o: curses.c keymaps.c curses_keys.h
Glauber Costa 47b075
+curses.o: curses.c keymaps.h curses_keys.h
Glauber Costa 47b075
 
Glauber Costa 47b075
 bt-host.o: CFLAGS += $(CONFIG_BLUEZ_CFLAGS)
Glauber Costa 47b075
 
Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/curses.c
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- qemu-kvm-0.10.orig/qemu/curses.c
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/curses.c
Glauber Costa 47b075
@@ -158,7 +158,6 @@ static void curses_cursor_position(Displ
Glauber Costa 47b075
 /* generic keyboard conversion */
Glauber Costa 47b075
 
Glauber Costa 47b075
 #include "curses_keys.h"
Glauber Costa 47b075
-#include "keymaps.c"
Glauber Costa 47b075
 
Glauber Costa 47b075
 static kbd_layout_t *kbd_layout = 0;
Glauber Costa 47b075
 static int keycode2keysym[CURSES_KEYS];
Glauber Costa 47b075
@@ -311,7 +310,7 @@ static void curses_keyboard_setup(void)
Glauber Costa 47b075
         keyboard_layout = "en-us";
Glauber Costa 47b075
 #endif
Glauber Costa 47b075
     if(keyboard_layout) {
Glauber Costa 47b075
-        kbd_layout = init_keyboard_layout(keyboard_layout);
Glauber Costa 47b075
+        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
Glauber Costa 47b075
         if (!kbd_layout)
Glauber Costa 47b075
             exit(1);
Glauber Costa 47b075
     }
Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/curses_keys.h
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- qemu-kvm-0.10.orig/qemu/curses_keys.h
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/curses_keys.h
Glauber Costa 47b075
@@ -21,6 +21,10 @@
Glauber Costa 47b075
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Glauber Costa 47b075
  * THE SOFTWARE.
Glauber Costa 47b075
  */
Glauber Costa 47b075
+
Glauber Costa 47b075
+#include "keymaps.h"
Glauber Costa 47b075
+
Glauber Costa 47b075
+
Glauber Costa 47b075
 #define KEY_RELEASE         0x80
Glauber Costa 47b075
 #define KEY_MASK            0x7f
Glauber Costa 47b075
 #define SHIFT_CODE          0x2a
Glauber Costa 47b075
@@ -239,11 +243,6 @@ static const int curses2keysym[CURSES_KE
Glauber Costa 47b075
 
Glauber Costa 47b075
 };
Glauber Costa 47b075
 
Glauber Costa 47b075
-typedef struct {
Glauber Costa 47b075
-	const char* name;
Glauber Costa 47b075
-	int keysym;
Glauber Costa 47b075
-} name2keysym_t;
Glauber Costa 47b075
-
Glauber Costa 47b075
 static const name2keysym_t name2keysym[] = {
Glauber Costa 47b075
     /* Plain ASCII */
Glauber Costa 47b075
     { "space", 0x020 },
Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/keymaps.c
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- qemu-kvm-0.10.orig/qemu/keymaps.c
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/keymaps.c
Glauber Costa 47b075
@@ -22,34 +22,20 @@
Glauber Costa 47b075
  * THE SOFTWARE.
Glauber Costa 47b075
  */
Glauber Costa 47b075
 
Glauber Costa 47b075
-static int get_keysym(const char *name)
Glauber Costa 47b075
+#include "keymaps.h"
Glauber Costa 47b075
+#include "sysemu.h"
Glauber Costa 47b075
+
Glauber Costa 47b075
+static int get_keysym(const name2keysym_t *table,
Glauber Costa 47b075
+		      const char *name)
Glauber Costa 47b075
 {
Glauber Costa 47b075
     const name2keysym_t *p;
Glauber Costa 47b075
-    for(p = name2keysym; p->name != NULL; p++) {
Glauber Costa 47b075
+    for(p = table; p->name != NULL; p++) {
Glauber Costa 47b075
         if (!strcmp(p->name, name))
Glauber Costa 47b075
             return p->keysym;
Glauber Costa 47b075
     }
Glauber Costa 47b075
     return 0;
Glauber Costa 47b075
 }
Glauber Costa 47b075
 
Glauber Costa 47b075
-struct key_range {
Glauber Costa 47b075
-    int start;
Glauber Costa 47b075
-    int end;
Glauber Costa 47b075
-    struct key_range *next;
Glauber Costa 47b075
-};
Glauber Costa 47b075
-
Glauber Costa 47b075
-#define MAX_NORMAL_KEYCODE 512
Glauber Costa 47b075
-#define MAX_EXTRA_COUNT 256
Glauber Costa 47b075
-typedef struct {
Glauber Costa 47b075
-    uint16_t keysym2keycode[MAX_NORMAL_KEYCODE];
Glauber Costa 47b075
-    struct {
Glauber Costa 47b075
-	int keysym;
Glauber Costa 47b075
-	uint16_t keycode;
Glauber Costa 47b075
-    } keysym2keycode_extra[MAX_EXTRA_COUNT];
Glauber Costa 47b075
-    int extra_count;
Glauber Costa 47b075
-    struct key_range *keypad_range;
Glauber Costa 47b075
-    struct key_range *numlock_range;
Glauber Costa 47b075
-} kbd_layout_t;
Glauber Costa 47b075
 
Glauber Costa 47b075
 static void add_to_key_range(struct key_range **krp, int code) {
Glauber Costa 47b075
     struct key_range *kr;
Glauber Costa 47b075
@@ -73,7 +59,8 @@ static void add_to_key_range(struct key_
Glauber Costa 47b075
     }
Glauber Costa 47b075
 }
Glauber Costa 47b075
 
Glauber Costa 47b075
-static kbd_layout_t *parse_keyboard_layout(const char *language,
Glauber Costa 47b075
+static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
Glauber Costa 47b075
+					   const char *language,
Glauber Costa 47b075
 					   kbd_layout_t * k)
Glauber Costa 47b075
 {
Glauber Costa 47b075
     FILE *f;
Glauber Costa 47b075
@@ -102,7 +89,7 @@ static kbd_layout_t *parse_keyboard_layo
Glauber Costa 47b075
 	if (!strncmp(line, "map ", 4))
Glauber Costa 47b075
 	    continue;
Glauber Costa 47b075
 	if (!strncmp(line, "include ", 8)) {
Glauber Costa 47b075
-	    parse_keyboard_layout(line + 8, k);
Glauber Costa 47b075
+	    parse_keyboard_layout(table, line + 8, k);
Glauber Costa 47b075
         } else {
Glauber Costa 47b075
 	    char *end_of_keysym = line;
Glauber Costa 47b075
 	    while (*end_of_keysym != 0 && *end_of_keysym != ' ')
Glauber Costa 47b075
@@ -110,7 +97,7 @@ static kbd_layout_t *parse_keyboard_layo
Glauber Costa 47b075
 	    if (*end_of_keysym) {
Glauber Costa 47b075
 		int keysym;
Glauber Costa 47b075
 		*end_of_keysym = 0;
Glauber Costa 47b075
-		keysym = get_keysym(line);
Glauber Costa 47b075
+		keysym = get_keysym(table, line);
Glauber Costa 47b075
 		if (keysym == 0) {
Glauber Costa 47b075
                     //		    fprintf(stderr, "Warning: unknown keysym %s\n", line);
Glauber Costa 47b075
 		} else {
Glauber Costa 47b075
@@ -154,12 +141,14 @@ static kbd_layout_t *parse_keyboard_layo
Glauber Costa 47b075
     return k;
Glauber Costa 47b075
 }
Glauber Costa 47b075
 
Glauber Costa 47b075
-static void *init_keyboard_layout(const char *language)
Glauber Costa 47b075
+
Glauber Costa 47b075
+void *init_keyboard_layout(const name2keysym_t *table, const char *language)
Glauber Costa 47b075
 {
Glauber Costa 47b075
-    return parse_keyboard_layout(language, 0);
Glauber Costa 47b075
+    return parse_keyboard_layout(table, language, 0);
Glauber Costa 47b075
 }
Glauber Costa 47b075
 
Glauber Costa 47b075
-static int keysym2scancode(void *kbd_layout, int keysym)
Glauber Costa 47b075
+
Glauber Costa 47b075
+int keysym2scancode(void *kbd_layout, int keysym)
Glauber Costa 47b075
 {
Glauber Costa 47b075
     kbd_layout_t *k = kbd_layout;
Glauber Costa 47b075
     if (keysym < MAX_NORMAL_KEYCODE) {
Glauber Costa 47b075
@@ -180,7 +169,7 @@ static int keysym2scancode(void *kbd_lay
Glauber Costa 47b075
     return 0;
Glauber Costa 47b075
 }
Glauber Costa 47b075
 
Glauber Costa 47b075
-static inline int keycode_is_keypad(void *kbd_layout, int keycode)
Glauber Costa 47b075
+int keycode_is_keypad(void *kbd_layout, int keycode)
Glauber Costa 47b075
 {
Glauber Costa 47b075
     kbd_layout_t *k = kbd_layout;
Glauber Costa 47b075
     struct key_range *kr;
Glauber Costa 47b075
@@ -191,7 +180,7 @@ static inline int keycode_is_keypad(void
Glauber Costa 47b075
     return 0;
Glauber Costa 47b075
 }
Glauber Costa 47b075
 
Glauber Costa 47b075
-static inline int keysym_is_numlock(void *kbd_layout, int keysym)
Glauber Costa 47b075
+int keysym_is_numlock(void *kbd_layout, int keysym)
Glauber Costa 47b075
 {
Glauber Costa 47b075
     kbd_layout_t *k = kbd_layout;
Glauber Costa 47b075
     struct key_range *kr;
Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/keymaps.h
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- /dev/null
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/keymaps.h
Glauber Costa 47b075
@@ -0,0 +1,60 @@
Glauber Costa 47b075
+/*
Glauber Costa 47b075
+ * QEMU keysym to keycode conversion using rdesktop keymaps
Glauber Costa 47b075
+ *
Glauber Costa 47b075
+ * Copyright (c) 2004 Johannes Schindelin
Glauber Costa 47b075
+ *
Glauber Costa 47b075
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
Glauber Costa 47b075
+ * of this software and associated documentation files (the "Software"), to deal
Glauber Costa 47b075
+ * in the Software without restriction, including without limitation the rights
Glauber Costa 47b075
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Glauber Costa 47b075
+ * copies of the Software, and to permit persons to whom the Software is
Glauber Costa 47b075
+ * furnished to do so, subject to the following conditions:
Glauber Costa 47b075
+ *
Glauber Costa 47b075
+ * The above copyright notice and this permission notice shall be included in
Glauber Costa 47b075
+ * all copies or substantial portions of the Software.
Glauber Costa 47b075
+ *
Glauber Costa 47b075
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Glauber Costa 47b075
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Glauber Costa 47b075
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
Glauber Costa 47b075
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Glauber Costa 47b075
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Glauber Costa 47b075
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Glauber Costa 47b075
+ * THE SOFTWARE.
Glauber Costa 47b075
+ */
Glauber Costa 47b075
+
Glauber Costa 47b075
+#ifndef __QEMU_KEYMAPS_H__
Glauber Costa 47b075
+#define __QEMU_KEYMAPS_H__
Glauber Costa 47b075
+
Glauber Costa 47b075
+#include "qemu-common.h"
Glauber Costa 47b075
+
Glauber Costa 47b075
+typedef struct {
Glauber Costa 47b075
+	const char* name;
Glauber Costa 47b075
+	int keysym;
Glauber Costa 47b075
+} name2keysym_t;
Glauber Costa 47b075
+
Glauber Costa 47b075
+struct key_range {
Glauber Costa 47b075
+    int start;
Glauber Costa 47b075
+    int end;
Glauber Costa 47b075
+    struct key_range *next;
Glauber Costa 47b075
+};
Glauber Costa 47b075
+
Glauber Costa 47b075
+#define MAX_NORMAL_KEYCODE 512
Glauber Costa 47b075
+#define MAX_EXTRA_COUNT 256
Glauber Costa 47b075
+typedef struct {
Glauber Costa 47b075
+    uint16_t keysym2keycode[MAX_NORMAL_KEYCODE];
Glauber Costa 47b075
+    struct {
Glauber Costa 47b075
+	int keysym;
Glauber Costa 47b075
+	uint16_t keycode;
Glauber Costa 47b075
+    } keysym2keycode_extra[MAX_EXTRA_COUNT];
Glauber Costa 47b075
+    int extra_count;
Glauber Costa 47b075
+    struct key_range *keypad_range;
Glauber Costa 47b075
+    struct key_range *numlock_range;
Glauber Costa 47b075
+} kbd_layout_t;
Glauber Costa 47b075
+
Glauber Costa 47b075
+
Glauber Costa 47b075
+void *init_keyboard_layout(const name2keysym_t *table, const char *language);
Glauber Costa 47b075
+int keysym2scancode(void *kbd_layout, int keysym);
Glauber Costa 47b075
+int keycode_is_keypad(void *kbd_layout, int keycode);
Glauber Costa 47b075
+int keysym_is_numlock(void *kbd_layout, int keysym);
Glauber Costa 47b075
+
Glauber Costa 47b075
+#endif /* __QEMU_KEYMAPS_H__ */
Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/sdl.c
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- qemu-kvm-0.10.orig/qemu/sdl.c
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/sdl.c
Glauber Costa 47b075
@@ -109,7 +109,6 @@ static void sdl_resize(DisplayState *ds)
Glauber Costa 47b075
 /* generic keyboard conversion */
Glauber Costa 47b075
 
Glauber Costa 47b075
 #include "sdl_keysym.h"
Glauber Costa 47b075
-#include "keymaps.c"
Glauber Costa 47b075
 
Glauber Costa 47b075
 static kbd_layout_t *kbd_layout = NULL;
Glauber Costa 47b075
 
Glauber Costa 47b075
@@ -677,7 +676,7 @@ void sdl_display_init(DisplayState *ds, 
Glauber Costa 47b075
         keyboard_layout = "en-us";
Glauber Costa 47b075
 #endif
Glauber Costa 47b075
     if(keyboard_layout) {
Glauber Costa 47b075
-        kbd_layout = init_keyboard_layout(keyboard_layout);
Glauber Costa 47b075
+        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
Glauber Costa 47b075
         if (!kbd_layout)
Glauber Costa 47b075
             exit(1);
Glauber Costa 47b075
     }
Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/sdl_keysym.h
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- qemu-kvm-0.10.orig/qemu/sdl_keysym.h
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/sdl_keysym.h
Glauber Costa 47b075
@@ -1,7 +1,6 @@
Glauber Costa 47b075
-typedef struct {
Glauber Costa 47b075
-	const char* name;
Glauber Costa 47b075
-	int keysym;
Glauber Costa 47b075
-} name2keysym_t;
Glauber Costa 47b075
+
Glauber Costa 47b075
+#include "keymaps.h"
Glauber Costa 47b075
+
Glauber Costa 47b075
 static const name2keysym_t name2keysym[]={
Glauber Costa 47b075
 /* ascii */
Glauber Costa 47b075
     { "space",                0x020},
Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/vnc.c
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- qemu-kvm-0.10.orig/qemu/vnc.c
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/vnc.c
Glauber Costa 47b075
@@ -35,7 +35,6 @@
Glauber Costa 47b075
 
Glauber Costa 47b075
 #include "vnc.h"
Glauber Costa 47b075
 #include "vnc_keysym.h"
Glauber Costa 47b075
-#include "keymaps.c"
Glauber Costa 47b075
 #include "d3des.h"
Glauber Costa 47b075
 
Glauber Costa 47b075
 #ifdef CONFIG_VNC_TLS
Glauber Costa 47b075
@@ -2420,9 +2419,9 @@ void vnc_display_init(DisplayState *ds)
Glauber Costa 47b075
     vs->ds = ds;
Glauber Costa 47b075
 
Glauber Costa 47b075
     if (keyboard_layout)
Glauber Costa 47b075
-        vs->kbd_layout = init_keyboard_layout(keyboard_layout);
Glauber Costa 47b075
+        vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
Glauber Costa 47b075
     else
Glauber Costa 47b075
-        vs->kbd_layout = init_keyboard_layout("en-us");
Glauber Costa 47b075
+        vs->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
Glauber Costa 47b075
 
Glauber Costa 47b075
     if (!vs->kbd_layout)
Glauber Costa 47b075
 	exit(1);
Glauber Costa 47b075
Index: qemu-kvm-0.10/qemu/vnc_keysym.h
Glauber Costa 47b075
===================================================================
Glauber Costa 47b075
--- qemu-kvm-0.10.orig/qemu/vnc_keysym.h
Glauber Costa 47b075
+++ qemu-kvm-0.10/qemu/vnc_keysym.h
Glauber Costa 47b075
@@ -1,7 +1,6 @@
Glauber Costa 47b075
-typedef struct {
Glauber Costa 47b075
-	const char* name;
Glauber Costa 47b075
-	int keysym;
Glauber Costa 47b075
-} name2keysym_t;
Glauber Costa 47b075
+
Glauber Costa 47b075
+#include "keymaps.h"
Glauber Costa 47b075
+
Glauber Costa 47b075
 static const name2keysym_t name2keysym[]={
Glauber Costa 47b075
 /* ascii */
Glauber Costa 47b075
     { "space",                0x020},