* [Qemu-devel] [Patch] selectable keyboard mapping function
@ 2004-12-19 16:24 Elrond
2004-12-19 18:17 ` Johannes Schindelin
0 siblings, 1 reply; 4+ messages in thread
From: Elrond @ 2004-12-19 16:24 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 379 bytes --]
Hi,
After having some bug reports about scrambled keyboards in
Debian, we decided to make the keyboard mapping function
choosable.
It helps most people at least somewhat.
Here are two bugreports for example problems:
<http://bugs.debian.org/282658>
<http://bugs.debian.org/284510>
Patch attached.
Elrond
p.s.: I'm not on the list, so please include me in replies.
[-- Attachment #2: 02_selectable_sdl_keyboard.patch --]
[-- Type: text/plain, Size: 5016 bytes --]
#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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Patch] selectable keyboard mapping function
2004-12-19 16:24 [Qemu-devel] [Patch] selectable keyboard mapping function Elrond
@ 2004-12-19 18:17 ` Johannes Schindelin
2004-12-19 19:02 ` Elrond
0 siblings, 1 reply; 4+ messages in thread
From: Johannes Schindelin @ 2004-12-19 18:17 UTC (permalink / raw)
To: Elrond; +Cc: qemu-devel
Hi,
Fabrice committed a new keyboard mapping scheme which you can activate by
using "-k <lang>" where <lang> is something like de, fr, en, etc. Could
you please try that and tell us if it solves your problems?
Ciao,
Dscho
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Patch] selectable keyboard mapping function
2004-12-19 18:17 ` Johannes Schindelin
@ 2004-12-19 19:02 ` Elrond
2004-12-19 19:10 ` Johannes Schindelin
0 siblings, 1 reply; 4+ messages in thread
From: Elrond @ 2004-12-19 19:02 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: qemu-devel
On Sun, Dec 19, 2004 at 07:17:04PM +0100, Johannes Schindelin wrote:
> Hi,
>
> Fabrice committed a new keyboard mapping scheme which you can activate by
> using "-k <lang>" where <lang> is something like de, fr, en, etc. Could
> you please try that and tell us if it solves your problems?
I can't try it myself, as I don't have those problems. You
could ask the submitters of those bugs.
I haven't looked at cvs yet, but doing "de"-schemes sounds
a bit weird, unless it's used to decode back from cooked
keys to scancodes..
Elrond
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Patch] selectable keyboard mapping function
2004-12-19 19:02 ` Elrond
@ 2004-12-19 19:10 ` Johannes Schindelin
0 siblings, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2004-12-19 19:10 UTC (permalink / raw)
To: Elrond; +Cc: qemu-devel
Hi,
On Sun, 19 Dec 2004, Elrond wrote:
> I haven't looked at cvs yet, but doing "de"-schemes sounds
> a bit weird, unless it's used to decode back from cooked
> keys to scancodes..
Well, it's not that weird, once you realize that X11 is standardized on
keysyms, but PC hardware on scancodes.
Hth,
Dscho
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-12-19 19:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-19 16:24 [Qemu-devel] [Patch] selectable keyboard mapping function Elrond
2004-12-19 18:17 ` Johannes Schindelin
2004-12-19 19:02 ` Elrond
2004-12-19 19:10 ` Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).