diff mbox

[v4,3/4] adb-keys.h: initial commit

Message ID 0970CE09-0FCD-4156-8B65-6542AC6224A4@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Programmingkid March 11, 2016, 2:29 a.m. UTC
This commit implements the adb-keys.h file. It holds information on adb keycode
values.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
---
* v4 changes
Replaced an 'a' with 'an'.
Replaced __ADBKEYS__ with ADB_KEYS_H.
Added additional information comment with link.
Changed license to GNU GPL v2 or later.

* v3 changes
Changed name of file from MacKeys.h to adb-keys.h.
Changed name of constants from MAC_KEYS_ to ADB_KEYS_.

 include/hw/input/adb-keys.h | 146 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 146 insertions(+)
 create mode 100644 include/hw/input/adb-keys.h

Comments

Peter Maydell March 12, 2016, 12:29 a.m. UTC | #1
On 11 March 2016 at 09:29, Programmingkid <programmingkidx@gmail.com> wrote:
> This commit implements the adb-keys.h file. It holds information on adb keycode
> values.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> ---

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
Peter Maydell March 13, 2016, 4:12 p.m. UTC | #2
On 11 March 2016 at 02:29, Programmingkid <programmingkidx@gmail.com> wrote:
> This commit implements the adb-keys.h file. It holds information on adb keycode
> values.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

> +
> +    ADB_KEY_GRAVE_ACCENT = 50,
> +    ADB_KEY_MINUS = 27,
> +    ADB_KEY_EQUAL = 24,
> +    ADB_KEY_DELETE = 51,
> +    ADB_KEY_CAPS_LOCK = 57,
> +    ADB_KEY_TAB = 48,
> +    ADB_KEY_RETURN = 36,
> +    ADB_KEY_LEFT_BRACKET = 33,
> +    ADB_KEY_RIGHT_BRACKET = 30,
> +    ADB_KEY_BACKSLASH = 42,
> +    ADB_KEY_SEMICOLON = 41,
> +    ADB_KEY_APOSTROPHE = 39,
> +    ADB_KEY_COMMA = 43,
> +    ADB_KEY_PERIOD = 47,
> +    ADB_KEY_FORWARD_SLASH = 44,
> +    ADB_KEY_LEFT_SHIFT = 56,
> +    ADB_KEY_RIGHT_SHIFT = 60,
> +    ADB_KEY_SPACEBAR = 49,
> +    ADB_KEY_LEFT_CONTROL = 59,
> +    ADB_KEY_RIGHT_CONTROL = 62,
> +    ADB_KEY_LEFT_OPTION = 58,
> +    ADB_KEY_RIGHT_OPTION = 61,
> +    ADB_KEY_LEFT_COMMAND = 55,
> +    ADB_KEY_RIGHT_COMMAND = 54,

> +    ADB_KEY_UP = 126,
> +    ADB_KEY_DOWN = 125,
> +    ADB_KEY_LEFT = 123,
> +    ADB_KEY_RIGHT = 124,

Looking at
http://www.archive.org/stream/apple-guide-macintosh-family-hardware/Apple_Guide_to_the_Macintosh_Family_Hardware_2e#page/n347/mode/2up

page 308/309, the codes you have here appear to be the
"keyboard driver codes", ie the ones you get after MacOS
has remapped them, not the "transition codes", ie the ones
the hardware actually generates.

In particular the transition codes for the right shift/option/control
are 0x7B/7C/7D, which are what you have here for KEY_LEFT/RIGHT/DOWN,
which is probably why you're then getting weird behaviour.

I suggest rechecking all these ADB keycodes against the
diagram on page 308.

thanks
-- PMM
diff mbox

Patch

