qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Implementing QKeyCode in cocoa.m
@ 2016-02-26  3:18 Programmingkid
  2016-02-29 17:17 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Programmingkid @ 2016-02-26  3:18 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel qemu-devel

A long time ago we talked about removing the pc/xt keyboard layout in the ui/cocoa.m file and replacing it with QKeyCode. I wanted to do this originally because the pc/xt layout does not support several keys found on a Macintosh keyboard (like keypad =).

https://lists.gnu.org/archive/html/qemu-devel/2015-02/msg01322.html
This link gives some info about this topic.

What I currently plan on doing is implementing an enum that defines all the Mac keys like this:

// Macintosh keyboard keycodes
enum {
    MAC_KEY_A = 0,
    MAC_KEY_B = 11,
    MAC_KEY_C = 8,
    MAC_KEY_D = 2,
    MAC_KEY_E = 14,
    MAC_KEY_F = 3,
    MAC_KEY_G = 5,
    MAC_KEY_H = 4,
    MAC_KEY_I = 34,
    MAC_KEY_J = 38,
    MAC_KEY_LEFTSHIFT = 56,
    MAC_KEY_RIGHTSHIFT = 60,
    MAC_KEY_SPACEBAR = 49,
    ...
};

Then implementing a translation array that translates mac keycodes to QKeyCode like this:

// Mac to QKeyCode conversion
int macToQKeyCodeMap[] = {
    [MAC_KEY_A] = Q_KEY_CODE_A,
    [MAC_KEY_B] = Q_KEY_CODE_B,
    [MAC_KEY_C] = Q_KEY_CODE_C,
    [MAC_KEY_D] = Q_KEY_CODE_D,
    [MAC_KEY_E] = Q_KEY_CODE_E,
    [MAC_KEY_F] = Q_KEY_CODE_F,
    [MAC_KEY_G] = Q_KEY_CODE_G,
    [MAC_KEY_H] = Q_KEY_CODE_H,
    [MAC_KEY_I] = Q_KEY_CODE_I,
    [MAC_KEY_J] = Q_KEY_CODE_J,
    [MAC_KEY_LEFTSHIFT] = Q_KEY_CODE_SHIFT,
    [MAC_KEY_RIGHTSHIFT] = Q_KEY_CODE_SHIFT_R,
    [MAC_KEY_SPACEBAR] = Q_KEY_CODE_SPC,
    ...
};

This macToQKeyCodeMap code will be in the cocoa.m file. The enum will probably be in include/hw/input/adb.h. Then I will probably implement another translation array in the file hw/input/adb.c called QKeyCode_to_ADB_keycode that will look something like this:

int QKeyCode_to_ADB_keycode[] = {
	[Q_KEY_CODE_A] = MAC_KEY_A, 
	[Q_KEY_CODE_B] = MAC_KEY_B,
	...
};

These changes shouldn't effect the gtk and sdl libraries because I don't plan on deleting any code they depend on.

Does this plan look acceptable? 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-29 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-26  3:18 [Qemu-devel] Implementing QKeyCode in cocoa.m Programmingkid
2016-02-29 17:17 ` Peter Maydell

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).