aboutsummaryrefslogtreecommitdiff
path: root/ui/input-keymap.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2017-07-26 17:29:15 +0200
committerGerd Hoffmann <kraxel@redhat.com>2017-07-27 14:23:09 +0200
commit606eb0c64991d59a9d5e249508867dc0cb3707e1 (patch)
tree1ed0a9920738d8974cc59aaaec6223fe17744098 /ui/input-keymap.c
parentd52a1a9102a4236dfbc7c95b3c7057f107dbf71d (diff)
ui: move qemu_input_linux_to_qcode()
Move from input-linux.c to input-keymap.c and export it, so the function is available elsewhere too. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-id: 20170726152918.11995-3-kraxel@redhat.com
Diffstat (limited to 'ui/input-keymap.c')
-rw-r--r--ui/input-keymap.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/ui/input-keymap.c b/ui/input-keymap.c
index 8a1476fc48..d4972bb364 100644
--- a/ui/input-keymap.c
+++ b/ui/input-keymap.c
@@ -3,6 +3,115 @@
#include "ui/keymaps.h"
#include "ui/input.h"
+#include "standard-headers/linux/input.h"
+
+static int linux_to_qcode[KEY_CNT] = {
+ [KEY_ESC] = Q_KEY_CODE_ESC,
+ [KEY_1] = Q_KEY_CODE_1,
+ [KEY_2] = Q_KEY_CODE_2,
+ [KEY_3] = Q_KEY_CODE_3,
+ [KEY_4] = Q_KEY_CODE_4,
+ [KEY_5] = Q_KEY_CODE_5,
+ [KEY_6] = Q_KEY_CODE_6,
+ [KEY_7] = Q_KEY_CODE_7,
+ [KEY_8] = Q_KEY_CODE_8,
+ [KEY_9] = Q_KEY_CODE_9,
+ [KEY_0] = Q_KEY_CODE_0,
+ [KEY_MINUS] = Q_KEY_CODE_MINUS,
+ [KEY_EQUAL] = Q_KEY_CODE_EQUAL,
+ [KEY_BACKSPACE] = Q_KEY_CODE_BACKSPACE,
+ [KEY_TAB] = Q_KEY_CODE_TAB,
+ [KEY_Q] = Q_KEY_CODE_Q,
+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CODE_F11,
+ [KEY_F12] = Q_KEY_CODE_F12,
+ [KEY_RIGHTCTRL] = Q_KEY_CODE_CTRL_R,
+ [KEY_SYSRQ] = Q_KEY_CODE_SYSRQ,
+ [KEY_RIGHTALT] = Q_KEY_CODE_ALT_R,
+ [KEY_HOME] = Q_KEY_CODE_HOME,
+ [KEY_UP] = Q_KEY_CODE_UP,
+ [KEY_PAGEUP] = Q_KEY_CODE_PGUP,
+ [KEY_LEFT] = Q_KEY_CODE_LEFT,
+ [KEY_RIGHT] = Q_KEY_CODE_RIGHT,
+ [KEY_END] = Q_KEY_CODE_END,
+ [KEY_DOWN] = Q_KEY_CODE_DOWN,
+ [KEY_PAGEDOWN] = Q_KEY_CODE_PGDN,
+ [KEY_INSERT] = Q_KEY_CODE_INSERT,
+ [KEY_DELETE] = Q_KEY_CODE_DELETE,
+ [KEY_LEFTMETA] = Q_KEY_CODE_META_L,
+ [KEY_RIGHTMETA] = Q_KEY_CODE_META_R,
+ [KEY_MENU] = Q_KEY_CODE_MENU,
+};
+
static const int qcode_to_number[] = {
[Q_KEY_CODE_SHIFT] = 0x2a,
[Q_KEY_CODE_SHIFT_R] = 0x36,
@@ -141,6 +250,12 @@ static const int qcode_to_number[] = {
static int number_to_qcode[0x100];
+int qemu_input_linux_to_qcode(unsigned int lnx)
+{
+ assert(lnx < KEY_CNT);
+ return linux_to_qcode[lnx];
+}
+
int qemu_input_key_value_to_number(const KeyValue *value)
{
if (value->type == KEY_VALUE_KIND_QCODE) {