diff mbox

[v2] MacKeys.h: initial commit

Message ID CDA245D4-EF81-489E-994C-2E04FEBDCFC9@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Programmingkid March 2, 2016, 1:58 a.m. UTC
This patch adds the file MacKeys.h. It is a file that contains all the constants
for the Macintosh keyboard keycodes.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

---
Added standard license.
Added #ifndef #define #endif macros.

 include/hw/input/MacKeys.h |  168 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 168 insertions(+), 0 deletions(-)
 create mode 100644 include/hw/input/MacKeys.h

Comments

Markus Armbruster March 2, 2016, 9:32 a.m. UTC | #1
Programmingkid <programmingkidx@gmail.com> writes:

> This patch adds the file MacKeys.h. It is a file that contains all the constants
> for the Macintosh keyboard keycodes.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>
> ---
> Added standard license.
> Added #ifndef #define #endif macros.
>
>  include/hw/input/MacKeys.h |  168 ++++++++++++++++++++++++++++++++++++++++++++

Please stick to lower case in file names.

$ git-ls-files | grep '[A-Z][a-z]' | grep -v Makefile
Changelog
docs/vnc-ledstate-Pseudo-encoding.txt
include/libdecnumber/decContext.h
include/libdecnumber/decNumber.h
include/libdecnumber/decNumberLocal.h
include/libdecnumber/dpd/decimal128Local.h
libdecnumber/decContext.c
libdecnumber/decNumber.c
Programmingkid March 2, 2016, 2:49 p.m. UTC | #2
On Mar 2, 2016, at 4:32 AM, Markus Armbruster wrote:

> Programmingkid <programmingkidx@gmail.com> writes:
> 
>> This patch adds the file MacKeys.h. It is a file that contains all the constants
>> for the Macintosh keyboard keycodes.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>> 
>> ---
>> Added standard license.
>> Added #ifndef #define #endif macros.
>> 
>> include/hw/input/MacKeys.h |  168 ++++++++++++++++++++++++++++++++++++++++++++
> 
> Please stick to lower case in file names.
> 
> $ git-ls-files | grep '[A-Z][a-z]' | grep -v Makefile
> Changelog
> docs/vnc-ledstate-Pseudo-encoding.txt
> include/libdecnumber/decContext.h
> include/libdecnumber/decNumber.h
> include/libdecnumber/decNumberLocal.h
> include/libdecnumber/dpd/decimal128Local.h
> libdecnumber/decContext.c
> libdecnumber/decNumber.c

Which one do you prefer: mackeys.h or macKeys.h ?
Markus Armbruster March 2, 2016, 3:55 p.m. UTC | #3
Programmingkid <programmingkidx@gmail.com> writes:

> On Mar 2, 2016, at 4:32 AM, Markus Armbruster wrote:
>
>> Programmingkid <programmingkidx@gmail.com> writes:
>> 
>>> This patch adds the file MacKeys.h. It is a file that contains all the constants
>>> for the Macintosh keyboard keycodes.
>>> 
>>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>>> 
>>> ---
>>> Added standard license.
>>> Added #ifndef #define #endif macros.
>>> 
>>> include/hw/input/MacKeys.h |  168 ++++++++++++++++++++++++++++++++++++++++++++
>> 
>> Please stick to lower case in file names.
>> 
>> $ git-ls-files | grep '[A-Z][a-z]' | grep -v Makefile
>> Changelog
>> docs/vnc-ledstate-Pseudo-encoding.txt
>> include/libdecnumber/decContext.h
>> include/libdecnumber/decNumber.h
>> include/libdecnumber/decNumberLocal.h
>> include/libdecnumber/dpd/decimal128Local.h
>> libdecnumber/decContext.c
>> libdecnumber/decNumber.c
>
> Which one do you prefer: mackeys.h or macKeys.h ?

I'd call it mac-keys.h.  mackeys.h would be okay.  There's enough
precedence for '_' in file names to justify mac_keys.h, but I personally
dislike that.
Eric Blake March 2, 2016, 4:01 p.m. UTC | #4
On 03/02/2016 08:55 AM, Markus Armbruster wrote:

>>>
>>> Please stick to lower case in file names.

>>
>> Which one do you prefer: mackeys.h or macKeys.h ?
> 
> I'd call it mac-keys.h.  mackeys.h would be okay.  There's enough
> precedence for '_' in file names to justify mac_keys.h, but I personally
> dislike that.

