All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: [Qemu-devel] [PATCH 09/15] char: convert the escc device to keycodemapdb
Date: Thu, 10 Aug 2017 16:55:16 +0100	[thread overview]
Message-ID: <20170810155522.31099-10-berrange@redhat.com> (raw)
In-Reply-To: <20170810155522.31099-1-berrange@redhat.com>

Replace the qcode_to_keycode table with automatically
generated tables.

Missing entries in qcode_to_keycode now fixed:

 - Q_KEY_CODE_KP_COMMA -> 0x2d

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 hw/char/escc.c     | 126 +++--------------------------------------------------
 include/ui/input.h |   3 ++
 ui/Makefile.objs   |   1 +
 ui/input-keymap.c  |   1 +
 4 files changed, 10 insertions(+), 121 deletions(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 5af7f0cddf..3cacdb5102 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -717,126 +717,6 @@ MemoryRegion *escc_init(hwaddr base, qemu_irq irqA, qemu_irq irqB,
     return &d->mmio;
 }
 
-static const uint8_t qcode_to_keycode[Q_KEY_CODE__MAX] = {
-    [Q_KEY_CODE_SHIFT]         = 99,
-    [Q_KEY_CODE_SHIFT_R]       = 110,
-    [Q_KEY_CODE_ALT]           = 19,
-    [Q_KEY_CODE_ALT_R]         = 13,
-    [Q_KEY_CODE_CTRL]          = 76,
-    [Q_KEY_CODE_CTRL_R]        = 76,
-    [Q_KEY_CODE_ESC]           = 29,
-    [Q_KEY_CODE_1]             = 30,
-    [Q_KEY_CODE_2]             = 31,
-    [Q_KEY_CODE_3]             = 32,
-    [Q_KEY_CODE_4]             = 33,
-    [Q_KEY_CODE_5]             = 34,
-    [Q_KEY_CODE_6]             = 35,
-    [Q_KEY_CODE_7]             = 36,
-    [Q_KEY_CODE_8]             = 37,
-    [Q_KEY_CODE_9]             = 38,
-    [Q_KEY_CODE_0]             = 39,
-    [Q_KEY_CODE_MINUS]         = 40,
-    [Q_KEY_CODE_EQUAL]         = 41,
-    [Q_KEY_CODE_BACKSPACE]     = 43,
-    [Q_KEY_CODE_TAB]           = 53,
-    [Q_KEY_CODE_Q]             = 54,
-    [Q_KEY_CODE_W]             = 55,
-    [Q_KEY_CODE_E]             = 56,
-    [Q_KEY_CODE_R]             = 57,
-    [Q_KEY_CODE_T]             = 58,
-    [Q_KEY_CODE_Y]             = 59,
-    [Q_KEY_CODE_U]             = 60,
-    [Q_KEY_CODE_I]             = 61,
-    [Q_KEY_CODE_O]             = 62,
-    [Q_KEY_CODE_P]             = 63,
-    [Q_KEY_CODE_BRACKET_LEFT]  = 64,
-    [Q_KEY_CODE_BRACKET_RIGHT] = 65,
-    [Q_KEY_CODE_RET]           = 89,
-    [Q_KEY_CODE_A]             = 77,
-    [Q_KEY_CODE_S]             = 78,
-    [Q_KEY_CODE_D]             = 79,
-    [Q_KEY_CODE_F]             = 80,
-    [Q_KEY_CODE_G]             = 81,
-    [Q_KEY_CODE_H]             = 82,
-    [Q_KEY_CODE_J]             = 83,
-    [Q_KEY_CODE_K]             = 84,
-    [Q_KEY_CODE_L]             = 85,
-    [Q_KEY_CODE_SEMICOLON]     = 86,
-    [Q_KEY_CODE_APOSTROPHE]    = 87,
-    [Q_KEY_CODE_GRAVE_ACCENT]  = 42,
-    [Q_KEY_CODE_BACKSLASH]     = 88,
-    [Q_KEY_CODE_Z]             = 100,
-    [Q_KEY_CODE_X]             = 101,
-    [Q_KEY_CODE_C]             = 102,
-    [Q_KEY_CODE_V]             = 103,
-    [Q_KEY_CODE_B]             = 104,
-    [Q_KEY_CODE_N]             = 105,
-    [Q_KEY_CODE_M]             = 106,
-    [Q_KEY_CODE_COMMA]         = 107,
-    [Q_KEY_CODE_DOT]           = 108,
-    [Q_KEY_CODE_SLASH]         = 109,
-    [Q_KEY_CODE_ASTERISK]      = 47,
-    [Q_KEY_CODE_SPC]           = 121,
-    [Q_KEY_CODE_CAPS_LOCK]     = 119,
-    [Q_KEY_CODE_F1]            = 5,
-    [Q_KEY_CODE_F2]            = 6,
-    [Q_KEY_CODE_F3]            = 8,
-    [Q_KEY_CODE_F4]            = 10,
-    [Q_KEY_CODE_F5]            = 12,
-    [Q_KEY_CODE_F6]            = 14,
-    [Q_KEY_CODE_F7]            = 16,
-    [Q_KEY_CODE_F8]            = 17,
-    [Q_KEY_CODE_F9]            = 18,
-    [Q_KEY_CODE_F10]           = 7,
-    [Q_KEY_CODE_NUM_LOCK]      = 98,
-    [Q_KEY_CODE_SCROLL_LOCK]   = 23,
-    [Q_KEY_CODE_KP_DIVIDE]     = 46,
-    [Q_KEY_CODE_KP_MULTIPLY]   = 47,
-    [Q_KEY_CODE_KP_SUBTRACT]   = 71,
-    [Q_KEY_CODE_KP_ADD]        = 125,
-    [Q_KEY_CODE_KP_ENTER]      = 90,
-    [Q_KEY_CODE_KP_DECIMAL]    = 50,
-    [Q_KEY_CODE_KP_0]          = 94,
-    [Q_KEY_CODE_KP_1]          = 112,
-    [Q_KEY_CODE_KP_2]          = 113,
-    [Q_KEY_CODE_KP_3]          = 114,
-    [Q_KEY_CODE_KP_4]          = 91,
-    [Q_KEY_CODE_KP_5]          = 92,
-    [Q_KEY_CODE_KP_6]          = 93,
-    [Q_KEY_CODE_KP_7]          = 68,
-    [Q_KEY_CODE_KP_8]          = 69,
-    [Q_KEY_CODE_KP_9]          = 70,
-    [Q_KEY_CODE_LESS]          = 124,
-    [Q_KEY_CODE_F11]           = 9,
-    [Q_KEY_CODE_F12]           = 11,
-    [Q_KEY_CODE_HOME]          = 52,
-    [Q_KEY_CODE_PGUP]          = 96,
-    [Q_KEY_CODE_PGDN]          = 123,
-    [Q_KEY_CODE_END]           = 74,
-    [Q_KEY_CODE_LEFT]          = 24,
-    [Q_KEY_CODE_UP]            = 20,
-    [Q_KEY_CODE_DOWN]          = 27,
-    [Q_KEY_CODE_RIGHT]         = 28,
-    [Q_KEY_CODE_INSERT]        = 44,
-    [Q_KEY_CODE_DELETE]        = 66,
-    [Q_KEY_CODE_STOP]          = 1,
-    [Q_KEY_CODE_AGAIN]         = 3,
-    [Q_KEY_CODE_PROPS]         = 25,
-    [Q_KEY_CODE_UNDO]          = 26,
-    [Q_KEY_CODE_FRONT]         = 49,
-    [Q_KEY_CODE_COPY]          = 51,
-    [Q_KEY_CODE_OPEN]          = 72,
-    [Q_KEY_CODE_PASTE]         = 73,
-    [Q_KEY_CODE_FIND]          = 95,
-    [Q_KEY_CODE_CUT]           = 97,
-    [Q_KEY_CODE_LF]            = 111,
-    [Q_KEY_CODE_HELP]          = 118,
-    [Q_KEY_CODE_META_L]        = 120,
-    [Q_KEY_CODE_META_R]        = 122,
-    [Q_KEY_CODE_COMPOSE]       = 67,
-    [Q_KEY_CODE_PRINT]         = 22,
-    [Q_KEY_CODE_SYSRQ]         = 21,
-};
 
 static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
                                 InputEvent *evt)
