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