@samitouri / QOSamiQemu / commits / 945c10d541

ui/input-legacy: Use Linux key codes

QemuInputEvent now stores Linux key codes for key events. Use those codes directly instead of translating between internal key code representations. Signed-off-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260520-input-v3-21-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp>

Akihiko Odaki committed May 20, 2026 at 15:48 UTC 945c10d5418b8462d254a0f55b208d2eaa1e080c
1 file changed +5 -17
ui/input-legacy.c
+5 -17
@@ -71,23 +71,11 @@ int index_from_key(const char *key, size_t key_length)
71 return i;
72 }
73
74 -static KeyValue *copy_key_value(KeyValue *src)
75 -{
76 - KeyValue *dst = g_new(KeyValue, 1);
77 - memcpy(dst, src, sizeof(*src));
78 - if (dst->type == KEY_VALUE_KIND_NUMBER) {
79 - QKeyCode code = qemu_input_key_number_to_qcode(dst->u.number.data);
80 - dst->type = KEY_VALUE_KIND_QCODE;
81 - dst->u.qcode.data = code;
82 - }
83 - return dst;
84 -}
85 -
74 void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
75 Error **errp)
76 {
77 KeyValueList *p;
90 - KeyValue **up = NULL;
78 + unsigned int *up = NULL;
79 int count = 0;
80
81 if (!has_hold_time) {
@@ -95,15 +83,15 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
83 }
84
85 for (p = keys; p != NULL; p = p->next) {
98 - qemu_input_event_send_key(NULL, copy_key_value(p->value), true);
99 - qemu_input_event_send_key_delay(hold_time);
86 up = g_realloc(up, sizeof(*up) * (count+1));
101 - up[count] = copy_key_value(p->value);
87 + up[count] = qemu_input_key_value_to_linux(p->value);
88 + qemu_input_event_send_key_linux(NULL, up[count], true);
89 + qemu_input_event_send_key_delay(hold_time);
90 count++;
91 }
92 while (count) {
93 count--;
106 - qemu_input_event_send_key(NULL, up[count], false);
94 + qemu_input_event_send_key_linux(NULL, up[count], false);
95 qemu_input_event_send_key_delay(hold_time);
96 }
97 g_free(up);