[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Implementing QKeyCode in cocoa.m
From: |
Programmingkid |
Subject: |
[Qemu-devel] Implementing QKeyCode in cocoa.m |
Date: |
Thu, 25 Feb 2016 22:18:42 -0500 |
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?
- [Qemu-devel] Implementing QKeyCode in cocoa.m,
Programmingkid <=