diff mbox

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

Message ID E7C32AB3-032F-49FB-8318-19D8AB0C9AA9@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Programmingkid March 15, 2016, 5:17 p.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>
---
* v5 changes
Commented out the ADB_KEY_POWER because it isn't in use. It wasn't deleted
because it might be useful in the future.
Changed the additional information link to another web page.

* 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 | 148 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 148 insertions(+)
 create mode 100644 include/hw/input/adb-keys.h

Comments

Peter Maydell March 15, 2016, 5:43 p.m. UTC | #1
On 15 March 2016 at 17:17, 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>
> ---
> * v5 changes
> +/*
> + *  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://www.archive.org/stream/apple-guide-macintosh
> + *                          -family-hardware/Apple_Guide_to_the_Macintosh_Family
> + *                          _Hardware_2e#page/n345/mode/2up - page 308

Better to have the whole URL on one line so you can just cut-n-paste
it into a web browser.

> +    ADB_KEY_LEFT_CONTROL = 54,
> +    ADB_KEY_RIGHT_CONTROL = 125,
> +    ADB_KEY_LEFT_OPTION = 58,
> +    ADB_KEY_RIGHT_OPTION = 124,
> +    ADB_KEY_LEFT_COMMAND = 55,
> +    ADB_KEY_RIGHT_COMMAND = 126,

Where does this one come from? The Apple doc shows the Extended Keyboard
as generating the same keycode for left and right command (0x37).

(Incidentally if we're using that doc as our official reference for
the keycodes then using hex the same as it does would be good.)

thanks
-- PMM
Programmingkid March 15, 2016, 6:02 p.m. UTC | #2
On Mar 15, 2016, at 1:43 PM, Peter Maydell wrote:

> On 15 March 2016 at 17:17, 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>
>> ---
>> * v5 changes
>> +/*
>> + *  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://www.archive.org/stream/apple-guide-macintosh
>> + *                          -family-hardware/Apple_Guide_to_the_Macintosh_Family
>> + *                          _Hardware_2e#page/n345/mode/2up - page 308
> 
> Better to have the whole URL on one line so you can just cut-n-paste
> it into a web browser.

It goes against the guidelines, but ok. 

> 
>> +    ADB_KEY_LEFT_CONTROL = 54,
>> +    ADB_KEY_RIGHT_CONTROL = 125,
>> +    ADB_KEY_LEFT_OPTION = 58,
>> +    ADB_KEY_RIGHT_OPTION = 124,
>> +    ADB_KEY_LEFT_COMMAND = 55,
>> +    ADB_KEY_RIGHT_COMMAND = 126,
> 
> Where does this one come from? The Apple doc shows the Extended Keyboard
> as generating the same keycode for left and right command (0x37).

I think it came from the old pc_to_adb_keycode array. The xev command in a linux guess does correctly report that Right Super key is being pushed when ADB_KEY_RIGHT_COMMAND is set to 126. On a Mac OS guess keyboard viewer does indicate at least one of the command keys is being pushed. So this value does work.
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..f340340
--- /dev/null
+++ b/include/hw/input/adb-keys.h
@@ -0,0 +1,148 @@ 
+/*
+ * 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://www.archive.org/stream/apple-guide-macintosh
+ *                          -family-hardware/Apple_Guide_to_the_Macintosh_Family
+ *                          _Hardware_2e#page/n345/mode/2up - page 308
+ */
+
+#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 = 123,
+    ADB_KEY_SPACEBAR = 49,
+    ADB_KEY_LEFT_CONTROL = 54,
+    ADB_KEY_RIGHT_CONTROL = 125,
+    ADB_KEY_LEFT_OPTION = 58,
+    ADB_KEY_RIGHT_OPTION = 124,
+    ADB_KEY_LEFT_COMMAND = 55,
+    ADB_KEY_RIGHT_COMMAND = 126,
+
+    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 = 62,
+    ADB_KEY_DOWN = 61,
+    ADB_KEY_LEFT = 59,
+    ADB_KEY_RIGHT = 60,
+
+    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 */