qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] MAC Keyboard again - with Patches


From: Bernhard Ehlers
Subject: [Qemu-devel] MAC Keyboard again - with Patches
Date: Sun, 23 Jan 2005 14:18:31 +0100

<x-tad-bigger>Hello,

the keyboard handling of qemu gave me some headaches. Some of the
problems I faced were just misunderstandings or lack of information.
Some other could be fixed by small patches.

My environment:
- Apple ibook (800 MHz G4) with german keyboard
- MAC OSX 10.3.7
- sdl V1.2.7 from fink
- qemu-snapshot-2004-12-28_23.tar.bz2
from http://people.fruitsalad.org/nox/
- qemu-fix-escape.patch.gz
from http://lists.gnu.org/archive/html/qemu-devel/2004-12/msg00314.html
- Windows NT4 and freedos as guest OS

The last time I checked CVS (about 2 weeks ago) I got build errors.
But as the keyboard relating functions hasn't changed since 5 weeks,
my comments should be valid for CVS as well.

Now my comments:

1. I had the impression, that the hosts keyboard layout and that of the
guest is totally unrelated. Well, this is true for unshifted keys,
as the ascii code of the key gets translated by the keymap to a key
code. But as the shift status is not translated, it has to be the same
on guest and host. Therefore host and guest must use the same keyboard
layout.

2. Substitute altgr by ctrl-alt
As the mac lacks the altgr key, I thought there is no way to enter
@ ~ [ ] { } | \ on my german keyboard. But as Virtual PC users might
know you can substitute altgr by ctrl-alt. I had to ask google for
that. To key in "@" enter ctrl-alt-q. So you must enter ctrl-alt
together with the PC keyboard position of those special keys.
This is not very mac like, but I can live with it.

3. The national german characters don't work.
As you can't enter a german text without using the umlaut characters,
it's a real annoyance. Furthermore I loose "?" as it's shift <sharp-S>
on a german keyboard. The reason that national characters don't work,
is that SDL returns SDLK_WORLD_0 to SDLK_WORLD_95 for those keys.
A quick fix is to use the unicode value in those cases.

--- qemu.orig/sdl.c Sun Dec 12 17:56:30 2004
+++ qemu/sdl.c Sun Jan 23 11:29:29 2005
@@ -78,10 +78,17 @@
static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev)
{
int keysym;
- /* workaround for X11+SDL bug with AltGR */
keysym = ev->keysym.sym;
+ /* workaround for X11+SDL bug with AltGR */
if (keysym == 0 && ev->keysym.scancode == 113)
keysym = SDLK_MODE;
+ /* workaround for national keys */
+ if (keysym >= SDLK_WORLD_0 && keysym <= SDLK_WORLD_95) {
+ if (ev->keysym.unicode <= 0xFF)
+ keysym = ev->keysym.unicode;
+ else
+ return 0;
+ }
return keysym2scancode(kbd_layout, keysym);
}

4. The keys for switching between the virtual consoles are mixed up.
The same is true for the full screen function. The reason for that
is the use of sdl_keyevent_to_keycode, with gives invalid results
on MACs. My suggestion is to use the keysym.sym value.
Futhermore I restricted the number of virtual consoles to 6 as
ctrl-alt-7 is used as altgr-7 ("{"), see comment #2.

--- qemu.orig/sdl.c Sun Dec 12 17:56:30 2004
+++ qemu/sdl.c Sun Jan 23 11:29:29 2005
@@ -341,15 +348,15 @@
gui_grab_code;
gui_key_modifier_pressed = mod_state;
if (gui_key_modifier_pressed) {
- int keycode;
- keycode = sdl_keyevent_to_keycode(&ev->key);
- switch(keycode) {
- case 0x21: /* 'f' key on US keyboard */
+ int keysym;
+ keysym = ev->key.keysym.sym;
+ switch(keysym) {
+ case 'f': /* 'f' key */
toggle_full_screen(ds);
gui_keysym = 1;
break;
- case 0x02 ... 0x0a: /* '1' to '9' keys */
- console_select(keycode - 0x02);
+ case '1' ... '6': /* '1' to '6' keys */
+ console_select(keysym - '1');
if (is_active_console(vga_console)) {
/* tell the vga console to redisplay itself */
vga_invalidate_display();

5. The option (Apple) key sends a "<"
I think this bug is introduced with the qemu-fix-escape patch.
In this patch the Meta key is translated to the key code 0x56,
which is the "<" key on a german keyboard. With the following patch
the Meta key is translated to the Windows key.

--- qemu.orig/keymaps/modifiers Sun Jan 23 11:37:56 2005
+++ qemu/keymaps/modifiers Sun Jan 23 11:13:17 2005
@@ -10,8 +10,8 @@

# Translate Meta, Super and Hyper to Windows keys.

-Meta_L 0x56
-Meta_R 0x56
+Meta_L 0xdb
+Meta_R 0xdc

# Translate Menu to the Windows Application key.
Menu 0xdd

6. Option-<Mouse key> works as right mouse key
With this mapping the users with a single key mac mouse can simulate
the second mouse key. I assume this mapping is introduced by SDL.
The only drawback is that with the release of the mouse, the option
key works as the windows key (see #5). To work around this, use
any modifier together with the option key. E.g. alt-option-mouse.

Well this got much longer than intended. Nevertheless I hope this will
help some non-US guys making the best out of qemu. At least for me this
really improves it.

Best regards

Bernhard Ehlers</x-tad-bigger>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]