hmp: Add name parameter to nbd_server_add
[qemu/ericb.git] / ui / input-keymap.c
blob95b1e0cbfa6386b6bfffd9c133281ee4e643b57a
1 #include "qemu/osdep.h"
2 #include "sysemu/sysemu.h"
3 #include "ui/keymaps.h"
4 #include "ui/input.h"
6 #include "standard-headers/linux/input.h"
8 #include "ui/input-keymap-atset1-to-qcode.c"
9 #include "ui/input-keymap-linux-to-qcode.c"
10 #include "ui/input-keymap-qcode-to-qnum.c"
11 #include "ui/input-keymap-qnum-to-qcode.c"
12 #include "ui/input-keymap-qcode-to-linux.c"
13 #include "ui/input-keymap-usb-to-qcode.c"
14 #include "ui/input-keymap-win32-to-qcode.c"
15 #include "ui/input-keymap-x11-to-qcode.c"
16 #include "ui/input-keymap-xorgevdev-to-qcode.c"
17 #include "ui/input-keymap-xorgkbd-to-qcode.c"
18 #include "ui/input-keymap-xorgxquartz-to-qcode.c"
19 #include "ui/input-keymap-xorgxwin-to-qcode.c"
21 int qemu_input_linux_to_qcode(unsigned int lnx)
23 if (lnx >= qemu_input_map_linux_to_qcode_len) {
24 return 0;
26 return qemu_input_map_linux_to_qcode[lnx];
29 int qemu_input_key_value_to_number(const KeyValue *value)
31 if (value->type == KEY_VALUE_KIND_QCODE) {
32 if (value->u.qcode.data >= qemu_input_map_qcode_to_qnum_len) {
33 return 0;
35 return qemu_input_map_qcode_to_qnum[value->u.qcode.data];
36 } else {
37 assert(value->type == KEY_VALUE_KIND_NUMBER);
38 return value->u.number.data;
42 int qemu_input_key_number_to_qcode(unsigned int nr)
44 if (nr >= qemu_input_map_qnum_to_qcode_len) {
45 return 0;
47 return qemu_input_map_qnum_to_qcode[nr];
50 int qemu_input_key_value_to_qcode(const KeyValue *value)
52 if (value->type == KEY_VALUE_KIND_QCODE) {
53 return value->u.qcode.data;
54 } else {
55 assert(value->type == KEY_VALUE_KIND_NUMBER);
56 return qemu_input_key_number_to_qcode(value->u.number.data);
60 int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
61 int *codes)
63 int keycode = qemu_input_key_value_to_number(value);
64 int count = 0;
66 if (value->type == KEY_VALUE_KIND_QCODE &&
67 value->u.qcode.data == Q_KEY_CODE_PAUSE) {
68 /* specific case */
69 int v = down ? 0 : 0x80;
70 codes[count++] = 0xe1;
71 codes[count++] = 0x1d | v;
72 codes[count++] = 0x45 | v;
73 return count;
75 if (keycode & SCANCODE_GREY) {
76 codes[count++] = SCANCODE_EMUL0;
77 keycode &= ~SCANCODE_GREY;
79 if (!down) {
80 keycode |= SCANCODE_UP;
82 codes[count++] = keycode;
84 return count;