ui/input-barrier: 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-20-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp>
This commit is contained in:
committed by
Marc-André Lureau
parent
89b76c5fb0
commit
45a933bacf
@@ -84,11 +84,11 @@ static const char *cmd_names[] = {
|
||||
|
||||
static kbd_layout_t *kbd_layout;
|
||||
|
||||
static int input_barrier_to_qcode(uint16_t keyid, uint16_t keycode)
|
||||
static unsigned int input_barrier_to_linux(uint16_t keyid, uint16_t keycode)
|
||||
{
|
||||
/* keycode is optional, if it is not provided use keyid */
|
||||
if (keycode && keycode <= qemu_input_map_xorgkbd_to_qcode_len) {
|
||||
return qemu_input_map_xorgkbd_to_qcode[keycode];
|
||||
if (keycode && keycode <= qemu_input_map_xorgkbd_to_linux_len) {
|
||||
return qemu_input_map_xorgkbd_to_linux[keycode];
|
||||
}
|
||||
|
||||
if (keyid >= 0xE000 && keyid <= 0xEFFF) {
|
||||
@@ -99,10 +99,10 @@ static int input_barrier_to_qcode(uint16_t keyid, uint16_t keycode)
|
||||
if (kbd_layout) {
|
||||
keycode = keysym2scancode(kbd_layout, keyid, NULL, false);
|
||||
|
||||
return qemu_input_key_number_to_qcode(keycode);
|
||||
return qemu_input_key_number_to_linux(keycode);
|
||||
}
|
||||
|
||||
return qemu_input_map_x11_to_qcode[keyid];
|
||||
return qemu_input_map_x11_to_linux[keyid];
|
||||
}
|
||||
|
||||
static int input_barrier_to_mouse(uint8_t buttonid)
|
||||
@@ -431,23 +431,23 @@ static gboolean writecmd(InputBarrier *ib, struct barrierMsg *msg)
|
||||
|
||||
/* keyboard */
|
||||
case barrierCmdDKeyDown:
|
||||
qemu_input_event_send_key_qcode(NULL,
|
||||
input_barrier_to_qcode(msg->key.keyid, msg->key.button),
|
||||
qemu_input_event_send_key_linux(NULL,
|
||||
input_barrier_to_linux(msg->key.keyid, msg->key.button),
|
||||
true);
|
||||
break;
|
||||
case barrierCmdDKeyRepeat:
|
||||
for (i = 0; i < msg->repeat.repeat; i++) {
|
||||
qemu_input_event_send_key_qcode(NULL,
|
||||
input_barrier_to_qcode(msg->repeat.keyid, msg->repeat.button),
|
||||
qemu_input_event_send_key_linux(NULL,
|
||||
input_barrier_to_linux(msg->repeat.keyid, msg->repeat.button),
|
||||
false);
|
||||
qemu_input_event_send_key_qcode(NULL,
|
||||
input_barrier_to_qcode(msg->repeat.keyid, msg->repeat.button),
|
||||
qemu_input_event_send_key_linux(NULL,
|
||||
input_barrier_to_linux(msg->repeat.keyid, msg->repeat.button),
|
||||
true);
|
||||
}
|
||||
break;
|
||||
case barrierCmdDKeyUp:
|
||||
qemu_input_event_send_key_qcode(NULL,
|
||||
input_barrier_to_qcode(msg->key.keyid, msg->key.button),
|
||||
qemu_input_event_send_key_linux(NULL,
|
||||
input_barrier_to_linux(msg->key.keyid, msg->key.button),
|
||||
false);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user