]> git.proxmox.com Git - mirror_qemu.git/blame - ui/input-keymap.c
Revert "vl: Fix to create migration object before block backends again"
[mirror_qemu.git] / ui / input-keymap.c
CommitLineData
e16f4c87 1#include "qemu/osdep.h"
02aa76c2 2#include "sysemu/sysemu.h"
0041e9a0 3#include "keymaps.h"
02aa76c2
GH
4#include "ui/input.h"
5
606eb0c6
GH
6#include "standard-headers/linux/input.h"
7
2ec78706 8#include "ui/input-keymap-atset1-to-qcode.c"
bcd5ac9b 9#include "ui/input-keymap-linux-to-qcode.c"
ab8f9d49
DB
10#include "ui/input-keymap-qcode-to-atset1.c"
11#include "ui/input-keymap-qcode-to-atset2.c"
12#include "ui/input-keymap-qcode-to-atset3.c"
5a15e6b1 13#include "ui/input-keymap-qcode-to-linux.c"
bcd5ac9b 14#include "ui/input-keymap-qcode-to-qnum.c"
e709a61a 15#include "ui/input-keymap-qcode-to-sun.c"
bcd5ac9b 16#include "ui/input-keymap-qnum-to-qcode.c"
ed7b2624 17#include "ui/input-keymap-usb-to-qcode.c"
2ec78706
DB
18#include "ui/input-keymap-win32-to-qcode.c"
19#include "ui/input-keymap-x11-to-qcode.c"
20#include "ui/input-keymap-xorgevdev-to-qcode.c"
21#include "ui/input-keymap-xorgkbd-to-qcode.c"
22#include "ui/input-keymap-xorgxquartz-to-qcode.c"
23#include "ui/input-keymap-xorgxwin-to-qcode.c"
656282d2 24#include "ui/input-keymap-osx-to-qcode.c"
02aa76c2 25
606eb0c6
GH
26int qemu_input_linux_to_qcode(unsigned int lnx)
27{
bcd5ac9b
DB
28 if (lnx >= qemu_input_map_linux_to_qcode_len) {
29 return 0;
30 }
31 return qemu_input_map_linux_to_qcode[lnx];
606eb0c6
GH
32}
33
02aa76c2
GH
34int qemu_input_key_value_to_number(const KeyValue *value)
35{
568c73a4 36 if (value->type == KEY_VALUE_KIND_QCODE) {
bcd5ac9b
DB
37 if (value->u.qcode.data >= qemu_input_map_qcode_to_qnum_len) {
38 return 0;
39 }
40 return qemu_input_map_qcode_to_qnum[value->u.qcode.data];
02aa76c2 41 } else {
568c73a4 42 assert(value->type == KEY_VALUE_KIND_NUMBER);
32bafa8f 43 return value->u.number.data;
02aa76c2
GH
44 }
45}
46
bcd5ac9b 47int qemu_input_key_number_to_qcode(unsigned int nr)
02aa76c2 48{
bcd5ac9b
DB
49 if (nr >= qemu_input_map_qnum_to_qcode_len) {
50 return 0;
02aa76c2 51 }
bcd5ac9b 52 return qemu_input_map_qnum_to_qcode[nr];
11c7fa7f
GH
53}
54
55int qemu_input_key_value_to_qcode(const KeyValue *value)
56{
568c73a4 57 if (value->type == KEY_VALUE_KIND_QCODE) {
32bafa8f 58 return value->u.qcode.data;
02aa76c2 59 } else {
568c73a4 60 assert(value->type == KEY_VALUE_KIND_NUMBER);
32bafa8f 61 return qemu_input_key_number_to_qcode(value->u.number.data);
02aa76c2
GH
62 }
63}
64
65int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
66 int *codes)
67{
68 int keycode = qemu_input_key_value_to_number(value);
69 int count = 0;
70
568c73a4 71 if (value->type == KEY_VALUE_KIND_QCODE &&
32bafa8f 72 value->u.qcode.data == Q_KEY_CODE_PAUSE) {
02aa76c2
GH
73 /* specific case */
74 int v = down ? 0 : 0x80;
75 codes[count++] = 0xe1;
76 codes[count++] = 0x1d | v;
77 codes[count++] = 0x45 | v;
78 return count;
79 }
80 if (keycode & SCANCODE_GREY) {
81 codes[count++] = SCANCODE_EMUL0;
82 keycode &= ~SCANCODE_GREY;
83 }
84 if (!down) {
85 keycode |= SCANCODE_UP;
86 }
87 codes[count++] = keycode;
88
89 return count;
90}