diff --git a/include/hw/input/adb-keys.h b/include/hw/input/adb-keys.h
new file mode 100644
index 0000000..2e4f759
--- /dev/null
+++ b/include/hw/input/adb-keys.h
@@ -0,0 +1,146 @@ 
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2016 John Arbuckle
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+/*
+ *  adb-keys.h
+ *
+ *  Provides an enum of all the Macintosh keycodes.
+ *  Note: keys like Power, volume related, and eject are handled at a lower
+ *        level and are not available to QEMU. That doesn't mean we can't
+ *        substitute one key for another. The function keys like F1 make a good
+ *        substitute for these keys. This can be done in the GTK, SDL, or Cocoa
+ *        code.
+ *  Additional information: http://stackoverflow.com/questions/3202629
+ */
+
+#ifndef ADB_KEYS_H
+#define ADB_KEYS_H
+
+enum {
+    ADB_KEY_A = 0,
+    ADB_KEY_B = 11,
+    ADB_KEY_C = 8,
+    ADB_KEY_D = 2,
+    ADB_KEY_E = 14,
+    ADB_KEY_F = 3,
+    ADB_KEY_G = 5,
+    ADB_KEY_H = 4,
+    ADB_KEY_I = 34,
+    ADB_KEY_J = 38,
+    ADB_KEY_K = 40,
+    ADB_KEY_L = 37,
+    ADB_KEY_M = 46,
+    ADB_KEY_N = 45,
+    ADB_KEY_O = 31,
+    ADB_KEY_P = 35,
+    ADB_KEY_Q = 12,
+    ADB_KEY_R = 15,
+    ADB_KEY_S = 1,
+    ADB_KEY_T = 17,
+    ADB_KEY_U = 32,
+    ADB_KEY_V = 9,
+    ADB_KEY_W = 13,
+    ADB_KEY_X = 7,
+    ADB_KEY_Y = 16,
+    ADB_KEY_Z = 6,
+
+    ADB_KEY_0 = 29,
+    ADB_KEY_1 = 18,
+    ADB_KEY_2 = 19,
+    ADB_KEY_3 = 20,
+    ADB_KEY_4 = 21,
+    ADB_KEY_5 = 23,
+    ADB_KEY_6 = 22,
+    ADB_KEY_7 = 26,
+    ADB_KEY_8 = 28,
+    ADB_KEY_9 = 25,
+
+    ADB_KEY_GRAVE_ACCENT = 50,
+    ADB_KEY_MINUS = 27,
+    ADB_KEY_EQUAL = 24,
+    ADB_KEY_DELETE = 51,
+    ADB_KEY_CAPS_LOCK = 57,
+    ADB_KEY_TAB = 48,
+    ADB_KEY_RETURN = 36,
+    ADB_KEY_LEFT_BRACKET = 33,
+    ADB_KEY_RIGHT_BRACKET = 30,
+    ADB_KEY_BACKSLASH = 42,
+    ADB_KEY_SEMICOLON = 41,
+    ADB_KEY_APOSTROPHE = 39,
+    ADB_KEY_COMMA = 43,
+    ADB_KEY_PERIOD = 47,
+    ADB_KEY_FORWARD_SLASH = 44,
+    ADB_KEY_LEFT_SHIFT = 56,
+    ADB_KEY_RIGHT_SHIFT = 60,
+    ADB_KEY_SPACEBAR = 49,
+    ADB_KEY_LEFT_CONTROL = 59,
+    ADB_KEY_RIGHT_CONTROL = 62,
+    ADB_KEY_LEFT_OPTION = 58,
+    ADB_KEY_RIGHT_OPTION = 61,
+    ADB_KEY_LEFT_COMMAND = 55,
+    ADB_KEY_RIGHT_COMMAND = 54,
+
+    ADB_KEY_KP_0 = 82,
+    ADB_KEY_KP_1 = 83,
+    ADB_KEY_KP_2 = 84,
+    ADB_KEY_KP_3 = 85,
+    ADB_KEY_KP_4 = 86,
+    ADB_KEY_KP_5 = 87,
+    ADB_KEY_KP_6 = 88,
+    ADB_KEY_KP_7 = 89,
+    ADB_KEY_KP_8 = 91,
+    ADB_KEY_KP_9 = 92,
+    ADB_KEY_KP_PERIOD = 65,
+    ADB_KEY_KP_ENTER = 76,
+    ADB_KEY_KP_PLUS = 69,
+    ADB_KEY_KP_SUBTRACT = 78,
+    ADB_KEY_KP_MULTIPLY = 67,
+    ADB_KEY_KP_DIVIDE = 75,
+    ADB_KEY_KP_EQUAL = 81,
+    ADB_KEY_KP_CLEAR = 71,
+
+    ADB_KEY_UP = 126,
+    ADB_KEY_DOWN = 125,
+    ADB_KEY_LEFT = 123,
+    ADB_KEY_RIGHT = 124,
+
+    ADB_KEY_HELP = 114,
+    ADB_KEY_HOME = 115,
+    ADB_KEY_PAGE_UP = 116,
+    ADB_KEY_PAGE_DOWN = 121,
+    ADB_KEY_END = 119,
+    ADB_KEY_FORWARD_DELETE = 117,
+
+    ADB_KEY_ESC = 53,
+    ADB_KEY_F1 = 122,
+    ADB_KEY_F2 = 120,
+    ADB_KEY_F3 = 99,
+    ADB_KEY_F4 = 118,
+    ADB_KEY_F5 = 96,
+    ADB_KEY_F6 = 97,
+    ADB_KEY_F7 = 98,
+    ADB_KEY_F8 = 100,
+    ADB_KEY_F9 = 101,
+    ADB_KEY_F10 = 109,
+    ADB_KEY_F11 = 103,
+    ADB_KEY_F12 = 111,
+    ADB_KEY_F13 = 105,
+    ADB_KEY_F14 = 107,
+    ADB_KEY_F15 = 113,
+
+    ADB_KEY_VOLUME_UP = 72,
+    ADB_KEY_VOLUME_DOWN = 73,
+    ADB_KEY_VOLUME_MUTE = 74,
+    ADB_KEY_POWER = 32639,
+};
+
+/* Could not find the value for this key. */
+/* #define ADB_KEY_EJECT */
+
+#endif /* ADB_KEYS_H */