hw/char/escc: 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-9-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp>
Akihiko Odaki committed
May 20, 2026 at 15:47 UTC
44f9eeb2de1bb477895a9623be2b9bbf6483b55e
1 file changed
+5
-4
hw/char/escc.c
+5
-4
@@ -30,6 +30,7 @@
30
#include "migration/vmstate.h"
31
#include "qemu/module.h"
32
#include "hw/char/escc.h"
33
+#include "standard-headers/linux/input-event-codes.h"
34
#include "ui/console.h"
35
36
#include "qemu/cutils.h"
@@ -804,7 +805,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
805
trace_escc_sunkbd_event_in(qcode, QKeyCode_str(qcode),
806
evt->key.down);
807
807
- if (qcode == Q_KEY_CODE_CAPS_LOCK) {
808
+ if (evt->key.key == KEY_CAPSLOCK) {
809
if (evt->key.down) {
810
s->caps_lock_mode ^= 1;
811
if (s->caps_lock_mode == 2) {
@@ -818,7 +819,7 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
819
}
820
}
821
821
- if (qcode == Q_KEY_CODE_NUM_LOCK) {
822
+ if (evt->key.key == KEY_NUMLOCK) {
823
if (evt->key.down) {
824
s->num_lock_mode ^= 1;
825
if (s->num_lock_mode == 2) {
@@ -832,11 +833,11 @@ static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
833
}
834
}
835
835
- if (qcode >= qemu_input_map_qcode_to_sun_len) {
836
+ if (evt->key.key >= qemu_input_map_linux_to_sun_len) {
837
return;
838
}
839
839
- keycode = qemu_input_map_qcode_to_sun[qcode];
840
+ keycode = qemu_input_map_linux_to_sun[evt->key.key];
841
if (!evt->key.down) {
842
keycode |= 0x80;
843
}