@@ -879,7 +759,11 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
         }
     }
 
-    keycode = qcode_to_keycode[qcode];
+    if (qcode > qemu_input_map_qcode2sun_len) {
+        return;
+    }
+
+    keycode = qemu_input_map_qcode2sun[qcode];
     if (!key->down) {
         keycode |= 0x80;
     }
diff --git a/include/ui/input.h b/include/ui/input.h
index 0400f88c5d..69ffff522b 100644
--- a/include/ui/input.h
+++ b/include/ui/input.h
@@ -86,6 +86,9 @@ extern const guint16 qemu_input_map_qcode2linux[];
 extern const guint qemu_input_map_qcode2qnum_len;
 extern const guint16 qemu_input_map_qcode2qnum[];
 
+extern const guint qemu_input_map_qcode2sun_len;
+extern const guint16 qemu_input_map_qcode2sun[];
+
 extern const guint qemu_input_map_qnum2qcode_len;
 extern const guint16 qemu_input_map_qnum2qcode[];
 
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index 7123f593ab..935a54c109 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -61,6 +61,7 @@ KEYCODEMAP_FILES = \
 		 ui/input-keymap-qcode2atset3.c \
 		 ui/input-keymap-qcode2linux.c \
 		 ui/input-keymap-qcode2qnum.c \
