diff mbox

[v3,1/4] adb-keys.h: initial commit

Message ID 065EA09A-157B-4F3A-BEFC-7C71F8020DC9@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Programmingkid March 5, 2016, 5:15 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>
---
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 | 160 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 160 insertions(+)
 create mode 100644 include/hw/input/adb-keys.h

Comments

Eric Blake March 6, 2016, 12:02 a.m. UTC | #1
On 03/04/2016 10:15 PM, Programmingkid wrote:
> This commit implements the adb-keys.h file. It holds information on adb keycode
> values.
> 
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> ---
> 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 | 160 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 160 insertions(+)
>  create mode 100644 include/hw/input/adb-keys.h

Thanks; you're getting closer at decent submission style.  Your
threading is still broken, though (the mail is missing an 'In-Reply-To:'
header that refers to <F4F7A35F-2C22-4F54-821F-03DDE2B146BC@gmail.com>
from the 0/4 cover letter); you can see this in the list archives:
https://lists.gnu.org/archive/html/qemu-devel/2016-03/threads.html#01180

Note how your messages each appear as top-level threads, while most
other series are properly threaded.

> 
> diff --git a/include/hw/input/adb-keys.h b/include/hw/input/adb-keys.h
> new file mode 100644
> index 0000000..6e009ee
> --- /dev/null
> +++ b/include/hw/input/adb-keys.h
> @@ -0,0 +1,160 @@
> +/*
> + * QEMU System Emulator
> + *
> + * Copyright (c) 2003-2008 Fabrice Bellard

Fabrice did not write this file.  You're probably better off replacing
this line wholesale with a Copyright 2016 and claiming copyright
yourself, since it is new material from you that is not substantially
copied from some existing file.

> + *
> + * 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:

Any reason you chose the weaker BSD license instead of the
project-default of GPLv2+?

> +/*
> + *  adb-keys.h
> + *
> + *  Provides a enum of all the Macintosh keycodes.

s/a enum/an enum/

Can you provide a URL to the source document that you used for coming up
with this list, so that we can better double-check your work?  (Do it as
a comment in this file, if you have one)

> + *  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 __ADBKEYS__
> +#define __ADBKEYS__

The name '__ADBKEYS__' is reserved for the compiler's use; you risk a
future collision for no good reason.  It's fine to use 'ADB_KEYS_H' as
your witness, better matching your filename and staying out of reserved
namespace.
Programmingkid March 6, 2016, 12:06 a.m. UTC | #2
On Mar 5, 2016, at 7:02 PM, Eric Blake wrote:

> On 03/04/2016 10:15 PM, Programmingkid wrote:
>> This commit implements the adb-keys.h file. It holds information on adb keycode
>> values.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>> ---
>> 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 | 160 ++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 160 insertions(+)
>> create mode 100644 include/hw/input/adb-keys.h
> 
> Thanks; you're getting closer at decent submission style.  Your
> threading is still broken, though (the mail is missing an 'In-Reply-To:'
> header that refers to <F4F7A35F-2C22-4F54-821F-03DDE2B146BC@gmail.com>
> from the 0/4 cover letter); you can see this in the list archives:
> https://lists.gnu.org/archive/html/qemu-devel/2016-03/threads.html#01180
> 
> Note how your messages each appear as top-level threads, while most
> other series are properly threaded.

I guess there is still room for improvement. :)

> 
>> 
>> diff --git a/include/hw/input/adb-keys.h b/include/hw/input/adb-keys.h
>> new file mode 100644
>> index 0000000..6e009ee
>> --- /dev/null
>> +++ b/include/hw/input/adb-keys.h
>> @@ -0,0 +1,160 @@
>> +/*
>> + * QEMU System Emulator
>> + *
>> + * Copyright (c) 2003-2008 Fabrice Bellard
> 
> Fabrice did not write this file.  You're probably better off replacing
> this line wholesale with a Copyright 2016 and claiming copyright
> yourself, since it is new material from you that is not substantially
> copied from some existing file.

Ok. 

> 
>> + *
>> + * 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:
> 
> Any reason you chose the weaker BSD license instead of the
> project-default of GPLv2+?

I just used the text that was in vl.c. I thought all files in QEMU were using GPLv2. 

> 
>> +/*
>> + *  adb-keys.h
>> + *
>> + *  Provides a enum of all the Macintosh keycodes.
> 
> s/a enum/an enum/

Good catch.

> 
> Can you provide a URL to the source document that you used for coming up
> with this list, so that we can better double-check your work?  (Do it as
> a comment in this file, if you have one)

http://stackoverflow.com/questions/3202629/where-can-i-find-a-list-of-mac-virtual-key-codes

> 
>> + *  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 __ADBKEYS__
>> +#define __ADBKEYS__
> 
> The name '__ADBKEYS__' is reserved for the compiler's use; you risk a
> future collision for no good reason.  It's fine to use 'ADB_KEYS_H' as
> your witness, better matching your filename and staying out of reserved
> namespace.

Ok.
Programmingkid March 6, 2016, 8:35 p.m. UTC | #3
On Mar 5, 2016, at 7:02 PM, Eric Blake wrote:

> On 03/04/2016 10:15 PM, Programmingkid wrote:
>> 
> 
>> + *
>> + * 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:
> 
> Any reason you chose the weaker BSD license instead of the
> project-default of GPLv2+?

Could you provide a file name or a link that has the exact text you wish to see in the file?

> Can you provide a URL to the source document that you used for coming up
> with this list, so that we can better double-check your work?  (Do it as
> a comment in this file, if you have one)

Does this look good:

/*
 *  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/where-can
 *                          -i-find-a-list-of-mac-virtual-key-codes
 */
