qemu/ui/input-keymap.c
Daniel P. Berrange ab8f9d49d6 hw: convert ps2 device to keycodemapdb
Replace the qcode_to_keycode_set1, qcode_to_keycode_set2,
and qcode_to_keycode_set3 tables with automatically
generated tables.

Missing entries in qcode_to_keycode_set1 now fixed:

 - Q_KEY_CODE_SYSRQ -> 0x54
 - Q_KEY_CODE_PRINT -> 0x54 (NB ignored due to special case)
 - Q_KEY_CODE_AGAIN -> 0xe005
 - Q_KEY_CODE_PROPS -> 0xe006
 - Q_KEY_CODE_UNDO -> 0xe007
 - Q_KEY_CODE_FRONT -> 0xe00c
 - Q_KEY_CODE_COPY -> 0xe078
 - Q_KEY_CODE_OPEN -> 0x64
 - Q_KEY_CODE_PASTE -> 0x65
 - Q_KEY_CODE_CUT -> 0xe03c
 - Q_KEY_CODE_LF -> 0x5b
 - Q_KEY_CODE_HELP -> 0xe075
 - Q_KEY_CODE_COMPOSE -> 0xe05d
 - Q_KEY_CODE_PAUSE -> 0xe046
 - Q_KEY_CODE_KP_EQUALS -> 0x59

And some mistakes corrected:

 - Q_KEY_CODE_HIRAGANA was mapped to 0x70 (Katakanahiragana)
   instead of of 0x77 (Hirigana)
 - Q_KEY_CODE_MENU was incorrectly mapped to the compose
   scancode (0xe05d) and is now mapped to 0xe01e
 - Q_KEY_CODE_FIND was mapped to 0xe065 (Search) instead
   of to 0xe041 (Find)
 - Q_KEY_CODE_POWER, SLEEP & WAKE had 0x0e instead of 0xe0
   as the prefix

Missing entries in qcode_to_keycode_set2 now fixed:

 - Q_KEY_CODE_PRINT -> 0x7f (NB ignored due to special case)
 - Q_KEY_CODE_COMPOSE -> 0xe02f
 - Q_KEY_CODE_PAUSE -> 0xe077
 - Q_KEY_CODE_KP_EQUALS -> 0x0f

And some mistakes corrected:

 - Q_KEY_CODE_HIRAGANA was mapped to 0x13 (Katakanahiragana)
   instead of of 0x62 (Hirigana)
 - Q_KEY_CODE_MENU was incorrectly mapped to the compose
   scancode (0xe02f) and is now not mapped
 - Q_KEY_CODE_FIND was mapped to 0xe010 (Search) and is now
   not mapped.
 - Q_KEY_CODE_POWER, SLEEP & WAKE had 0x0e instead of 0xe0
   as the prefix

Missing entries in qcode_to_keycode_set3 now fixed:

 - Q_KEY_CODE_ASTERISK -> 0x7e
 - Q_KEY_CODE_SYSRQ -> 0x57
 - Q_KEY_CODE_LESS -> 0x13
 - Q_KEY_CODE_STOP -> 0x0a
 - Q_KEY_CODE_AGAIN -> 0x0b
 - Q_KEY_CODE_PROPS -> 0x0c
 - Q_KEY_CODE_UNDO -> 0x10
 - Q_KEY_CODE_COPY -> 0x18
 - Q_KEY_CODE_OPEN -> 0x20
 - Q_KEY_CODE_PASTE -> 0x28
 - Q_KEY_CODE_FIND -> 0x30
 - Q_KEY_CODE_CUT -> 0x38
 - Q_KEY_CODE_HELP -> 0x09
 - Q_KEY_CODE_COMPOSE -> 0x8d
 - Q_KEY_CODE_AUDIONEXT -> 0x93
 - Q_KEY_CODE_AUDIOPREV -> 0x94
 - Q_KEY_CODE_AUDIOSTOP -> 0x98
 - Q_KEY_CODE_AUDIOMUTE -> 0x9c
 - Q_KEY_CODE_VOLUMEUP -> 0x95
 - Q_KEY_CODE_VOLUMEDOWN -> 0x9d
 - Q_KEY_CODE_CALCULATOR -> 0xa3
 - Q_KEY_CODE_AC_HOME -> 0x97

And some mistakes corrected:

 - Q_KEY_CODE_MENU was incorrectly mapped to the compose
   scancode (0x8d) and is now 0x91

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 20180117164118.8510-2-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-01-29 09:30:25 +01:00

89 lines
2.5 KiB
C

#include "qemu/osdep.h"
#include "sysemu/sysemu.h"
#include "ui/keymaps.h"
#include "ui/input.h"
#include "standard-headers/linux/input.h"
#include "ui/input-keymap-atset1-to-qcode.c"
#include "ui/input-keymap-linux-to-qcode.c"
#include "ui/input-keymap-qcode-to-atset1.c"
#include "ui/input-keymap-qcode-to-atset2.c"
#include "ui/input-keymap-qcode-to-atset3.c"
#include "ui/input-keymap-qcode-to-qnum.c"
#include "ui/input-keymap-qnum-to-qcode.c"
#include "ui/input-keymap-qcode-to-linux.c"
#include "ui/input-keymap-usb-to-qcode.c"
#include "ui/input-keymap-win32-to-qcode.c"
#include "ui/input-keymap-x11-to-qcode.c"
#include "ui/input-keymap-xorgevdev-to-qcode.c"
#include "ui/input-keymap-xorgkbd-to-qcode.c"
#include "ui/input-keymap-xorgxquartz-to-qcode.c"
#include "ui/input-keymap-xorgxwin-to-qcode.c"
int qemu_input_linux_to_qcode(unsigned int lnx)
{
if (lnx >= qemu_input_map_linux_to_qcode_len) {
return 0;
}
return qemu_input_map_linux_to_qcode[lnx];
}
int qemu_input_key_value_to_number(const KeyValue *value)
{
if (value->type == KEY_VALUE_KIND_QCODE) {
if (value->u.qcode.data >= qemu_input_map_qcode_to_qnum_len) {
return 0;
}
return qemu_input_map_qcode_to_qnum[value->u.qcode.data];
} else {
assert(value->type == KEY_VALUE_KIND_NUMBER);
return value->u.number.data;
}
}
int qemu_input_key_number_to_qcode(unsigned int nr)
{
if (nr >= qemu_input_map_qnum_to_qcode_len) {
return 0;
}
return qemu_input_map_qnum_to_qcode[nr];
}
int qemu_input_key_value_to_qcode(const KeyValue *value)
{
if (value->type == KEY_VALUE_KIND_QCODE) {
return value->u.qcode.data;
} else {
assert(value->type == KEY_VALUE_KIND_NUMBER);
return qemu_input_key_number_to_qcode(value->u.number.data);
}
}
int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
int *codes)
{
int keycode = qemu_input_key_value_to_number(value);
int count = 0;
if (value->type == KEY_VALUE_KIND_QCODE &&
value->u.qcode.data == Q_KEY_CODE_PAUSE) {
/* specific case */
int v = down ? 0 : 0x80;
codes[count++] = 0xe1;
codes[count++] = 0x1d | v;
codes[count++] = 0x45 | v;
return count;
}
if (keycode & SCANCODE_GREY) {
codes[count++] = SCANCODE_EMUL0;
keycode &= ~SCANCODE_GREY;
}
if (!down) {
keycode |= SCANCODE_UP;
}
codes[count++] = keycode;
return count;
}