qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] Cocoa keyboard handling fixes (update)


From: Joachim Henke
Subject: [Qemu-devel] [PATCH] Cocoa keyboard handling fixes (update)
Date: Fri, 30 Dec 2005 21:58:31 +0100

In the meanwhile I did some more fixes and improvements over the patch I
posted on December 27th. Here is the complete ChangeLog:

- fix a crash that occurs when pressing a dead key in the monitor
  (I already reported this on December 8th, please drop that old patch)
- keymap corrections
- make ctrl+alt key combos work for the guest OS (e.g. ctrl-alt-delete)
- don't pass undefined keycodes to the guest OS during KeyDown and KeyUp
  events (as it is already done for modifier key events)
- make HOME, END, and DELETE keys work in the monitor
- avoid compiler warnings
- some code cleanup


A bit more in detail:

The file 'hw/adb.c' contains an array 'pc_to_adb_keycode[256]', which can
be reversed and used as some kind of reference (have a look at the attached
file 'adb_to_pc.txt'). You can see that this list is slightly different
from the keymap in cocoa.m, which needs indeed three adjustments to have
the same key codes in QEMU on an iMac like on a real PC (QZ_KP_ENTER was
just a typo: 0x9c = 156, not 152).

In the keymap, undefined keys are represented with the value 0, but they
are forwarded to the guest OS without checking. Currently, when running
Linux as guest OS, the kernel log is flooded with messages like

atkbd.c: Unknown key pressed (translated set 2, code 0x0 on isa0060/serio0).
atkbd.c: Use 'setkeycodes 00 <keycode>' to make it known.
atkbd.c: Unknown key released (translated set 2, code 0x0 on isa0060/serio0).
atkbd.c: Use 'setkeycodes 00 <keycode>' to make it known.

when such an undefined key is pressed.

'setAppleMenu' was removed from the header in Mac OS 10.4, so we need to
declare it ourselves to avoid compiler warnings when building on Tiger.

In the function header of 'CustomApplicationMain', the types of argc and
argv are not declared. This gives a warning with GCC4. We can safely remove
these parameters since they are not used in the function (and are globally
available in gArgc and gArgv anyway).


Cleanups:
- use bytes instead of dwords for keymap[] to save some space in the binary
- properly warn about _all_ undefined keycodes (not only those that are
  beyond the bounds of keymap[])
- calling [NSApp nextEventMatchingMask: ... ] with 'nil' for 'untilDate:'
  has always been the same like using [NSDate distantPast], so we can save
  the space to initialize it
- we don't need an array of 256 integers to remember the state of those few
  modifier keys: as they are all in the range 0x36-0x3E of ADB keycodes, we
  can use the lower 4 bits as an index into a bit field
- "num lock" is handled by NSKeyDown and NSKeyUp anyway, and doesn't go
  through NSFlagsChanged, so we don't need to probe for it there


It isn't that dramatically as the explanation maybe suggests (c:  Just have
a look at the patch. Excuse me for posting two versions of this patch.
Fabrice, please apply this one.

Sorry
Jo.

Attachment: cocoa_keyboard.diff.gz
Description: GNU Zip compressed data

Attachment: adb_to_pc.txt
Description: Text document


reply via email to

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