* [Qemu-devel] [PATCH v5 0/4] ADB improvements @ 2016-08-18 2:27 John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 1/4] adb-keys.h: initial commit John Arbuckle ` (4 more replies) 0 siblings, 5 replies; 13+ messages in thread From: John Arbuckle @ 2016-08-18 2:27 UTC (permalink / raw) To: qemu-ppc, david, qemu-devel; +Cc: John Arbuckle This patch series makes several improvements to the ADB code. To test this code, please implement the patches in the order below. John Arbuckle (4): adb-keys.h: initial commit adb.c: add support for QKeyCode adb.c: correct several key assignments adb.c: prevent NO_KEY value from going to guest hw/input/adb.c | 229 +++++++++++++++++++++++++++++++++++--------- include/hw/input/adb-keys.h | 141 +++++++++++++++++++++++++++ 2 files changed, 325 insertions(+), 45 deletions(-) create mode 100644 include/hw/input/adb-keys.h -- *v5 changes: Merged Power key patch with patch 2/4. Uncommented ADB_KEY_POWER in adb-keys.h. Moved qemu_input_handler_register() function call to adb_kbd_realizefn() function. Added ADB_DPRINTF() call to NO_KEY if condition. *v4 changes: Replaced ADB_KEY_LEFT_COMAND and ADB_KEY_RIGHT_COMAND with ADB_KEY_COMMAND. Removed debug printf statement. Removed stray ". Rearranged code in "correct several key assignments" and "prevent NO_KEY value from going to guest" patches. *v3 changes: Removed note from adb-keys.h. Created new patch that adds QKeyCode support, but doesn't change any mappings. Made patch that does correct key mappings. Made new patch the prevents NO_KEY value from going to guest. Add suggested comments to power key code. Moved else statement. *v2 changes: Swapped order of adb-keys.h and "add support for QKeyCode" patches. 2.7.2 ^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v5 1/4] adb-keys.h: initial commit 2016-08-18 2:27 [Qemu-devel] [PATCH v5 0/4] ADB improvements John Arbuckle @ 2016-08-18 2:27 ` John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 2/4] adb.c: add support for QKeyCode John Arbuckle ` (3 subsequent siblings) 4 siblings, 0 replies; 13+ messages in thread From: John Arbuckle @ 2016-08-18 2:27 UTC (permalink / raw) To: qemu-ppc, david, qemu-devel; +Cc: John Arbuckle Add the adb-keys.h file. It maps ADB transition key codes with values. Signed-off-by: John Arbuckle <programmingkidx@gmail.com> --- *v5 changes: Uncommented ADB_KEY_POWER constant. *v4 changes: Replaced ADB_KEY_LEFT_COMAND and ADB_KEY_RIGHT_COMAND with ADB_KEY_COMMAND. *v3 changes: Removed note. *v2 changes: Changed order of this patch. include/hw/input/adb-keys.h | 141 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 include/hw/input/adb-keys.h diff --git a/include/hw/input/adb-keys.h b/include/hw/input/adb-keys.h new file mode 100644 index 0000000..525fba8 --- /dev/null +++ b/include/hw/input/adb-keys.h @@ -0,0 +1,141 @@ +/* + * 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. + * 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 = 0x00, + ADB_KEY_B = 0x0b, + ADB_KEY_C = 0x08, + ADB_KEY_D = 0x02, + ADB_KEY_E = 0x0e, + ADB_KEY_F = 0x03, + ADB_KEY_G = 0x05, + ADB_KEY_H = 0x04, + ADB_KEY_I = 0x22, + ADB_KEY_J = 0x26, + ADB_KEY_K = 0x28, + ADB_KEY_L = 0x25, + ADB_KEY_M = 0x2e, + ADB_KEY_N = 0x2d, + ADB_KEY_O = 0x1f, + ADB_KEY_P = 0x23, + ADB_KEY_Q = 0x0c, + ADB_KEY_R = 0x0f, + ADB_KEY_S = 0x01, + ADB_KEY_T = 0x11, + ADB_KEY_U = 0x20, + ADB_KEY_V = 0x09, + ADB_KEY_W = 0x0d, + ADB_KEY_X = 0x07, + ADB_KEY_Y = 0x10, + ADB_KEY_Z = 0x06, + + ADB_KEY_0 = 0x1d, + ADB_KEY_1 = 0x12, + ADB_KEY_2 = 0x13, + ADB_KEY_3 = 0x14, + ADB_KEY_4 = 0x15, + ADB_KEY_5 = 0x17, + ADB_KEY_6 = 0x16, + ADB_KEY_7 = 0x1a, + ADB_KEY_8 = 0x1c, + ADB_KEY_9 = 0x19, + + ADB_KEY_GRAVE_ACCENT = 0x32, + ADB_KEY_MINUS = 0x1b, + ADB_KEY_EQUAL = 0x18, + ADB_KEY_DELETE = 0x33, + ADB_KEY_CAPS_LOCK = 0x39, + ADB_KEY_TAB = 0x30, + ADB_KEY_RETURN = 0x24, + ADB_KEY_LEFT_BRACKET = 0x21, + ADB_KEY_RIGHT_BRACKET = 0x1e, + ADB_KEY_BACKSLASH = 0x2a, + ADB_KEY_SEMICOLON = 0x29, + ADB_KEY_APOSTROPHE = 0x27, + ADB_KEY_COMMA = 0x2b, + ADB_KEY_PERIOD = 0x2f, + ADB_KEY_FORWARD_SLASH = 0x2c, + ADB_KEY_LEFT_SHIFT = 0x38, + ADB_KEY_RIGHT_SHIFT = 0x7b, + ADB_KEY_SPACEBAR = 0x31, + ADB_KEY_LEFT_CONTROL = 0x36, + ADB_KEY_RIGHT_CONTROL = 0x7d, + ADB_KEY_LEFT_OPTION = 0x3a, + ADB_KEY_RIGHT_OPTION = 0x7c, + ADB_KEY_COMMAND = 0x37, + + ADB_KEY_KP_0 = 0x52, + ADB_KEY_KP_1 = 0x53, + ADB_KEY_KP_2 = 0x54, + ADB_KEY_KP_3 = 0x55, + ADB_KEY_KP_4 = 0x56, + ADB_KEY_KP_5 = 0x57, + ADB_KEY_KP_6 = 0x58, + ADB_KEY_KP_7 = 0x59, + ADB_KEY_KP_8 = 0x5b, + ADB_KEY_KP_9 = 0x5c, + ADB_KEY_KP_PERIOD = 0x41, + ADB_KEY_KP_ENTER = 0x4c, + ADB_KEY_KP_PLUS = 0x45, + ADB_KEY_KP_SUBTRACT = 0x4e, + ADB_KEY_KP_MULTIPLY = 0x43, + ADB_KEY_KP_DIVIDE = 0x4b, + ADB_KEY_KP_EQUAL = 0x51, + ADB_KEY_KP_CLEAR = 0x47, + + ADB_KEY_UP = 0x3e, + ADB_KEY_DOWN = 0x3d, + ADB_KEY_LEFT = 0x3b, + ADB_KEY_RIGHT = 0x3c, + + ADB_KEY_HELP = 0x72, + ADB_KEY_HOME = 0x73, + ADB_KEY_PAGE_UP = 0x74, + ADB_KEY_PAGE_DOWN = 0x79, + ADB_KEY_END = 0x77, + ADB_KEY_FORWARD_DELETE = 0x75, + + ADB_KEY_ESC = 0x35, + ADB_KEY_F1 = 0x7a, + ADB_KEY_F2 = 0x78, + ADB_KEY_F3 = 0x63, + ADB_KEY_F4 = 0x76, + ADB_KEY_F5 = 0x60, + ADB_KEY_F6 = 0x61, + ADB_KEY_F7 = 0x62, + ADB_KEY_F8 = 0x64, + ADB_KEY_F9 = 0x65, + ADB_KEY_F10 = 0x6d, + ADB_KEY_F11 = 0x67, + ADB_KEY_F12 = 0x6f, + ADB_KEY_F13 = 0x69, + ADB_KEY_F14 = 0x6b, + ADB_KEY_F15 = 0x71, + + ADB_KEY_VOLUME_UP = 0x48, + ADB_KEY_VOLUME_DOWN = 0x49, + ADB_KEY_VOLUME_MUTE = 0x4a, + ADB_KEY_POWER = 0x7f7f +}; + +/* Could not find the value for this key. */ +/* #define ADB_KEY_EJECT */ + +#endif /* ADB_KEYS_H */ -- 2.7.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v5 2/4] adb.c: add support for QKeyCode 2016-08-18 2:27 [Qemu-devel] [PATCH v5 0/4] ADB improvements John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 1/4] adb-keys.h: initial commit John Arbuckle @ 2016-08-18 2:27 ` John Arbuckle 2016-08-18 11:04 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan 2016-09-15 0:00 ` [Qemu-devel] " David Gibson 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 3/4] adb.c: correct several key assignments John Arbuckle ` (2 subsequent siblings) 4 siblings, 2 replies; 13+ messages in thread From: John Arbuckle @ 2016-08-18 2:27 UTC (permalink / raw) To: qemu-ppc, david, qemu-devel; +Cc: John Arbuckle The old pc scancode translation is replaced with QEMU's QKeyCode. This is just a mechanical substitution, which a number of broken mappings left in. Signed-off-by: John Arbuckle <programmingkidx@gmail.com> --- *v5 changes Merged Power key patch with patch 2/4. Moved qemu_input_handler_register() function call to adb_kbd_realizefn() function. *v4 changes Replaced ADB_KEY_LEFT_COMMAND with ADB_KEY_COMMAND. Removed ADB_KEY_RIGHT_COMMAND comment. *v3 changes Kept original pc_to_adb_keycode mapping. *v2 changes Changed order of this patch. hw/input/adb.c | 234 ++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 189 insertions(+), 45 deletions(-) diff --git a/hw/input/adb.c b/hw/input/adb.c index f0ad0d4..18c220b 100644 --- a/hw/input/adb.c +++ b/hw/input/adb.c @@ -25,6 +25,9 @@ #include "hw/hw.h" #include "hw/input/adb.h" #include "ui/console.h" +#include "include/hw/input/adb-keys.h" +#include "ui/input.h" +#include "sysemu/sysemu.h" /* debug ADB */ //#define DEBUG_ADB @@ -187,23 +190,136 @@ typedef struct ADBKeyboardClass { DeviceRealize parent_realize; } ADBKeyboardClass; -static const uint8_t pc_to_adb_keycode[256] = { - 0, 53, 18, 19, 20, 21, 23, 22, 26, 28, 25, 29, 27, 24, 51, 48, - 12, 13, 14, 15, 17, 16, 32, 34, 31, 35, 33, 30, 36, 54, 0, 1, - 2, 3, 5, 4, 38, 40, 37, 41, 39, 50, 56, 42, 6, 7, 8, 9, - 11, 45, 46, 43, 47, 44,123, 67, 58, 49, 57,122,120, 99,118, 96, - 97, 98,100,101,109, 71,107, 89, 91, 92, 78, 86, 87, 88, 69, 83, - 84, 85, 82, 65, 0, 0, 10,103,111, 0, 0,110, 81, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 94, 0, 93, 0, 0, 0, 0, 0, 0,104,102, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76,125, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,105, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 75, 0, 0,124, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0,115, 62,116, 0, 59, 0, 60, 0,119, - 61,121,114,117, 0, 0, 0, 0, 0, 0, 0, 55,126, 0,127, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +int qcode_to_adb_keycode[] = { + + [Q_KEY_CODE_SHIFT] = ADB_KEY_LEFT_SHIFT, + [Q_KEY_CODE_SHIFT_R] = ADB_KEY_RIGHT_SHIFT, + [Q_KEY_CODE_ALT] = ADB_KEY_LEFT_OPTION, + [Q_KEY_CODE_ALT_R] = ADB_KEY_RIGHT_OPTION, + [Q_KEY_CODE_ALTGR] = 0, + [Q_KEY_CODE_CTRL] = ADB_KEY_LEFT_CONTROL, + [Q_KEY_CODE_CTRL_R] = ADB_KEY_RIGHT_CONTROL, + [Q_KEY_CODE_META_L] = ADB_KEY_COMMAND, + [Q_KEY_CODE_META_R] = ADB_KEY_COMMAND, + [Q_KEY_CODE_SPC] = ADB_KEY_SPACEBAR, + + [Q_KEY_CODE_ESC] = ADB_KEY_ESC, + [Q_KEY_CODE_1] = ADB_KEY_1, + [Q_KEY_CODE_2] = ADB_KEY_2, + [Q_KEY_CODE_3] = ADB_KEY_3, + [Q_KEY_CODE_4] = ADB_KEY_4, + [Q_KEY_CODE_5] = ADB_KEY_5, + [Q_KEY_CODE_6] = ADB_KEY_6, + [Q_KEY_CODE_7] = ADB_KEY_7, + [Q_KEY_CODE_8] = ADB_KEY_8, + [Q_KEY_CODE_9] = ADB_KEY_9, + [Q_KEY_CODE_0] = ADB_KEY_0, + [Q_KEY_CODE_MINUS] = ADB_KEY_MINUS, + [Q_KEY_CODE_EQUAL] = ADB_KEY_EQUAL, + [Q_KEY_CODE_BACKSPACE] = ADB_KEY_DELETE, + [Q_KEY_CODE_TAB] = ADB_KEY_TAB, + [Q_KEY_CODE_Q] = ADB_KEY_Q, + [Q_KEY_CODE_W] = ADB_KEY_W, + [Q_KEY_CODE_E] = ADB_KEY_E, + [Q_KEY_CODE_R] = ADB_KEY_R, + [Q_KEY_CODE_T] = ADB_KEY_T, + [Q_KEY_CODE_Y] = ADB_KEY_Y, + [Q_KEY_CODE_U] = ADB_KEY_U, + [Q_KEY_CODE_I] = ADB_KEY_I, + [Q_KEY_CODE_O] = ADB_KEY_O, + [Q_KEY_CODE_P] = ADB_KEY_P, + [Q_KEY_CODE_BRACKET_LEFT] = ADB_KEY_LEFT_BRACKET, + [Q_KEY_CODE_BRACKET_RIGHT] = ADB_KEY_RIGHT_BRACKET, + [Q_KEY_CODE_RET] = ADB_KEY_RETURN, + [Q_KEY_CODE_A] = ADB_KEY_A, + [Q_KEY_CODE_S] = ADB_KEY_S, + [Q_KEY_CODE_D] = ADB_KEY_D, + [Q_KEY_CODE_F] = ADB_KEY_F, + [Q_KEY_CODE_G] = ADB_KEY_G, + [Q_KEY_CODE_H] = ADB_KEY_H, + [Q_KEY_CODE_J] = ADB_KEY_J, + [Q_KEY_CODE_K] = ADB_KEY_K, + [Q_KEY_CODE_L] = ADB_KEY_L, + [Q_KEY_CODE_SEMICOLON] = ADB_KEY_SEMICOLON, + [Q_KEY_CODE_APOSTROPHE] = ADB_KEY_APOSTROPHE, + [Q_KEY_CODE_GRAVE_ACCENT] = ADB_KEY_GRAVE_ACCENT, + [Q_KEY_CODE_BACKSLASH] = ADB_KEY_BACKSLASH, + [Q_KEY_CODE_Z] = ADB_KEY_Z, + [Q_KEY_CODE_X] = ADB_KEY_X, + [Q_KEY_CODE_C] = ADB_KEY_C, + [Q_KEY_CODE_V] = ADB_KEY_V, + [Q_KEY_CODE_B] = ADB_KEY_B, + [Q_KEY_CODE_N] = ADB_KEY_N, + [Q_KEY_CODE_M] = ADB_KEY_M, + [Q_KEY_CODE_COMMA] = ADB_KEY_COMMA, + [Q_KEY_CODE_DOT] = ADB_KEY_PERIOD, + [Q_KEY_CODE_SLASH] = ADB_KEY_FORWARD_SLASH, + [Q_KEY_CODE_ASTERISK] = ADB_KEY_KP_MULTIPLY, + [Q_KEY_CODE_CAPS_LOCK] = ADB_KEY_CAPS_LOCK, + + [Q_KEY_CODE_F1] = ADB_KEY_F1, + [Q_KEY_CODE_F2] = ADB_KEY_F2, + [Q_KEY_CODE_F3] = ADB_KEY_F3, + [Q_KEY_CODE_F4] = ADB_KEY_F4, + [Q_KEY_CODE_F5] = ADB_KEY_F5, + [Q_KEY_CODE_F6] = ADB_KEY_F6, + [Q_KEY_CODE_F7] = ADB_KEY_F7, + [Q_KEY_CODE_F8] = ADB_KEY_F8, + [Q_KEY_CODE_F9] = ADB_KEY_F9, + [Q_KEY_CODE_F10] = ADB_KEY_F10, + [Q_KEY_CODE_F11] = ADB_KEY_F11, + [Q_KEY_CODE_F12] = ADB_KEY_F12, + [Q_KEY_CODE_PRINT] = 0, + [Q_KEY_CODE_SYSRQ] = 0, + [Q_KEY_CODE_SCROLL_LOCK] = ADB_KEY_F14, + [Q_KEY_CODE_PAUSE] = 0, + + [Q_KEY_CODE_NUM_LOCK] = ADB_KEY_KP_CLEAR, + [Q_KEY_CODE_KP_EQUALS] = 0, + [Q_KEY_CODE_KP_DIVIDE] = ADB_KEY_KP_DIVIDE, + [Q_KEY_CODE_KP_MULTIPLY] = ADB_KEY_KP_MULTIPLY, + [Q_KEY_CODE_KP_SUBTRACT] = ADB_KEY_KP_SUBTRACT, + [Q_KEY_CODE_KP_ADD] = ADB_KEY_KP_PLUS, + [Q_KEY_CODE_KP_ENTER] = ADB_KEY_KP_ENTER, + [Q_KEY_CODE_KP_DECIMAL] = ADB_KEY_KP_PERIOD, + [Q_KEY_CODE_KP_0] = ADB_KEY_KP_0, + [Q_KEY_CODE_KP_1] = ADB_KEY_KP_1, + [Q_KEY_CODE_KP_2] = ADB_KEY_KP_2, + [Q_KEY_CODE_KP_3] = ADB_KEY_KP_3, + [Q_KEY_CODE_KP_4] = ADB_KEY_KP_4, + [Q_KEY_CODE_KP_5] = ADB_KEY_KP_5, + [Q_KEY_CODE_KP_6] = ADB_KEY_KP_6, + [Q_KEY_CODE_KP_7] = ADB_KEY_KP_7, + [Q_KEY_CODE_KP_8] = ADB_KEY_KP_8, + [Q_KEY_CODE_KP_9] = ADB_KEY_KP_9, + + [Q_KEY_CODE_UP] = ADB_KEY_UP, + [Q_KEY_CODE_DOWN] = ADB_KEY_DOWN, + [Q_KEY_CODE_LEFT] = ADB_KEY_LEFT, + [Q_KEY_CODE_RIGHT] = ADB_KEY_RIGHT, + + [Q_KEY_CODE_HELP] = 0, + [Q_KEY_CODE_INSERT] = ADB_KEY_HELP, + [Q_KEY_CODE_DELETE] = ADB_KEY_FORWARD_DELETE, + [Q_KEY_CODE_HOME] = ADB_KEY_HOME, + [Q_KEY_CODE_END] = ADB_KEY_END, + [Q_KEY_CODE_PGUP] = ADB_KEY_PAGE_UP, + [Q_KEY_CODE_PGDN] = ADB_KEY_PAGE_DOWN, + + [Q_KEY_CODE_LESS] = 0xa, + [Q_KEY_CODE_STOP] = 0, + [Q_KEY_CODE_AGAIN] = 0, + [Q_KEY_CODE_PROPS] = 0, + [Q_KEY_CODE_UNDO] = 0, + [Q_KEY_CODE_FRONT] = 0, + [Q_KEY_CODE_COPY] = 0, + [Q_KEY_CODE_OPEN] = 0, + [Q_KEY_CODE_PASTE] = 0, + [Q_KEY_CODE_FIND] = 0, + [Q_KEY_CODE_CUT] = 0, + [Q_KEY_CODE_LF] = 0, + [Q_KEY_CODE_COMPOSE] = 0, + [Q_KEY_CODE_POWER] = ADB_KEY_POWER }; static void adb_kbd_put_keycode(void *opaque, int keycode) @@ -220,35 +336,40 @@ static void adb_kbd_put_keycode(void *opaque, int keycode) static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf) { - static int ext_keycode; KBDState *s = ADB_KEYBOARD(d); - int adb_keycode, keycode; + int keycode; int olen; olen = 0; - for(;;) { - if (s->count == 0) - break; - keycode = s->data[s->rptr]; - if (++s->rptr == sizeof(s->data)) - s->rptr = 0; - s->count--; - - if (keycode == 0xe0) { - ext_keycode = 1; - } else { - if (ext_keycode) - adb_keycode = pc_to_adb_keycode[keycode | 0x80]; - else - adb_keycode = pc_to_adb_keycode[keycode & 0x7f]; - obuf[0] = adb_keycode | (keycode & 0x80); - /* NOTE: could put a second keycode if needed */ - obuf[1] = 0xff; - olen = 2; - ext_keycode = 0; - break; - } + if (s->count == 0) { + return 0; + } + keycode = s->data[s->rptr]; + s->rptr++; + if (s->rptr == sizeof(s->data)) { + s->rptr = 0; } + s->count--; + /* + * The power key is the only two byte value key, so it is a special case. + * Since 0x7f is not a used keycode for ADB we overload it to indicate the + * power button when we're storing keycodes in our internal buffer, and + * expand it out to two bytes when we send to the guest. + */ + if (keycode == 0x7f) { + obuf[0] = 0x7f; + obuf[1] = 0x7f; + olen = 2; + } else { + obuf[0] = keycode; + /* NOTE: the power key key-up is the two byte sequence 0xff 0xff; + * otherwise we could in theory send a second keycode in the second + * byte, but choose not to bother. + */ + obuf[1] = 0xff; + olen = 2; + } + return olen; } @@ -313,6 +434,26 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, return olen; } +/* This is where keyboard events enter this file */ +static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, + InputEvent *evt) +{ + KBDState *s = (KBDState *)dev; + int qcode, keycode; + + qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key); + if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) { + return; + } + keycode = qcode_to_adb_keycode[qcode]; + + if (evt->u.key.data->down == false) { /* if key release event */ + keycode = keycode | 0x80; /* create keyboard break code */ + } + + adb_kbd_put_keycode(s, keycode); +} + static const VMStateDescription vmstate_adb_kbd = { .name = "adb_kbd", .version_id = 2, @@ -340,14 +481,17 @@ static void adb_kbd_reset(DeviceState *dev) s->count = 0; } +static QemuInputHandler adb_keyboard_handler = { + .name = "QEMU ADB Keyboard", + .mask = INPUT_EVENT_MASK_KEY, + .event = adb_keyboard_event, +}; + static void adb_kbd_realizefn(DeviceState *dev, Error **errp) { - ADBDevice *d = ADB_DEVICE(dev); ADBKeyboardClass *akc = ADB_KEYBOARD_GET_CLASS(dev); - akc->parent_realize(dev, errp); - - qemu_add_kbd_event_handler(adb_kbd_put_keycode, d); + qemu_input_handler_register(dev, &adb_keyboard_handler); } static void adb_kbd_initfn(Object *obj) -- 2.7.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v5 2/4] adb.c: add support for QKeyCode 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 2/4] adb.c: add support for QKeyCode John Arbuckle @ 2016-08-18 11:04 ` BALATON Zoltan 2016-09-15 0:00 ` [Qemu-devel] " David Gibson 1 sibling, 0 replies; 13+ messages in thread From: BALATON Zoltan @ 2016-08-18 11:04 UTC (permalink / raw) To: John Arbuckle; +Cc: qemu-ppc, david, qemu-devel Hello, Not a review just some style comments. On Wed, 17 Aug 2016, John Arbuckle wrote: > static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf) > { > - static int ext_keycode; > KBDState *s = ADB_KEYBOARD(d); > - int adb_keycode, keycode; > + int keycode; > int olen; > > olen = 0; > - for(;;) { > - if (s->count == 0) > - break; > - keycode = s->data[s->rptr]; > - if (++s->rptr == sizeof(s->data)) > - s->rptr = 0; > - s->count--; > - > - if (keycode == 0xe0) { > - ext_keycode = 1; > - } else { > - if (ext_keycode) > - adb_keycode = pc_to_adb_keycode[keycode | 0x80]; > - else > - adb_keycode = pc_to_adb_keycode[keycode & 0x7f]; > - obuf[0] = adb_keycode | (keycode & 0x80); > - /* NOTE: could put a second keycode if needed */ > - obuf[1] = 0xff; > - olen = 2; > - ext_keycode = 0; > - break; > - } > + if (s->count == 0) { > + return 0; > + } > + keycode = s->data[s->rptr]; > + s->rptr++; > + if (s->rptr == sizeof(s->data)) { > + s->rptr = 0; > } > + s->count--; It's more ususal to use the postfix increment/decrement in the same line where the value is used than its own line, unless that's needed to be separate (that's why there are two variants: post and prefix). So you could do the ++ in the if or where keycode is assigned and you may be able to move the -- also the other if when the value of count can go one less (or at least move the s->count-- line closer to the if which looks clearer to me but that may be my taste only. Regards, BALATON Zoltan > + /* > + * The power key is the only two byte value key, so it is a special case. > + * Since 0x7f is not a used keycode for ADB we overload it to indicate the > + * power button when we're storing keycodes in our internal buffer, and > + * expand it out to two bytes when we send to the guest. > + */ > + if (keycode == 0x7f) { > + obuf[0] = 0x7f; > + obuf[1] = 0x7f; > + olen = 2; > + } else { > + obuf[0] = keycode; > + /* NOTE: the power key key-up is the two byte sequence 0xff 0xff; > + * otherwise we could in theory send a second keycode in the second > + * byte, but choose not to bother. > + */ > + obuf[1] = 0xff; > + olen = 2; > + } > + > return olen; > } > > @@ -313,6 +434,26 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, > return olen; > } ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v5 2/4] adb.c: add support for QKeyCode 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 2/4] adb.c: add support for QKeyCode John Arbuckle 2016-08-18 11:04 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan @ 2016-09-15 0:00 ` David Gibson 1 sibling, 0 replies; 13+ messages in thread From: David Gibson @ 2016-09-15 0:00 UTC (permalink / raw) To: John Arbuckle; +Cc: qemu-ppc, qemu-devel [-- Attachment #1: Type: text/plain, Size: 12775 bytes --] On Wed, Aug 17, 2016 at 10:27:48PM -0400, John Arbuckle wrote: > The old pc scancode translation is replaced with QEMU's QKeyCode. This is just > a mechanical substitution, which a number of broken mappings left in. > > Signed-off-by: John Arbuckle <programmingkidx@gmail.com> > --- > *v5 changes > Merged Power key patch with patch 2/4. > Moved qemu_input_handler_register() function call to adb_kbd_realizefn() > function. > > *v4 changes > Replaced ADB_KEY_LEFT_COMMAND with ADB_KEY_COMMAND. > Removed ADB_KEY_RIGHT_COMMAND comment. > > *v3 changes > Kept original pc_to_adb_keycode mapping. > > *v2 changes > Changed order of this patch. > > hw/input/adb.c | 234 ++++++++++++++++++++++++++++++++++++++++++++++----------- > 1 file changed, 189 insertions(+), 45 deletions(-) > > diff --git a/hw/input/adb.c b/hw/input/adb.c > index f0ad0d4..18c220b 100644 > --- a/hw/input/adb.c > +++ b/hw/input/adb.c > @@ -25,6 +25,9 @@ > #include "hw/hw.h" > #include "hw/input/adb.h" > #include "ui/console.h" > +#include "include/hw/input/adb-keys.h" > +#include "ui/input.h" > +#include "sysemu/sysemu.h" > > /* debug ADB */ > //#define DEBUG_ADB > @@ -187,23 +190,136 @@ typedef struct ADBKeyboardClass { > DeviceRealize parent_realize; > } ADBKeyboardClass; > > -static const uint8_t pc_to_adb_keycode[256] = { > - 0, 53, 18, 19, 20, 21, 23, 22, 26, 28, 25, 29, 27, 24, 51, 48, > - 12, 13, 14, 15, 17, 16, 32, 34, 31, 35, 33, 30, 36, 54, 0, 1, > - 2, 3, 5, 4, 38, 40, 37, 41, 39, 50, 56, 42, 6, 7, 8, 9, > - 11, 45, 46, 43, 47, 44,123, 67, 58, 49, 57,122,120, 99,118, 96, > - 97, 98,100,101,109, 71,107, 89, 91, 92, 78, 86, 87, 88, 69, 83, > - 84, 85, 82, 65, 0, 0, 10,103,111, 0, 0,110, 81, 0, 0, 0, > - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > - 0, 0, 0, 94, 0, 93, 0, 0, 0, 0, 0, 0,104,102, 0, 0, > - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76,125, 0, 0, > - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,105, 0, 0, 0, 0, 0, > - 0, 0, 0, 0, 0, 75, 0, 0,124, 0, 0, 0, 0, 0, 0, 0, > - 0, 0, 0, 0, 0, 0, 0,115, 62,116, 0, 59, 0, 60, 0,119, > - 61,121,114,117, 0, 0, 0, 0, 0, 0, 0, 55,126, 0,127, 0, > - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > - 0, 0, 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, > +int qcode_to_adb_keycode[] = { > + > + [Q_KEY_CODE_SHIFT] = ADB_KEY_LEFT_SHIFT, > + [Q_KEY_CODE_SHIFT_R] = ADB_KEY_RIGHT_SHIFT, > + [Q_KEY_CODE_ALT] = ADB_KEY_LEFT_OPTION, > + [Q_KEY_CODE_ALT_R] = ADB_KEY_RIGHT_OPTION, > + [Q_KEY_CODE_ALTGR] = 0, > + [Q_KEY_CODE_CTRL] = ADB_KEY_LEFT_CONTROL, > + [Q_KEY_CODE_CTRL_R] = ADB_KEY_RIGHT_CONTROL, > + [Q_KEY_CODE_META_L] = ADB_KEY_COMMAND, > + [Q_KEY_CODE_META_R] = ADB_KEY_COMMAND, > + [Q_KEY_CODE_SPC] = ADB_KEY_SPACEBAR, > + > + [Q_KEY_CODE_ESC] = ADB_KEY_ESC, > + [Q_KEY_CODE_1] = ADB_KEY_1, > + [Q_KEY_CODE_2] = ADB_KEY_2, > + [Q_KEY_CODE_3] = ADB_KEY_3, > + [Q_KEY_CODE_4] = ADB_KEY_4, > + [Q_KEY_CODE_5] = ADB_KEY_5, > + [Q_KEY_CODE_6] = ADB_KEY_6, > + [Q_KEY_CODE_7] = ADB_KEY_7, > + [Q_KEY_CODE_8] = ADB_KEY_8, > + [Q_KEY_CODE_9] = ADB_KEY_9, > + [Q_KEY_CODE_0] = ADB_KEY_0, > + [Q_KEY_CODE_MINUS] = ADB_KEY_MINUS, > + [Q_KEY_CODE_EQUAL] = ADB_KEY_EQUAL, > + [Q_KEY_CODE_BACKSPACE] = ADB_KEY_DELETE, > + [Q_KEY_CODE_TAB] = ADB_KEY_TAB, > + [Q_KEY_CODE_Q] = ADB_KEY_Q, > + [Q_KEY_CODE_W] = ADB_KEY_W, > + [Q_KEY_CODE_E] = ADB_KEY_E, > + [Q_KEY_CODE_R] = ADB_KEY_R, > + [Q_KEY_CODE_T] = ADB_KEY_T, > + [Q_KEY_CODE_Y] = ADB_KEY_Y, > + [Q_KEY_CODE_U] = ADB_KEY_U, > + [Q_KEY_CODE_I] = ADB_KEY_I, > + [Q_KEY_CODE_O] = ADB_KEY_O, > + [Q_KEY_CODE_P] = ADB_KEY_P, > + [Q_KEY_CODE_BRACKET_LEFT] = ADB_KEY_LEFT_BRACKET, > + [Q_KEY_CODE_BRACKET_RIGHT] = ADB_KEY_RIGHT_BRACKET, > + [Q_KEY_CODE_RET] = ADB_KEY_RETURN, > + [Q_KEY_CODE_A] = ADB_KEY_A, > + [Q_KEY_CODE_S] = ADB_KEY_S, > + [Q_KEY_CODE_D] = ADB_KEY_D, > + [Q_KEY_CODE_F] = ADB_KEY_F, > + [Q_KEY_CODE_G] = ADB_KEY_G, > + [Q_KEY_CODE_H] = ADB_KEY_H, > + [Q_KEY_CODE_J] = ADB_KEY_J, > + [Q_KEY_CODE_K] = ADB_KEY_K, > + [Q_KEY_CODE_L] = ADB_KEY_L, > + [Q_KEY_CODE_SEMICOLON] = ADB_KEY_SEMICOLON, > + [Q_KEY_CODE_APOSTROPHE] = ADB_KEY_APOSTROPHE, > + [Q_KEY_CODE_GRAVE_ACCENT] = ADB_KEY_GRAVE_ACCENT, > + [Q_KEY_CODE_BACKSLASH] = ADB_KEY_BACKSLASH, > + [Q_KEY_CODE_Z] = ADB_KEY_Z, > + [Q_KEY_CODE_X] = ADB_KEY_X, > + [Q_KEY_CODE_C] = ADB_KEY_C, > + [Q_KEY_CODE_V] = ADB_KEY_V, > + [Q_KEY_CODE_B] = ADB_KEY_B, > + [Q_KEY_CODE_N] = ADB_KEY_N, > + [Q_KEY_CODE_M] = ADB_KEY_M, > + [Q_KEY_CODE_COMMA] = ADB_KEY_COMMA, > + [Q_KEY_CODE_DOT] = ADB_KEY_PERIOD, > + [Q_KEY_CODE_SLASH] = ADB_KEY_FORWARD_SLASH, > + [Q_KEY_CODE_ASTERISK] = ADB_KEY_KP_MULTIPLY, > + [Q_KEY_CODE_CAPS_LOCK] = ADB_KEY_CAPS_LOCK, > + > + [Q_KEY_CODE_F1] = ADB_KEY_F1, > + [Q_KEY_CODE_F2] = ADB_KEY_F2, > + [Q_KEY_CODE_F3] = ADB_KEY_F3, > + [Q_KEY_CODE_F4] = ADB_KEY_F4, > + [Q_KEY_CODE_F5] = ADB_KEY_F5, > + [Q_KEY_CODE_F6] = ADB_KEY_F6, > + [Q_KEY_CODE_F7] = ADB_KEY_F7, > + [Q_KEY_CODE_F8] = ADB_KEY_F8, > + [Q_KEY_CODE_F9] = ADB_KEY_F9, > + [Q_KEY_CODE_F10] = ADB_KEY_F10, > + [Q_KEY_CODE_F11] = ADB_KEY_F11, > + [Q_KEY_CODE_F12] = ADB_KEY_F12, > + [Q_KEY_CODE_PRINT] = 0, > + [Q_KEY_CODE_SYSRQ] = 0, > + [Q_KEY_CODE_SCROLL_LOCK] = ADB_KEY_F14, > + [Q_KEY_CODE_PAUSE] = 0, > + > + [Q_KEY_CODE_NUM_LOCK] = ADB_KEY_KP_CLEAR, > + [Q_KEY_CODE_KP_EQUALS] = 0, > + [Q_KEY_CODE_KP_DIVIDE] = ADB_KEY_KP_DIVIDE, > + [Q_KEY_CODE_KP_MULTIPLY] = ADB_KEY_KP_MULTIPLY, > + [Q_KEY_CODE_KP_SUBTRACT] = ADB_KEY_KP_SUBTRACT, > + [Q_KEY_CODE_KP_ADD] = ADB_KEY_KP_PLUS, > + [Q_KEY_CODE_KP_ENTER] = ADB_KEY_KP_ENTER, > + [Q_KEY_CODE_KP_DECIMAL] = ADB_KEY_KP_PERIOD, > + [Q_KEY_CODE_KP_0] = ADB_KEY_KP_0, > + [Q_KEY_CODE_KP_1] = ADB_KEY_KP_1, > + [Q_KEY_CODE_KP_2] = ADB_KEY_KP_2, > + [Q_KEY_CODE_KP_3] = ADB_KEY_KP_3, > + [Q_KEY_CODE_KP_4] = ADB_KEY_KP_4, > + [Q_KEY_CODE_KP_5] = ADB_KEY_KP_5, > + [Q_KEY_CODE_KP_6] = ADB_KEY_KP_6, > + [Q_KEY_CODE_KP_7] = ADB_KEY_KP_7, > + [Q_KEY_CODE_KP_8] = ADB_KEY_KP_8, > + [Q_KEY_CODE_KP_9] = ADB_KEY_KP_9, > + > + [Q_KEY_CODE_UP] = ADB_KEY_UP, > + [Q_KEY_CODE_DOWN] = ADB_KEY_DOWN, > + [Q_KEY_CODE_LEFT] = ADB_KEY_LEFT, > + [Q_KEY_CODE_RIGHT] = ADB_KEY_RIGHT, > + > + [Q_KEY_CODE_HELP] = 0, > + [Q_KEY_CODE_INSERT] = ADB_KEY_HELP, > + [Q_KEY_CODE_DELETE] = ADB_KEY_FORWARD_DELETE, > + [Q_KEY_CODE_HOME] = ADB_KEY_HOME, > + [Q_KEY_CODE_END] = ADB_KEY_END, > + [Q_KEY_CODE_PGUP] = ADB_KEY_PAGE_UP, > + [Q_KEY_CODE_PGDN] = ADB_KEY_PAGE_DOWN, > + > + [Q_KEY_CODE_LESS] = 0xa, > + [Q_KEY_CODE_STOP] = 0, > + [Q_KEY_CODE_AGAIN] = 0, > + [Q_KEY_CODE_PROPS] = 0, > + [Q_KEY_CODE_UNDO] = 0, > + [Q_KEY_CODE_FRONT] = 0, > + [Q_KEY_CODE_COPY] = 0, > + [Q_KEY_CODE_OPEN] = 0, > + [Q_KEY_CODE_PASTE] = 0, > + [Q_KEY_CODE_FIND] = 0, > + [Q_KEY_CODE_CUT] = 0, > + [Q_KEY_CODE_LF] = 0, > + [Q_KEY_CODE_COMPOSE] = 0, > + [Q_KEY_CODE_POWER] = ADB_KEY_POWER > }; > > static void adb_kbd_put_keycode(void *opaque, int keycode) > @@ -220,35 +336,40 @@ static void adb_kbd_put_keycode(void *opaque, int keycode) > > static int adb_kbd_poll(ADBDevice *d, uint8_t *obuf) > { > - static int ext_keycode; > KBDState *s = ADB_KEYBOARD(d); > - int adb_keycode, keycode; > + int keycode; > int olen; > > olen = 0; > - for(;;) { > - if (s->count == 0) > - break; > - keycode = s->data[s->rptr]; > - if (++s->rptr == sizeof(s->data)) > - s->rptr = 0; > - s->count--; > - > - if (keycode == 0xe0) { > - ext_keycode = 1; > - } else { > - if (ext_keycode) > - adb_keycode = pc_to_adb_keycode[keycode | 0x80]; > - else > - adb_keycode = pc_to_adb_keycode[keycode & 0x7f]; > - obuf[0] = adb_keycode | (keycode & 0x80); > - /* NOTE: could put a second keycode if needed */ > - obuf[1] = 0xff; > - olen = 2; > - ext_keycode = 0; > - break; > - } > + if (s->count == 0) { > + return 0; > + } > + keycode = s->data[s->rptr]; > + s->rptr++; > + if (s->rptr == sizeof(s->data)) { > + s->rptr = 0; > } > + s->count--; > + /* > + * The power key is the only two byte value key, so it is a special case. > + * Since 0x7f is not a used keycode for ADB we overload it to indicate the > + * power button when we're storing keycodes in our internal buffer, and > + * expand it out to two bytes when we send to the guest. > + */ > + if (keycode == 0x7f) { > + obuf[0] = 0x7f; > + obuf[1] = 0x7f; > + olen = 2; > + } else { > + obuf[0] = keycode; > + /* NOTE: the power key key-up is the two byte sequence 0xff 0xff; > + * otherwise we could in theory send a second keycode in the second > + * byte, but choose not to bother. > + */ > + obuf[1] = 0xff; > + olen = 2; > + } > + > return olen; > } > > @@ -313,6 +434,26 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf, > return olen; > } > > +/* This is where keyboard events enter this file */ > +static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, > + InputEvent *evt) > +{ > + KBDState *s = (KBDState *)dev; > + int qcode, keycode; > + > + qcode = qemu_input_key_value_to_qcode(evt->u.key.data->key); > + if (qcode >= ARRAY_SIZE(qcode_to_adb_keycode)) { > + return; > + } > + keycode = qcode_to_adb_keycode[qcode]; > + > + if (evt->u.key.data->down == false) { /* if key release event */ > + keycode = keycode | 0x80; /* create keyboard break code */ > + } > + > + adb_kbd_put_keycode(s, keycode); Relying on adb_kbd_put_keycode() to truncate 0x7f7f to 0x7f is a bit subtle. The truncation of 0x7f7f | 0x80 == 0x7fff to 0xff is even more so. But otherwise these patches look good, and I'll apply to ppc-for-2.8. > +} > + > static const VMStateDescription vmstate_adb_kbd = { > .name = "adb_kbd", > .version_id = 2, > @@ -340,14 +481,17 @@ static void adb_kbd_reset(DeviceState *dev) > s->count = 0; > } > > +static QemuInputHandler adb_keyboard_handler = { > + .name = "QEMU ADB Keyboard", > + .mask = INPUT_EVENT_MASK_KEY, > + .event = adb_keyboard_event, > +}; > + > static void adb_kbd_realizefn(DeviceState *dev, Error **errp) > { > - ADBDevice *d = ADB_DEVICE(dev); > ADBKeyboardClass *akc = ADB_KEYBOARD_GET_CLASS(dev); > - > akc->parent_realize(dev, errp); > - > - qemu_add_kbd_event_handler(adb_kbd_put_keycode, d); > + qemu_input_handler_register(dev, &adb_keyboard_handler); > } > > static void adb_kbd_initfn(Object *obj) -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 801 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v5 3/4] adb.c: correct several key assignments 2016-08-18 2:27 [Qemu-devel] [PATCH v5 0/4] ADB improvements John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 1/4] adb-keys.h: initial commit John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 2/4] adb.c: add support for QKeyCode John Arbuckle @ 2016-08-18 2:27 ` John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 4/4] adb.c: prevent NO_KEY value from going to guest John Arbuckle 2016-08-18 2:37 ` [Qemu-devel] [PATCH v5 0/4] ADB improvements no-reply 4 siblings, 0 replies; 13+ messages in thread From: John Arbuckle @ 2016-08-18 2:27 UTC (permalink / raw) To: qemu-ppc, david, qemu-devel; +Cc: John Arbuckle The original pc_to_adb_keycode mapping did have several keys that were incorrectly mapped. This patch fixes these mappings. Signed-off-by: John Arbuckle <programmingkidx@gmail.com> --- v4 changes: Removed NO_KEY related code. Kept all the "= 0" code near the end of the qcode_to_adb_keycode. hw/input/adb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/input/adb.c b/hw/input/adb.c index 18c220b..12c6333 100644 --- a/hw/input/adb.c +++ b/hw/input/adb.c @@ -196,7 +196,7 @@ int qcode_to_adb_keycode[] = { [Q_KEY_CODE_SHIFT_R] = ADB_KEY_RIGHT_SHIFT, [Q_KEY_CODE_ALT] = ADB_KEY_LEFT_OPTION, [Q_KEY_CODE_ALT_R] = ADB_KEY_RIGHT_OPTION, - [Q_KEY_CODE_ALTGR] = 0, + [Q_KEY_CODE_ALTGR] = ADB_KEY_RIGHT_OPTION, [Q_KEY_CODE_CTRL] = ADB_KEY_LEFT_CONTROL, [Q_KEY_CODE_CTRL_R] = ADB_KEY_RIGHT_CONTROL, [Q_KEY_CODE_META_L] = ADB_KEY_COMMAND, @@ -269,13 +269,13 @@ int qcode_to_adb_keycode[] = { [Q_KEY_CODE_F10] = ADB_KEY_F10, [Q_KEY_CODE_F11] = ADB_KEY_F11, [Q_KEY_CODE_F12] = ADB_KEY_F12, - [Q_KEY_CODE_PRINT] = 0, - [Q_KEY_CODE_SYSRQ] = 0, + [Q_KEY_CODE_PRINT] = ADB_KEY_F13, + [Q_KEY_CODE_SYSRQ] = ADB_KEY_F13, [Q_KEY_CODE_SCROLL_LOCK] = ADB_KEY_F14, - [Q_KEY_CODE_PAUSE] = 0, + [Q_KEY_CODE_PAUSE] = ADB_KEY_F15, [Q_KEY_CODE_NUM_LOCK] = ADB_KEY_KP_CLEAR, - [Q_KEY_CODE_KP_EQUALS] = 0, + [Q_KEY_CODE_KP_EQUALS] = ADB_KEY_KP_EQUAL, [Q_KEY_CODE_KP_DIVIDE] = ADB_KEY_KP_DIVIDE, [Q_KEY_CODE_KP_MULTIPLY] = ADB_KEY_KP_MULTIPLY, [Q_KEY_CODE_KP_SUBTRACT] = ADB_KEY_KP_SUBTRACT, @@ -298,7 +298,7 @@ int qcode_to_adb_keycode[] = { [Q_KEY_CODE_LEFT] = ADB_KEY_LEFT, [Q_KEY_CODE_RIGHT] = ADB_KEY_RIGHT, - [Q_KEY_CODE_HELP] = 0, + [Q_KEY_CODE_HELP] = ADB_KEY_HELP, [Q_KEY_CODE_INSERT] = ADB_KEY_HELP, [Q_KEY_CODE_DELETE] = ADB_KEY_FORWARD_DELETE, [Q_KEY_CODE_HOME] = ADB_KEY_HOME, -- 2.7.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v5 4/4] adb.c: prevent NO_KEY value from going to guest 2016-08-18 2:27 [Qemu-devel] [PATCH v5 0/4] ADB improvements John Arbuckle ` (2 preceding siblings ...) 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 3/4] adb.c: correct several key assignments John Arbuckle @ 2016-08-18 2:27 ` John Arbuckle 2016-08-18 11:06 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan 2016-08-18 2:37 ` [Qemu-devel] [PATCH v5 0/4] ADB improvements no-reply 4 siblings, 1 reply; 13+ messages in thread From: John Arbuckle @ 2016-08-18 2:27 UTC (permalink / raw) To: qemu-ppc, david, qemu-devel; +Cc: John Arbuckle The NO_KEY value should not be sent to the guest. This patch drops that value. Signed-off-by: John Arbuckle <programmingkidx@gmail.com> --- v5 changes: Added ADB_DPRINTF() call. v4 changes: Added NO_KEY related code to this patch. Added removal of "= 0" code near end of qcode_to_adb_keycode. hw/input/adb.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/hw/input/adb.c b/hw/input/adb.c index 12c6333..3d39368 100644 --- a/hw/input/adb.c +++ b/hw/input/adb.c @@ -62,6 +62,9 @@ do { printf("ADB: " fmt , ## __VA_ARGS__); } while (0) /* error codes */ #define ADB_RET_NOTPRESENT (-2) +/* The adb keyboard doesn't have every key imaginable */ +#define NO_KEY 0xff + static void adb_device_reset(ADBDevice *d) { qdev_reset_all(DEVICE(d)); @@ -191,6 +194,8 @@ typedef struct ADBKeyboardClass { } ADBKeyboardClass; int qcode_to_adb_keycode[] = { + /* Make sure future additions are automatically set to NO_KEY */ + [0 ... 0xff] = NO_KEY, [Q_KEY_CODE_SHIFT] = ADB_KEY_LEFT_SHIFT, [Q_KEY_CODE_SHIFT_R] = ADB_KEY_RIGHT_SHIFT, @@ -306,19 +311,6 @@ int qcode_to_adb_keycode[] = { [Q_KEY_CODE_PGUP] = ADB_KEY_PAGE_UP, [Q_KEY_CODE_PGDN] = ADB_KEY_PAGE_DOWN, - [Q_KEY_CODE_LESS] = 0xa, - [Q_KEY_CODE_STOP] = 0, - [Q_KEY_CODE_AGAIN] = 0, - [Q_KEY_CODE_PROPS] = 0, - [Q_KEY_CODE_UNDO] = 0, - [Q_KEY_CODE_FRONT] = 0, - [Q_KEY_CODE_COPY] = 0, - [Q_KEY_CODE_OPEN] = 0, - [Q_KEY_CODE_PASTE] = 0, - [Q_KEY_CODE_FIND] = 0, - [Q_KEY_CODE_CUT] = 0, - [Q_KEY_CODE_LF] = 0, - [Q_KEY_CODE_COMPOSE] = 0, [Q_KEY_CODE_POWER] = ADB_KEY_POWER }; @@ -446,7 +438,10 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, return; } keycode = qcode_to_adb_keycode[qcode]; - + if (keycode == NO_KEY) { /* We don't want to send this to the guest */ + ADB_DPRINTF("Ignoring NO_KEY\n"); + return; + } if (evt->u.key.data->down == false) { /* if key release event */ keycode = keycode | 0x80; /* create keyboard break code */ } -- 2.7.2 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v5 4/4] adb.c: prevent NO_KEY value from going to guest 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 4/4] adb.c: prevent NO_KEY value from going to guest John Arbuckle @ 2016-08-18 11:06 ` BALATON Zoltan 2016-08-20 1:29 ` Programmingkid 0 siblings, 1 reply; 13+ messages in thread From: BALATON Zoltan @ 2016-08-18 11:06 UTC (permalink / raw) To: John Arbuckle; +Cc: qemu-ppc, david, qemu-devel On Wed, 17 Aug 2016, John Arbuckle wrote: > @@ -446,7 +438,10 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, > return; > } > keycode = qcode_to_adb_keycode[qcode]; > - > + if (keycode == NO_KEY) { /* We don't want to send this to the guest */ > + ADB_DPRINTF("Ignoring NO_KEY\n"); > + return; > + } > if (evt->u.key.data->down == false) { /* if key release event */ > keycode = keycode | 0x80; /* create keyboard break code */ > } I think you should print the qcode value that was ignored instead of that it was mapped to NO_KEY which is not that informative. Regards, BALATON Zoltan ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v5 4/4] adb.c: prevent NO_KEY value from going to guest 2016-08-18 11:06 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan @ 2016-08-20 1:29 ` Programmingkid 2016-08-20 17:18 ` BALATON Zoltan 0 siblings, 1 reply; 13+ messages in thread From: Programmingkid @ 2016-08-20 1:29 UTC (permalink / raw) To: BALATON Zoltan; +Cc: qemu-ppc, david, qemu-devel On Aug 18, 2016, at 7:06 AM, BALATON Zoltan wrote: > On Wed, 17 Aug 2016, John Arbuckle wrote: >> @@ -446,7 +438,10 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, >> return; >> } >> keycode = qcode_to_adb_keycode[qcode]; >> - >> + if (keycode == NO_KEY) { /* We don't want to send this to the guest */ >> + ADB_DPRINTF("Ignoring NO_KEY\n"); >> + return; >> + } >> if (evt->u.key.data->down == false) { /* if key release event */ >> keycode = keycode | 0x80; /* create keyboard break code */ >> } > > I think you should print the qcode value that was ignored instead of that it was mapped to NO_KEY which is not that informative. > > Regards, > BALATON Zoltan Sounds like a good idea. What do you think of this: ADB_DPRINTF("Ignoring key with qcode %d\n", qcode); ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [Qemu-ppc] [PATCH v5 4/4] adb.c: prevent NO_KEY value from going to guest 2016-08-20 1:29 ` Programmingkid @ 2016-08-20 17:18 ` BALATON Zoltan 0 siblings, 0 replies; 13+ messages in thread From: BALATON Zoltan @ 2016-08-20 17:18 UTC (permalink / raw) To: Programmingkid; +Cc: qemu-ppc, qemu-devel, david On Fri, 19 Aug 2016, Programmingkid wrote: > On Aug 18, 2016, at 7:06 AM, BALATON Zoltan wrote: >> On Wed, 17 Aug 2016, John Arbuckle wrote: >>> @@ -446,7 +438,10 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src, >>> return; >>> } >>> keycode = qcode_to_adb_keycode[qcode]; >>> - >>> + if (keycode == NO_KEY) { /* We don't want to send this to the guest */ >>> + ADB_DPRINTF("Ignoring NO_KEY\n"); >>> + return; >>> + } >>> if (evt->u.key.data->down == false) { /* if key release event */ >>> keycode = keycode | 0x80; /* create keyboard break code */ >>> } >> >> I think you should print the qcode value that was ignored instead of that it was mapped to NO_KEY which is not that informative. >> >> Regards, >> BALATON Zoltan > > Sounds like a good idea. > > What do you think of this: > ADB_DPRINTF("Ignoring key with qcode %d\n", qcode); That looks good to me. (Nothing more is needed as this is a debug message so people reading this should be able to find the meaning of qcode value.) Regards, BALATON Zoltan ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v5 0/4] ADB improvements 2016-08-18 2:27 [Qemu-devel] [PATCH v5 0/4] ADB improvements John Arbuckle ` (3 preceding siblings ...) 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 4/4] adb.c: prevent NO_KEY value from going to guest John Arbuckle @ 2016-08-18 2:37 ` no-reply 2016-08-23 12:19 ` David Gibson 4 siblings, 1 reply; 13+ messages in thread From: no-reply @ 2016-08-18 2:37 UTC (permalink / raw) To: programmingkidx; +Cc: famz, qemu-ppc, david, qemu-devel Hi, Your series seems to have some coding style problems. See output below for more information: Message-id: 1471487270-1490-1-git-send-email-programmingkidx@gmail.com Subject: [Qemu-devel] [PATCH v5 0/4] ADB improvements Type: series === TEST SCRIPT BEGIN === #!/bin/bash BASE=base n=1 total=$(git log --oneline $BASE.. | wc -l) failed=0 # Useful git options git config --local diff.renamelimit 0 git config --local diff.renames True commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do echo "Checking PATCH $n/$total: $(git show --no-patch --format=%s $c)..." if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then failed=1 echo fi n=$((n+1)) done exit $failed === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 From https://github.com/patchew-project/qemu * [new tag] patchew/1471487270-1490-1-git-send-email-programmingkidx@gmail.com -> patchew/1471487270-1490-1-git-send-email-programmingkidx@gmail.com Switched to a new branch 'test' 8e862cb adb.c: prevent NO_KEY value from going to guest 649cccc adb.c: correct several key assignments f4950b2 adb.c: add support for QKeyCode db1d3d7 adb-keys.h: initial commit === OUTPUT BEGIN === Checking PATCH 1/4: adb-keys.h: initial commit... ERROR: line over 90 characters #30: FILE: include/hw/input/adb-keys.h:14: + * Additional information: http://www.archive.org/stream/apple-guide-macintosh-family-hardware/Apple_Guide_to_the_Macintosh_Family_Hardware_2e#page/n345/mode/2up total: 1 errors, 0 warnings, 141 lines checked Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. Checking PATCH 2/4: adb.c: add support for QKeyCode... Checking PATCH 3/4: adb.c: correct several key assignments... Checking PATCH 4/4: adb.c: prevent NO_KEY value from going to guest... === OUTPUT END === Test command exited with code: 1 --- Email generated automatically by Patchew [http://patchew.org/]. Please send your feedback to patchew-devel@freelists.org ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v5 0/4] ADB improvements 2016-08-18 2:37 ` [Qemu-devel] [PATCH v5 0/4] ADB improvements no-reply @ 2016-08-23 12:19 ` David Gibson 2016-08-23 19:21 ` Programmingkid 0 siblings, 1 reply; 13+ messages in thread From: David Gibson @ 2016-08-23 12:19 UTC (permalink / raw) To: qemu-devel; +Cc: programmingkidx, famz, qemu-ppc [-- Attachment #1: Type: text/plain, Size: 2693 bytes --] On Wed, Aug 17, 2016 at 07:37:16PM -0700, no-reply@patchew.org wrote: > Hi, > > Your series seems to have some coding style problems. See output below for > more information: > > Message-id: 1471487270-1490-1-git-send-email-programmingkidx@gmail.com > Subject: [Qemu-devel] [PATCH v5 0/4] ADB improvements > Type: series > > === TEST SCRIPT BEGIN === > #!/bin/bash > > BASE=base > n=1 > total=$(git log --oneline $BASE.. | wc -l) > failed=0 > > # Useful git options > git config --local diff.renamelimit 0 > git config --local diff.renames True > > commits="$(git log --format=%H --reverse $BASE..)" > for c in $commits; do > echo "Checking PATCH $n/$total: $(git show --no-patch --format=%s $c)..." > if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then > failed=1 > echo > fi > n=$((n+1)) > done > > exit $failed > === TEST SCRIPT END === > > Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 > From https://github.com/patchew-project/qemu > * [new tag] patchew/1471487270-1490-1-git-send-email-programmingkidx@gmail.com -> patchew/1471487270-1490-1-git-send-email-programmingkidx@gmail.com > Switched to a new branch 'test' > 8e862cb adb.c: prevent NO_KEY value from going to guest > 649cccc adb.c: correct several key assignments > f4950b2 adb.c: add support for QKeyCode > db1d3d7 adb-keys.h: initial commit > > === OUTPUT BEGIN === > Checking PATCH 1/4: adb-keys.h: initial commit... > ERROR: line over 90 characters > #30: FILE: include/hw/input/adb-keys.h:14: > + * Additional information: http://www.archive.org/stream/apple-guide-macintosh-family-hardware/Apple_Guide_to_the_Macintosh_Family_Hardware_2e#page/n345/mode/2up This error can be ignored - the line is only long because of the stupidly long URL, which should not be broken. > total: 1 errors, 0 warnings, 141 lines checked > > Your patch has style problems, please review. If any of these errors > are false positives report them to the maintainer, see > CHECKPATCH in MAINTAINERS. > > Checking PATCH 2/4: adb.c: add support for QKeyCode... > Checking PATCH 3/4: adb.c: correct several key assignments... > Checking PATCH 4/4: adb.c: prevent NO_KEY value from going to guest... > === OUTPUT END === > > Test command exited with code: 1 > > > --- > Email generated automatically by Patchew [http://patchew.org/]. > Please send your feedback to patchew-devel@freelists.org -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v5 0/4] ADB improvements 2016-08-23 12:19 ` David Gibson @ 2016-08-23 19:21 ` Programmingkid 0 siblings, 0 replies; 13+ messages in thread From: Programmingkid @ 2016-08-23 19:21 UTC (permalink / raw) To: David Gibson; +Cc: qemu-devel, famz, qemu-ppc On Aug 23, 2016, at 8:19 AM, David Gibson wrote: > On Wed, Aug 17, 2016 at 07:37:16PM -0700, no-reply@patchew.org wrote: >> Hi, >> >> Your series seems to have some coding style problems. See output below for >> more information: >> >> Message-id: 1471487270-1490-1-git-send-email-programmingkidx@gmail.com >> Subject: [Qemu-devel] [PATCH v5 0/4] ADB improvements >> Type: series >> >> === TEST SCRIPT BEGIN === >> #!/bin/bash >> >> BASE=base >> n=1 >> total=$(git log --oneline $BASE.. | wc -l) >> failed=0 >> >> # Useful git options >> git config --local diff.renamelimit 0 >> git config --local diff.renames True >> >> commits="$(git log --format=%H --reverse $BASE..)" >> for c in $commits; do >> echo "Checking PATCH $n/$total: $(git show --no-patch --format=%s $c)..." >> if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then >> failed=1 >> echo >> fi >> n=$((n+1)) >> done >> >> exit $failed >> === TEST SCRIPT END === >> >> Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 >> From https://github.com/patchew-project/qemu >> * [new tag] patchew/1471487270-1490-1-git-send-email-programmingkidx@gmail.com -> patchew/1471487270-1490-1-git-send-email-programmingkidx@gmail.com >> Switched to a new branch 'test' >> 8e862cb adb.c: prevent NO_KEY value from going to guest >> 649cccc adb.c: correct several key assignments >> f4950b2 adb.c: add support for QKeyCode >> db1d3d7 adb-keys.h: initial commit >> >> === OUTPUT BEGIN === >> Checking PATCH 1/4: adb-keys.h: initial commit... >> ERROR: line over 90 characters >> #30: FILE: include/hw/input/adb-keys.h:14: >> + * Additional information: http://www.archive.org/stream/apple-guide-macintosh-family-hardware/Apple_Guide_to_the_Macintosh_Family_Hardware_2e#page/n345/mode/2up > > This error can be ignored - the line is only long because of the > stupidly long URL, which should not be broken. Ok. I'm glad I didn't listen to that patch checker program. ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2016-09-15 0:26 UTC | newest] Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2016-08-18 2:27 [Qemu-devel] [PATCH v5 0/4] ADB improvements John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 1/4] adb-keys.h: initial commit John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 2/4] adb.c: add support for QKeyCode John Arbuckle 2016-08-18 11:04 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan 2016-09-15 0:00 ` [Qemu-devel] " David Gibson 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 3/4] adb.c: correct several key assignments John Arbuckle 2016-08-18 2:27 ` [Qemu-devel] [PATCH v5 4/4] adb.c: prevent NO_KEY value from going to guest John Arbuckle 2016-08-18 11:06 ` [Qemu-devel] [Qemu-ppc] " BALATON Zoltan 2016-08-20 1:29 ` Programmingkid 2016-08-20 17:18 ` BALATON Zoltan 2016-08-18 2:37 ` [Qemu-devel] [PATCH v5 0/4] ADB improvements no-reply 2016-08-23 12:19 ` David Gibson 2016-08-23 19:21 ` Programmingkid
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.