I also suggested "mac-keys.h" in my v1 review:
https://lists.gnu.org/archive/html/qemu-devel/2016-03/msg00364.html
Peter Maydell March 2, 2016, 4:45 p.m. UTC | #5
On 2 March 2016 at 15:55, Markus Armbruster <armbru@redhat.com> wrote:
> I'd call it mac-keys.h.  mackeys.h would be okay.  There's enough
> precedence for '_' in file names to justify mac_keys.h, but I personally
> dislike that.

Calling it adb-keys.h would make it clearer that what we're defining
here are the scancodes for ADB keyboards. (They happen to be the
same as the Cocoa/Carbon GUI keycodes for modern macs with non
ADB keyboards, but this is just a historical effect.)

thanks
-- PMM
Programmingkid March 2, 2016, 5:04 p.m. UTC | #6
On Mar 2, 2016, at 11:45 AM, Peter Maydell wrote:

> On 2 March 2016 at 15:55, Markus Armbruster <armbru@redhat.com> wrote:
>> I'd call it mac-keys.h.  mackeys.h would be okay.  There's enough
>> precedence for '_' in file names to justify mac_keys.h, but I personally
>> dislike that.
> 
> Calling it adb-keys.h would make it clearer that what we're defining
> here are the scancodes for ADB keyboards. (They happen to be the
> same as the Cocoa/Carbon GUI keycodes for modern macs with non
> ADB keyboards, but this is just a historical effect.)

Great idea.
Programmingkid March 2, 2016, 5:13 p.m. UTC | #7
On Mar 2, 2016, at 11:45 AM, Peter Maydell wrote:

> On 2 March 2016 at 15:55, Markus Armbruster <armbru@redhat.com> wrote:
>> I'd call it mac-keys.h.  mackeys.h would be okay.  There's enough
>> precedence for '_' in file names to justify mac_keys.h, but I personally
>> dislike that.
> 
> Calling it adb-keys.h would make it clearer that what we're defining
> here are the scancodes for ADB keyboards. (They happen to be the
> same as the Cocoa/Carbon GUI keycodes for modern macs with non
> ADB keyboards, but this is just a historical effect.)

Did you want me to change all the constants to something other than MAC_KEY_ ?
I could be ADB_KEY_ for all the keys if you want.
Peter Maydell March 2, 2016, 5:33 p.m. UTC | #8
On 2 March 2016 at 17:13, Programmingkid <programmingkidx@gmail.com> wrote:
>
> On Mar 2, 2016, at 11:45 AM, Peter Maydell wrote:
>
>> On 2 March 2016 at 15:55, Markus Armbruster <armbru@redhat.com> wrote:
>>> I'd call it mac-keys.h.  mackeys.h would be okay.  There's enough
>>> precedence for '_' in file names to justify mac_keys.h, but I personally
>>> dislike that.
>>
>> Calling it adb-keys.h would make it clearer that what we're defining
>> here are the scancodes for ADB keyboards. (They happen to be the
>> same as the Cocoa/Carbon GUI keycodes for modern macs with non
>> ADB keyboards, but this is just a historical effect.)
>
> Did you want me to change all the constants to something other than MAC_KEY_ ?
> I could be ADB_KEY_ for all the keys if you want.

Yes, I think if we're calling it adb-keys.h then a search-and-replace
on the constant names to match would be a good idea.

-- PMM
diff mbox

Patch

