summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAkihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>2026-05-20 15:47:47 +0900
committerMarc-André Lureau <marcandre.lureau@redhat.com>2026-05-25 01:00:54 +0400
commit184c07600d2c65204ffe7d98263e916e779c8aa8 (patch)
tree6853288c427fa44f6759100f870ba2ad955c80f8 /tools
parent56729b7aaf7252c0843d106be50c18243c17f98a (diff)
downloadqemu-184c07600d2c65204ffe7d98263e916e779c8aa8.tar.gz
qemu-184c07600d2c65204ffe7d98263e916e779c8aa8.zip
ui/input: Use Linux key codes for internal key events
Linux input key codes are a better internal representation than QKeyCode: - With Linux input key codes as the internal representation, keys previously lost solely because the middle layer between event sources and sinks used QKeyCode will be preserved, since Linux key codes cover all keys that those sources and sinks use. For example, KEY_KPJPCOMMA cannot be represented with QKeyCode, but it is widely supported by event sources and sinks since it is included in linux, atset1, atset2, usb, x11, osx, qnum (derived from atset1), xorgxquartz, and xorgevdev (derived from linux). - They make it possible to pass through Linux host key codes to Linux guests to preserve all key inputs. - They simplify consumers by avoiding QKeyCode aliases, namely asterisk/kp_multiply and sysrq/print. This matches the approach used by virtio and Xen. 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-4-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp>
Diffstat (limited to 'tools')
-rw-r--r--tools/qemu-vnc/input.c13
-rw-r--r--tools/qemu-vnc/trace-events2
2 files changed, 11 insertions, 4 deletions
diff --git a/tools/qemu-vnc/input.c b/tools/qemu-vnc/input.c
index 2313b0a7c7..90e2e79d1e 100644
--- a/tools/qemu-vnc/input.c
+++ b/tools/qemu-vnc/input.c
@@ -83,10 +83,17 @@ void qemu_input_event_send_key_delay(uint32_t delay_ms)
void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down)
{
+ unsigned int lnx = qemu_input_map_qcode_to_linux[q];
+ qemu_input_event_send_key_linux(src, lnx, down);
+}
+
+void qemu_input_event_send_key_linux(QemuConsole *src, unsigned int lnx,
+ bool down)
+{
QemuDBusDisplay1Keyboard *kbd;
guint qnum;
- trace_qemu_vnc_key_event(q, down);
+ trace_qemu_vnc_key_event(lnx, down);
if (!src) {
return;
@@ -96,10 +103,10 @@ void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down)
return;
}
- if (q >= qemu_input_map_qcode_to_qnum_len) {
+ if (lnx >= qemu_input_map_linux_to_qnum_len) {
return;
}
- qnum = qemu_input_map_qcode_to_qnum[q];
+ qnum = qemu_input_map_linux_to_qnum[lnx];
if (down) {
qemu_dbus_display1_keyboard_call_press(
diff --git a/tools/qemu-vnc/trace-events b/tools/qemu-vnc/trace-events
index e3b550de10..570062984a 100644
--- a/tools/qemu-vnc/trace-events
+++ b/tools/qemu-vnc/trace-events
@@ -12,7 +12,7 @@ qemu_vnc_cursor_define(int width, int height, int hot_x, int hot_y) "w=%d h=%d h
qemu_vnc_input_abs(uint32_t x, uint32_t y) "x=%u y=%u"
qemu_vnc_input_btn(int button, bool press) "button=%d press=%d"
qemu_vnc_input_rel(int dx, int dy) "dx=%d dy=%d"
-qemu_vnc_key_event(int qcode, bool down) "qcode=%d down=%d"
+qemu_vnc_key_event(unsigned int lnx, bool down) "lnx=%u down=%d"
qemu_vnc_owner_appeared(const char *name) "peer=%s"
qemu_vnc_owner_vanished(const char *name) "peer=%s"
qemu_vnc_scanout(uint32_t width, uint32_t height, uint32_t stride, uint32_t format) "w=%u h=%u stride=%u fmt=0x%x"