+		 ui/input-keymap-qcode2sun.c \
 		 ui/input-keymap-qnum2qcode.c \
 		 $(NULL)
 
diff --git a/ui/input-keymap.c b/ui/input-keymap.c
index afe6def002..05a097b97f 100644
--- a/ui/input-keymap.c
+++ b/ui/input-keymap.c
@@ -12,6 +12,7 @@
 #include "ui/input-keymap-qcode2atset3.c"
 #include "ui/input-keymap-qcode2linux.c"
 #include "ui/input-keymap-qcode2qnum.c"
+#include "ui/input-keymap-qcode2sun.c"
 #include "ui/input-keymap-qnum2qcode.c"
 
 int qemu_input_linux_to_qcode(unsigned int lnx)
-- 
2.13.3

  parent reply	other threads:[~2017-08-10 15:56 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-10 15:55 [Qemu-devel] [PATCH 00/15] Convert over to use keycodemapdb Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 01/15] ui: add keycodemapdb repository as a GIT submodule Daniel P. Berrange
2017-08-10 18:23   ` Eric Blake
2017-08-11  9:07     ` Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 02/15] ui: convert common input code to keycodemapdb Daniel P. Berrange
2017-08-10 18:59   ` Eric Blake
2017-08-11  9:12     ` Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 03/15] ui: convert key events to QKeyCodes immediately Daniel P. Berrange
2017-08-10 19:11   ` Eric Blake
2017-08-10 15:55 ` [Qemu-devel] [PATCH 04/15] ui: don't export qemu_input_event_new_key Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 05/15] ui: use QKeyCode exclusively in InputKeyEvent Daniel P. Berrange
2017-08-10 19:02   ` Eric Blake
2017-08-11  9:13     ` Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 06/15] input: convert virtio-input-hid device to keycodemapdb Daniel P. Berrange
2017-08-21 13:49   ` Gerd Hoffmann
2017-08-30 16:01     ` Daniel P. Berrange
2017-09-01  7:10       ` Gerd Hoffmann
2017-08-10 15:55 ` [Qemu-devel] [PATCH 07/15] input: convert ps2 " Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 08/15] input: convert the adb " Daniel P. Berrange
2017-08-10 15:55 ` Daniel P. Berrange [this message]
2017-08-10 15:55 ` [Qemu-devel] [PATCH 10/15] ui: convert cocoa frontend " Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 11/15] ui: convert the SDL2 " Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 12/15] ui: convert GTK and SDL1 frontends " Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 13/15] ui: remove qemu_input_qcode_to_number method Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 14/15] ui: remove qemu_input_linux_to_qcode method Daniel P. Berrange
2017-08-10 15:55 ` [Qemu-devel] [PATCH 15/15] display: convert XenInput keyboard to keycodemapdb Daniel P. Berrange
2017-08-10 16:10 ` [Qemu-devel] [PATCH 00/15] Convert over to use keycodemapdb no-reply
2017-08-10 16:59   ` Daniel P. Berrange
2017-08-10 16:11 ` no-reply
2017-08-10 16:11 ` no-reply
2017-08-10 16:12 ` no-reply
2017-08-21 13:53 ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170810155522.31099-10-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.