diff --git a/include/hw/input/MacKeys.h b/include/hw/input/MacKeys.h
new file mode 100644
index 0000000..72c5d04
--- /dev/null
+++ b/include/hw/input/MacKeys.h
@@ -0,0 +1,168 @@ 
+/*
+ * QEMU System Emulator
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/*
+ *  MacKeys.h
+ *
+ *  Provides a 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.
+ */
+
+#ifndef __MACKEYS__
+#define __MACKEYS__
+
+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_K = 40,
+    MAC_KEY_L = 37,
+    MAC_KEY_M = 46,
+    MAC_KEY_N = 45,
+    MAC_KEY_O = 31,
+    MAC_KEY_P = 35,
+    MAC_KEY_Q = 12,
+    MAC_KEY_R = 15,
+    MAC_KEY_S = 1,
+    MAC_KEY_T = 17,
+    MAC_KEY_U = 32,
+    MAC_KEY_V = 9,
+    MAC_KEY_W = 13,
+    MAC_KEY_X = 7,
+    MAC_KEY_Y = 16,
+    MAC_KEY_Z = 6,
+
+    MAC_KEY_0 = 29,
+    MAC_KEY_1 = 18,
+    MAC_KEY_2 = 19,
+    MAC_KEY_3 = 20,
+    MAC_KEY_4 = 21,
+    MAC_KEY_5 = 23,
+    MAC_KEY_6 = 22,
+    MAC_KEY_7 = 26,
+    MAC_KEY_8 = 28,
+    MAC_KEY_9 = 25,
+
+    MAC_KEY_GRAVE_ACCENT = 50,
+    MAC_KEY_MINUS = 27,
+    MAC_KEY_EQUAL = 24,
+    MAC_KEY_DELETE = 51,
+    MAC_KEY_CAPS_LOCK = 57,
+    MAC_KEY_TAB = 48,
+    MAC_KEY_RETURN = 36,
+    MAC_KEY_LEFT_BRACKET = 33,
+    MAC_KEY_RIGHT_BRACKET = 30,
+    MAC_KEY_BACKSLASH = 42,
+    MAC_KEY_SEMICOLON = 41,
+    MAC_KEY_APOSTROPHE = 39,
+    MAC_KEY_COMMA = 43,
+    MAC_KEY_PERIOD = 47,
+    MAC_KEY_FORWARD_SLASH = 44,
+    MAC_KEY_LEFT_SHIFT = 56,
+    MAC_KEY_RIGHT_SHIFT = 60,
+    MAC_KEY_SPACEBAR = 49,
+    MAC_KEY_LEFT_CONTROL = 59,
+    MAC_KEY_RIGHT_CONTROL = 62,
+    MAC_KEY_LEFT_OPTION = 58,
+    MAC_KEY_RIGHT_OPTION = 61,
+    MAC_KEY_LEFT_COMMAND = 55,
+    MAC_KEY_RIGHT_COMMAND = 54,
+
+    MAC_KEY_KP_0 = 82,
+    MAC_KEY_KP_1 = 83,
+    MAC_KEY_KP_2 = 84,
+    MAC_KEY_KP_3 = 85,
+    MAC_KEY_KP_4 = 86,
+    MAC_KEY_KP_5 = 87,
+    MAC_KEY_KP_6 = 88,
+    MAC_KEY_KP_7 = 89,
+    MAC_KEY_KP_8 = 91,
+    MAC_KEY_KP_9 = 92,
+    MAC_KEY_KP_PERIOD = 65,
+    MAC_KEY_KP_ENTER = 76,
+    MAC_KEY_KP_PLUS = 69,
+    MAC_KEY_KP_SUBTRACT = 78,
+    MAC_KEY_KP_MULTIPLY = 67,
+    MAC_KEY_KP_DIVIDE = 75,
+    MAC_KEY_KP_EQUAL = 81,
+    MAC_KEY_KP_CLEAR = 71,
+
+    MAC_KEY_UP = 126,
+    MAC_KEY_DOWN = 125,
+    MAC_KEY_LEFT = 123,
+    MAC_KEY_RIGHT = 124,
+
+    MAC_KEY_HELP = 114,
+    MAC_KEY_HOME = 115,
+    MAC_KEY_PAGE_UP = 116,
+    MAC_KEY_PAGE_DOWN = 121,
+    MAC_KEY_END = 119,
+    MAC_KEY_FORWARD_DELETE = 117,
+
+    MAC_KEY_ESC = 53,
+    MAC_KEY_F1 = 122,
+    MAC_KEY_F2 = 120,
+    MAC_KEY_F3 = 99,
+    MAC_KEY_F4 = 118,
+    MAC_KEY_F5 = 96,
+    MAC_KEY_F6 = 97,
+    MAC_KEY_F7 = 98,
+    MAC_KEY_F8 = 100,
+    MAC_KEY_F9 = 101,
+    MAC_KEY_F10 = 109,
+    MAC_KEY_F11 = 103,
+    MAC_KEY_F12 = 111,
+    MAC_KEY_F13 = 105,
+    MAC_KEY_F14 = 107,
+    MAC_KEY_F15 = 113,
+
+    MAC_KEY_VOLUME_UP = 72,
+    MAC_KEY_VOLUME_DOWN = 73,
+    MAC_KEY_VOLUME_MUTE = 74,
+
+    /*
+     * I didn't count the Power key as the largest value because it's very large
+     * value would cause arrays that depend on MAC_KEY_LARGEST_VALUE to be too
+     * big.
+     */
+    MAC_KEY_POWER = 32639,
+
+    MAC_KEY_LARGEST_VALUE = MAC_KEY_UP,
+};
+
+/* Could not find the value for this key. */
+/* #define MAC_KEY_EJECT */
+
+#endif