qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 5/7] add the QKeyCode enum and the key_defs t


From: Luiz Capitulino
Subject: Re: [Qemu-devel] [PATCH v6 5/7] add the QKeyCode enum and the key_defs table
Date: Fri, 3 Aug 2012 10:32:33 -0300

On Fri,  3 Aug 2012 10:48:40 +0800
Amos Kong <address@hidden> wrote:

> key_defs[] in monitor.c is a mapping table of keys and keycodes,
> this patch added a QKeyCode enum and a new key_defs table,
> Key's index in the enmu is same as keycode's index in new key_defs[].
> 
> Signed-off-by: Amos Kong <address@hidden>
> ---
>  input.c          |  146 
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  qapi-schema.json |   26 ++++++++++
>  2 files changed, 172 insertions(+), 0 deletions(-)
> 
> diff --git a/input.c b/input.c
> index 6968b31..680d756 100644
> --- a/input.c
> +++ b/input.c
> @@ -37,6 +37,152 @@ static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =
>  static NotifierList mouse_mode_notifiers = 
>      NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
>  
> +static const int key_defs[] = {

Weird, I expected this would brake the build, as the new table is unused.

Anyway, what I suggested in my last review was to do the table move in a
different patch, which includes adding the new accessors, dropping key_defs
from the monitor and doing the necessary changes in the monitor functions
which access key_defs directly.

This way, the patch converting sendkey() to the qapi does just the
conversion itself (vs. conversion plus refactorings).

> +    [Q_KEY_CODE_SHIFT] = 0x2a,
> +    [Q_KEY_CODE_SHIFT_R] = 0x36,
> +
> +    [Q_KEY_CODE_ALT] = 0x38,
> +    [Q_KEY_CODE_ALT_R] = 0xb8,
> +    [Q_KEY_CODE_ALTGR] = 0x64,
> +    [Q_KEY_CODE_ALTGR_R] = 0xe4,
> +    [Q_KEY_CODE_CTRL] = 0x1d,
> +    [Q_KEY_CODE_CTRL_R] = 0x9d,
> +
> +    [Q_KEY_CODE_MENU] = 0xdd,
> +
> +    [Q_KEY_CODE_ESC] = 0x01,
> +
> +    [Q_KEY_CODE_1] = 0x02,
> +    [Q_KEY_CODE_2] = 0x03,
> +    [Q_KEY_CODE_3] = 0x04,
> +    [Q_KEY_CODE_4] = 0x05,
> +    [Q_KEY_CODE_5] = 0x06,
> +    [Q_KEY_CODE_6] = 0x07,
> +    [Q_KEY_CODE_7] = 0x08,
> +    [Q_KEY_CODE_8] = 0x09,
> +    [Q_KEY_CODE_9] = 0x0a,
> +    [Q_KEY_CODE_0] = 0x0b,
> +    [Q_KEY_CODE_MINUS] = 0x0c,
> +    [Q_KEY_CODE_EQUAL] = 0x0d,
> +    [Q_KEY_CODE_BACKSPACE] = 0x0e,
> +
> +    [Q_KEY_CODE_TAB] = 0x0f,
> +    [Q_KEY_CODE_Q] = 0x10,
> +    [Q_KEY_CODE_W] = 0x11,
> +    [Q_KEY_CODE_E] = 0x12,
> +    [Q_KEY_CODE_R] = 0x13,
> +    [Q_KEY_CODE_T] = 0x14,
> +    [Q_KEY_CODE_Y] = 0x15,
> +    [Q_KEY_CODE_U] = 0x16,
> +    [Q_KEY_CODE_I] = 0x17,
> +    [Q_KEY_CODE_O] = 0x18,
> +    [Q_KEY_CODE_P] = 0x19,
> +    [Q_KEY_CODE_BRACKET_LEFT] = 0x1a,
> +    [Q_KEY_CODE_BRACKET_RIGHT] = 0x1b,
> +    [Q_KEY_CODE_RET] = 0x1c,
> +
> +    [Q_KEY_CODE_A] = 0x1e,
> +    [Q_KEY_CODE_S] = 0x1f,
> +    [Q_KEY_CODE_D] = 0x20,
> +    [Q_KEY_CODE_F] = 0x21,
> +    [Q_KEY_CODE_G] = 0x22,
> +    [Q_KEY_CODE_H] = 0x23,
> +    [Q_KEY_CODE_J] = 0x24,
> +    [Q_KEY_CODE_K] = 0x25,
> +    [Q_KEY_CODE_L] = 0x26,
> +    [Q_KEY_CODE_SEMICOLON] = 0x27,
> +    [Q_KEY_CODE_APOSTROPHE] = 0x28,
> +    [Q_KEY_CODE_GRAVE_ACCENT] = 0x29,
> +
> +    [Q_KEY_CODE_BACKSLASH] = 0x2b,
> +    [Q_KEY_CODE_Z] = 0x2c,
> +    [Q_KEY_CODE_X] = 0x2d,
> +    [Q_KEY_CODE_C] = 0x2e,
> +    [Q_KEY_CODE_V] = 0x2f,
> +    [Q_KEY_CODE_B] = 0x30,
> +    [Q_KEY_CODE_N] = 0x31,
> +    [Q_KEY_CODE_M] = 0x32,
> +    [Q_KEY_CODE_COMMA] = 0x33,
> +    [Q_KEY_CODE_DOT] = 0x34,
> +    [Q_KEY_CODE_SLASH] = 0x35,
> +
> +    [Q_KEY_CODE_ASTERISK] = 0x37,
> +
> +    [Q_KEY_CODE_SPC] = 0x39,
> +    [Q_KEY_CODE_CAPS_LOCK] = 0x3a,
> +    [Q_KEY_CODE_F1] = 0x3b,
> +    [Q_KEY_CODE_F2] = 0x3c,
> +    [Q_KEY_CODE_F3] = 0x3d,
> +    [Q_KEY_CODE_F4] = 0x3e,
> +    [Q_KEY_CODE_F5] = 0x3f,
> +    [Q_KEY_CODE_F6] = 0x40,
> +    [Q_KEY_CODE_F7] = 0x41,
> +    [Q_KEY_CODE_F8] = 0x42,
> +    [Q_KEY_CODE_F9] = 0x43,
> +    [Q_KEY_CODE_F10] = 0x44,
> +    [Q_KEY_CODE_NUM_LOCK] = 0x45,
> +    [Q_KEY_CODE_SCROLL_LOCK] = 0x46,
> +
> +    [Q_KEY_CODE_KP_DIVIDE] = 0xb5,
> +    [Q_KEY_CODE_KP_MULTIPLY] = 0x37,
> +    [Q_KEY_CODE_KP_SUBTRACT] = 0x4a,
> +    [Q_KEY_CODE_KP_ADD] = 0x4e,
> +    [Q_KEY_CODE_KP_ENTER] = 0x9c,
> +    [Q_KEY_CODE_KP_DECIMAL] = 0x53,
> +    [Q_KEY_CODE_SYSRQ] = 0x54,
> +
> +    [Q_KEY_CODE_KP_0] = 0x52,
> +    [Q_KEY_CODE_KP_1] = 0x4f,
> +    [Q_KEY_CODE_KP_2] = 0x50,
> +    [Q_KEY_CODE_KP_3] = 0x51,
> +    [Q_KEY_CODE_KP_4] = 0x4b,
> +    [Q_KEY_CODE_KP_5] = 0x4c,
> +    [Q_KEY_CODE_KP_6] = 0x4d,
> +    [Q_KEY_CODE_KP_7] = 0x47,
> +    [Q_KEY_CODE_KP_8] = 0x48,
> +    [Q_KEY_CODE_KP_9] = 0x49,
> +
> +    [Q_KEY_CODE_LESS] = 0x56,
> +
> +    [Q_KEY_CODE_F11] = 0x57,
> +    [Q_KEY_CODE_F12] = 0x58,
> +
> +    [Q_KEY_CODE_PRINT] = 0xb7,
> +
> +    [Q_KEY_CODE_HOME] = 0xc7,
> +    [Q_KEY_CODE_PGUP] = 0xc9,
> +    [Q_KEY_CODE_PGDN] = 0xd1,
> +    [Q_KEY_CODE_END] = 0xcf,
> +
> +    [Q_KEY_CODE_LEFT] = 0xcb,
> +    [Q_KEY_CODE_UP] = 0xc8,
> +    [Q_KEY_CODE_DOWN] = 0xd0,
> +    [Q_KEY_CODE_RIGHT] = 0xcd,
> +
> +    [Q_KEY_CODE_INSERT] = 0xd2,
> +    [Q_KEY_CODE_DELETE] = 0xd3,
> +#ifdef NEED_CPU_H
> +#if defined(TARGET_SPARC) && !defined(TARGET_SPARC64)
> +    [Q_KEY_CODE_STOP] = 0xf0,
> +    [Q_KEY_CODE_AGAIN] = 0xf1,
> +    [Q_KEY_CODE_PROPS] = 0xf2,
> +    [Q_KEY_CODE_UNDO] = 0xf3,
> +    [Q_KEY_CODE_FRONT] = 0xf4,
> +    [Q_KEY_CODE_COPY] = 0xf5,
> +    [Q_KEY_CODE_OPEN] = 0xf6,
> +    [Q_KEY_CODE_PASTE] = 0xf7,
> +    [Q_KEY_CODE_FIND] = 0xf8,
> +    [Q_KEY_CODE_CUT] = 0xf9,
> +    [Q_KEY_CODE_LF] = 0xfa,
> +    [Q_KEY_CODE_HELP] = 0xfb,
> +    [Q_KEY_CODE_META_L] = 0xfc,
> +    [Q_KEY_CODE_META_R] = 0xfd,
> +    [Q_KEY_CODE_COMPOSE] = 0xfe,
> +#endif
> +#endif
> +    [Q_KEY_CODE_MAX] = 0,
> +};
> +
>  void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
>  {
>      qemu_put_kbd_event_opaque = opaque;
> diff --git a/qapi-schema.json b/qapi-schema.json
> index bc55ed2..0b5abb9 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -2183,3 +2183,29 @@
>  # Since: 0.14.0
>  ##
>  { 'command': 'closefd', 'data': {'fdname': 'str'} }
> +
> +##
> +# @QKeyCode:
> +#
> +# An enumeration of key name.
> +#
> +# This is used by the send-key command.
> +#
> +# Since: 1.2
> +##
> +{ 'enum': 'QKeyCode',
> +  'data': [ 'shift', 'shift_r', 'alt', 'alt_r', 'altgr', 'altgr_r', 'ctrl',
> +            'ctrl_r', 'menu', 'esc', '1', '2', '3', '4', '5', '6', '7', '8',
> +            '9', '0', 'minus', 'equal', 'backspace', 'tab', 'q', 'w', 'e',
> +            'r', 't', 'y', 'u', 'i', 'o', 'p', 'bracket_left', 
> 'bracket_right',
> +            'ret', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'semicolon',
> +            'apostrophe', 'grave_accent', 'backslash', 'z', 'x', 'c', 'v', 
> 'b',
> +            'n', 'm', 'comma', 'dot', 'slash', 'asterisk', 'spc', 
> 'caps_lock',
> +            'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10',
> +            'num_lock', 'scroll_lock', 'kp_divide', 'kp_multiply',
> +            'kp_subtract', 'kp_add', 'kp_enter', 'kp_decimal', 'sysrq', 
> 'kp_0',
> +            'kp_1', 'kp_2', 'kp_3', 'kp_4', 'kp_5', 'kp_6', 'kp_7', 'kp_8',
> +            'kp_9', 'less', 'f11', 'f12', 'print', 'home', 'pgup', 'pgdn', 
> 'end',
> +            'left', 'up', 'down', 'right', 'insert', 'delete', 'stop', 
> 'again',
> +            'props', 'undo', 'front', 'copy', 'open', 'paste', 'find', 'cut',
> +             'lf', 'help', 'meta_l', 'meta_r', 'compose' ] }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]