ui: introduce enum to track VNC client framebuffer update request state
[qemu/ar7.git] / ui / input-keymap.c
blob663986a17baeb1c683d676096d51bb03ffc82183
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-linux-to-qcode.c"
9 #include "ui/input-keymap-qcode-to-qnum.c"
10 #include "ui/input-keymap-qnum-to-qcode.c"
11 #include "ui/input-keymap-qcode-to-linux.c"
13 int qemu_input_linux_to_qcode(unsigned int lnx)
15 if (lnx >= qemu_input_map_linux_to_qcode_len) {
16 return 0;
18 return qemu_input_map_linux_to_qcode[lnx];
21 int qemu_input_key_value_to_number(const KeyValue *value)
23 if (value->type == KEY_VALUE_KIND_QCODE) {
24 if (value->u.qcode.data >= qemu_input_map_qcode_to_qnum_len) {
25 return 0;
27 return qemu_input_map_qcode_to_qnum[value->u.qcode.data];
28 } else {
29 assert(value->type == KEY_VALUE_KIND_NUMBER);
30 return value->u.number.data;
34 int qemu_input_key_number_to_qcode(unsigned int nr)
36 if (nr >= qemu_input_map_qnum_to_qcode_len) {
37 return 0;
39 return qemu_input_map_qnum_to_qcode[nr];
42 int qemu_input_key_value_to_qcode(const KeyValue *value)
44 if (value->type == KEY_VALUE_KIND_QCODE) {
45 return value->u.qcode.data;
46 } else {
47 assert(value->type == KEY_VALUE_KIND_NUMBER);
48 return qemu_input_key_number_to_qcode(value->u.number.data);
52 int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
53 int *codes)
55 int keycode = qemu_input_key_value_to_number(value);
56 int count = 0;
58 if (value->type == KEY_VALUE_KIND_QCODE &&
59 value->u.qcode.data == Q_KEY_CODE_PAUSE) {
60 /* specific case */
61 int v = down ? 0 : 0x80;
62 codes[count++] = 0xe1;
63 codes[count++] = 0x1d | v;
64 codes[count++] = 0x45 | v;
65 return count;
67 if (keycode & SCANCODE_GREY) {
68 codes[count++] = SCANCODE_EMUL0;
69 keycode &= ~SCANCODE_GREY;
71 if (!down) {
72 keycode |= SCANCODE_UP;
74 codes[count++] = keycode;
76 return count;