Eric Blake March 7, 2016, 9:10 p.m. UTC | #4
On 03/06/2016 01:35 PM, Programmingkid wrote:
> 
> On Mar 5, 2016, at 7:02 PM, Eric Blake wrote:
> 
>> On 03/04/2016 10:15 PM, Programmingkid wrote:
>>>
>>
>>> + *
>>> + * 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:
>>
>> Any reason you chose the weaker BSD license instead of the
>> project-default of GPLv2+?
> 
> Could you provide a file name or a link that has the exact text you wish to see in the file?

BSD is just fine, if you have a strong reason for preferring it (it is a
weaker license than GPLv2+, which means GPL code can import BSD code,
but BSD code can't import GPL code.  Personally, I try to avoid the BSD
license on my code, because I don't like the fact that it allows
companies to make a proprietary fork of my code, while the GPL
guarantees that anyone using my code will keep it free.  But other
people don't like the GPL and intentionally favor BSD for things they
write for maximum uptake of their code.)

If you don't have a strong license preference, then there are plenty of
GPLv2+ files you can copy from:

$ git grep -l 'GPL, version 2 or' | wc -l
482

> 
>> Can you provide a URL to the source document that you used for coming up
>> with this list, so that we can better double-check your work?  (Do it as
>> a comment in this file, if you have one)
> 
> Does this look good:
> 
> /*
>  *  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/where-can
>  *                          -i-find-a-list-of-mac-virtual-key-codes

The URL is line-broken; but still works (since stackoverflow only cares
about the 3202629/ prefix). But yes, that sort of information source is
useful as a code comment.
Programmingkid March 7, 2016, 9:33 p.m. UTC | #5
On Mar 7, 2016, at 4:10 PM, Eric Blake wrote:

> On 03/06/2016 01:35 PM, Programmingkid wrote:
>> 
>> On Mar 5, 2016, at 7:02 PM, Eric Blake wrote:
>> 
>>> On 03/04/2016 10:15 PM, Programmingkid wrote:
>>>> 
>>> 
>>>> + *
>>>> + * 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:
>>> 
>>> Any reason you chose the weaker BSD license instead of the
>>> project-default of GPLv2+?
>> 
>> Could you provide a file name or a link that has the exact text you wish to see in the file?
> 
> BSD is just fine, if you have a strong reason for preferring it (it is a
> weaker license than GPLv2+, which means GPL code can import BSD code,
> but BSD code can't import GPL code.  Personally, I try to avoid the BSD
> license on my code, because I don't like the fact that it allows
> companies to make a proprietary fork of my code, while the GPL
> guarantees that anyone using my code will keep it free.  But other
> people don't like the GPL and intentionally favor BSD for things they
> write for maximum uptake of their code.)
> 
> If you don't have a strong license preference, then there are plenty of
> GPLv2+ files you can copy from:
> 
> $ git grep -l 'GPL, version 2 or' | wc -l
> 482

Rather than place the whole license agreement in the file, could I just say this:

This code is licensed under the GNU GPL v2.


>>> Can you provide a URL to the source document that you used for coming up
>>> with this list, so that we can better double-check your work?  (Do it as
>>> a comment in this file, if you have one)
>> 
>> Does this look good:
>> 
>> /*
>> *  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/where-can
>> *                          -i-find-a-list-of-mac-virtual-key-codes
> 
> The URL is line-broken; but still works (since stackoverflow only cares
> about the 3202629/ prefix). But yes, that sort of information source is
> useful as a code comment.

I didn't know I could shorten the url like that. I will definitely change the text to this:

*
*  Additional information: http://stackoverflow.com/questions/3202629
*

Thanks for this tip.
Eric Blake March 7, 2016, 9:44 p.m. UTC | #6
On 03/07/2016 02:33 PM, Programmingkid wrote:
>> If you don't have a strong license preference, then there are plenty of
>> GPLv2+ files you can copy from:
>>
>> $ git grep -l 'GPL, version 2 or' | wc -l
>> 482
> 
> Rather than place the whole license agreement in the file, could I just say this:
> 
> This code is licensed under the GNU GPL v2.

No, because that is GPLv2-only, not GPLv2+.  The "or later" clause is an
important distinction (it determines whether your code can be copied
into a GPLv3+ project), and we've declared that no new files should be
GPLv2-only unless they are copied from a pre-existing project (such as
the Linux kernel) under that restriction, so that at least the rest of
qemu is usable in GPLv3 (even while qemu itself must remain GPLv2).

But if you're asking if you can use the two-liner present in
block/null.c (among other places), sure:

 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */
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..6e009ee
--- /dev/null
+++ b/include/hw/input/adb-keys.h
@@ -0,0 +1,160 @@ 
+/*
+ * 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.
+ */
+
+/*
+ *  adb-keys.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 __ADBKEYS__
+#define __ADBKEYS__
+
+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 /* __ADBKEYS__ */