#DPATCHLEVEL=1 diff -ur qemu-0.6.1/sdl.c qemu/sdl.c --- qemu-0.6.1/sdl.c 2004-11-14 21:51:33.000000000 +0100 +++ qemu/sdl.c 2004-11-27 20:37:14.000000000 +0100 @@ -72,7 +72,6 @@ ds->height = h; } -#ifdef CONFIG_SDL_GENERIC_KBD /* XXX: use keymap tables defined in the VNC patch because the following code suppose you have a US keyboard. */ @@ -131,6 +130,7 @@ [SDLK_COMMA] = 0x33, [SDLK_PERIOD] = 0x34, [SDLK_SLASH] = 0x35, + [SDLK_RSHIFT] = 0x36, [SDLK_KP_MULTIPLY] = 0x37, [SDLK_LALT] = 0x38, [SDLK_SPACE] = 0x39, @@ -178,20 +178,16 @@ [SDLK_DELETE] = 0xd3, }; -static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) +static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev) { return scancodes[ev->keysym.sym]; } -#elif defined(_WIN32) - -static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) +static uint8_t sdl_keyevent_to_keycode_direct(const SDL_KeyboardEvent *ev) { return ev->keysym.scancode; } -#else - static const uint8_t x_keycode_to_pc_keycode[61] = { 0xc7, /* 97 Home */ 0xc8, /* 98 Up */ @@ -256,7 +252,7 @@ 0x53, /* 157 KP_Del */ }; -static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev) +static uint8_t sdl_keyevent_to_keycode_xf86(const SDL_KeyboardEvent *ev) { int keycode; @@ -275,8 +271,30 @@ return keycode; } +#ifdef CONFIG_SDL_GENERIC_KBD +#define DEFAULT_KEYEVENT_TO_KEYCODE sdl_keyevent_to_keycode_generic +#elif defined(_WIN32) +#define DEFAULT_KEYEVENT_TO_KEYCODE sdl_keyevent_to_keycode_direct +#else +#define DEFAULT_KEYEVENT_TO_KEYCODE sdl_keyevent_to_keycode_xf86 #endif +static uint8_t (* sdl_keyevent_to_keycode) (const SDL_KeyboardEvent *ev) = DEFAULT_KEYEVENT_TO_KEYCODE; + +void qemu_keyboard_set_sdl_method(const char *method) +{ + if (strcmp(method, "generic")==0) + sdl_keyevent_to_keycode = sdl_keyevent_to_keycode_generic; + else if (strcmp(method, "direct")==0) + sdl_keyevent_to_keycode = sdl_keyevent_to_keycode_direct; + else if (strcmp(method, "xf86")==0) + sdl_keyevent_to_keycode = sdl_keyevent_to_keycode_xf86; + else + fprintf(stderr, "Unknown keyboard method `%s', ignoring\n", + method); +} + + static void reset_keys(void) { int i; diff -ur qemu-0.6.1/vl.c qemu/vl.c --- qemu-0.6.1/vl.c 2004-11-14 21:51:33.000000000 +0100 +++ qemu/vl.c 2004-11-27 20:41:14.000000000 +0100 @@ -2502,6 +2502,8 @@ "-m megs set virtual RAM size to megs MB [default=%d]\n" "-nographic disable graphical output and redirect serial I/Os to console\n" "-enable-audio enable audio support\n" + "-keyboard {generic|direct|xf86}\n" + " Select keyboard mapping method [default=xf86]\n" "-localtime set the real time clock to local time [default=utc]\n" "-full-screen start in full screen\n" #ifdef TARGET_PPC @@ -2591,6 +2593,7 @@ QEMU_OPTION_m, QEMU_OPTION_nographic, QEMU_OPTION_enable_audio, + QEMU_OPTION_keyboard, QEMU_OPTION_nics, QEMU_OPTION_macaddr, @@ -2647,6 +2650,9 @@ { "m", HAS_ARG, QEMU_OPTION_m }, { "nographic", 0, QEMU_OPTION_nographic }, { "enable-audio", 0, QEMU_OPTION_enable_audio }, +#ifdef CONFIG_SDL + { "keyboard", HAS_ARG, QEMU_OPTION_keyboard }, +#endif { "nics", HAS_ARG, QEMU_OPTION_nics}, { "macaddr", HAS_ARG, QEMU_OPTION_macaddr}, @@ -2975,6 +2981,11 @@ case QEMU_OPTION_enable_audio: audio_enabled = 1; break; +#ifdef CONFIG_SDL + case QEMU_OPTION_keyboard: + qemu_keyboard_set_sdl_method(optarg); + break; +#endif case QEMU_OPTION_h: help(); break; diff -ur qemu-0.6.1/vl.h qemu/vl.h --- qemu-0.6.1/vl.h 2004-11-14 21:51:33.000000000 +0100 +++ qemu/vl.h 2004-11-27 15:55:53.000000000 +0100 @@ -545,6 +545,7 @@ /* sdl.c */ void sdl_display_init(DisplayState *ds, int full_screen); +void qemu_keyboard_set_sdl_method(const char *method); /* ide.c */ #define MAX_DISKS 4 --- qemu-0.6.1/qemu-doc.texi~ 2004-12-18 21:19:02.000000000 +0100 +++ qemu-0.6.1/qemu-doc.texi 2004-12-18 21:19:02.000000000 +0100 @@ -194,6 +194,21 @@ The SB16 emulation is disabled by default as it may give problems with Windows. You can enable it manually with this option. +@item -keyboard {generic|direct|xf86} +Choose a mapping function for the keyboard: +@table @code +@item xf86 +An i386 XFree86 based one +(default on most Unix builds) +@item generic +an SDL based mapping function, fixes some "scrambled keyboards" +problems, but has its own issues +(default for alpha) +@item direct +Uses the scancodes as acquired from the underlying OS. +(default on Win32) +@end table + @item -localtime Set the real time clock to local time (the default is to UTC time). This option is needed to have correct date in MS-DOS or