@samitouri / QOSamiQemu / commits / a0f5963a30

ui/input: Introduce QemuInputEvent typedef

Add QemuInputEvent as the input subsystem's name for InputEvent and use it in input handler, queue, and replay interfaces. This prepares for decoupling QEMU's internal input event representation from the QAPI InputEvent type. 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-1-7c9e4c7abe34@rsg.ci.i.u-tokyo.ac.jp>

Akihiko Odaki committed May 20, 2026 at 15:47 UTC a0f5963a307206162be3a62358424f24d99f3699
22 files changed +47 -45
chardev/msmouse.c
+1 -1
@@ -122,7 +122,7 @@ static void msmouse_queue_event(MouseChardev *mouse)
122 }
123
124 static void msmouse_input_event(DeviceState *dev, QemuConsole *src,
125 - InputEvent *evt)
125 + QemuInputEvent *evt)
126 {
127 MouseChardev *mouse = MOUSE_CHARDEV(dev);
128 InputMoveEvent *move;
chardev/wctablet.c
+1 -1
@@ -146,7 +146,7 @@ static void wctablet_queue_event(TabletChardev *tablet)
146 }
147
148 static void wctablet_input_event(DeviceState *dev, QemuConsole *src,
149 - InputEvent *evt)
149 + QemuInputEvent *evt)
150 {
151 TabletChardev *tablet = (TabletChardev *)dev;
152 InputMoveEvent *move;
hw/arm/musicpal.c
+1 -1
@@ -1066,7 +1066,7 @@ struct musicpal_key_state {
1066 };
1067
1068 static void musicpal_key_event(DeviceState *dev, QemuConsole *src,
1069 - InputEvent *evt)
1069 + QemuInputEvent *evt)
1070 {
1071 musicpal_key_state *s = MUSICPAL_KEY(dev);
1072 InputKeyEvent *key = evt->u.key.data;
hw/char/escc.c
+2 -2
@@ -794,7 +794,7 @@ static const VMStateDescription vmstate_escc = {
794 };
795
796 static void sunkbd_handle_event(DeviceState *dev, QemuConsole *src,
797 - InputEvent *evt)
797 + QemuInputEvent *evt)
798 {
799 ESCCChannelState *s = (ESCCChannelState *)dev;
800 int qcode, keycode;
@@ -954,7 +954,7 @@ static void handle_kbd_command(ESCCChannelState *s, int val)
954 }
955
956 static void sunmouse_handle_event(DeviceState *dev, QemuConsole *src,
957 - InputEvent *evt)
957 + QemuInputEvent *evt)
958 {
959 ESCCChannelState *s = (ESCCChannelState *)dev;
960 InputMoveEvent *move;
hw/display/xenfb.c
+2 -2
@@ -200,7 +200,7 @@ static int xenfb_send_position(struct XenInput *xenfb,
200 * already has code for dealing with this...
201 */
202 static void xenfb_key_event(DeviceState *dev, QemuConsole *src,
203 - InputEvent *evt)
203 + QemuInputEvent *evt)
204 {
205 struct XenInput *xenfb = (struct XenInput *)dev;
206 InputKeyEvent *key = evt->u.key.data;
@@ -227,7 +227,7 @@ static void xenfb_key_event(DeviceState *dev, QemuConsole *src,
227 * the button state.
228 */
229 static void xenfb_mouse_event(DeviceState *dev, QemuConsole *src,
230 - InputEvent *evt)
230 + QemuInputEvent *evt)
231 {
232 struct XenInput *xenfb = (struct XenInput *)dev;
233 InputBtnEvent *btn;
hw/input/adb-kbd.c
+1 -1
@@ -306,7 +306,7 @@ static bool adb_kbd_has_data(ADBDevice *d)
306
307 /* This is where keyboard events enter this file */
308 static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,
309 - InputEvent *evt)
309 + QemuInputEvent *evt)
310 {
311 KBDState *s = (KBDState *)dev;
312 int qcode, keycode;
hw/input/adb-mouse.c
+1 -1
@@ -56,7 +56,7 @@ struct ADBMouseClass {
56 #define ADB_MOUSE_BUTTON_RIGHT 0x02
57
58 static void adb_mouse_handle_event(DeviceState *dev, QemuConsole *src,
59 - InputEvent *evt)
59 + QemuInputEvent *evt)
60 {
61 MouseState *s = (MouseState *)dev;
62 InputMoveEvent *move;
hw/input/hid.c
+2 -2
@@ -108,7 +108,7 @@ void hid_set_next_idle(HIDState *hs)
108 }
109
110 static void hid_pointer_event(DeviceState *dev, QemuConsole *src,
111 - InputEvent *evt)
111 + QemuInputEvent *evt)
112 {
113 static const int bmap[INPUT_BUTTON__MAX] = {
114 [INPUT_BUTTON_LEFT] = 0x01,
@@ -226,7 +226,7 @@ static void hid_pointer_sync(DeviceState *dev)
226 }
227
228 static void hid_keyboard_event(DeviceState *dev, QemuConsole *src,
229 - InputEvent *evt)
229 + QemuInputEvent *evt)
230 {
231 HIDState *hs = (HIDState *)dev;
232 int scancodes[3], i, count;
hw/input/ps2.c
+2 -2
@@ -310,7 +310,7 @@ static void ps2_put_keycode(void *opaque, int keycode)
310 }
311
312 static void ps2_keyboard_event(DeviceState *dev, QemuConsole *src,
313 - InputEvent *evt)
313 + QemuInputEvent *evt)
314 {
315 PS2KbdState *s = (PS2KbdState *)dev;
316 InputKeyEvent *key = evt->u.key.data;
@@ -787,7 +787,7 @@ static int ps2_mouse_send_packet(PS2MouseState *s)
787 }
788
789 static void ps2_mouse_event(DeviceState *dev, QemuConsole *src,
790 - InputEvent *evt)
790 + QemuInputEvent *evt)
791 {
792 static const int bmap[INPUT_BUTTON__MAX] = {
793 [INPUT_BUTTON_LEFT] = PS2_MOUSE_BUTTON_LEFT,
hw/input/stellaris_gamepad.c
+1 -1
@@ -16,7 +16,7 @@
16 #include "ui/console.h"
17
18 static void stellaris_gamepad_event(DeviceState *dev, QemuConsole *src,
19 - InputEvent *evt)
19 + QemuInputEvent *evt)
20 {
21 StellarisGamepad *s = STELLARIS_GAMEPAD(dev);
22 InputKeyEvent *key = evt->u.key.data;
hw/input/virtio-input-hid.c
+1 -1
@@ -79,7 +79,7 @@ static void virtio_input_extend_config(VirtIOInput *vinput,
79 }
80
81 static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src,
82 - InputEvent *evt)
82 + QemuInputEvent *evt)
83 {
84 VirtIOInput *vinput = VIRTIO_INPUT(dev);
85 virtio_input_event event;
hw/m68k/next-kbd.c
+2 -1
@@ -242,7 +242,8 @@ static void nextkbd_put_keycode(NextKBDState *s, int keycode)
242 /* s->update_irq(s->update_arg, 1); */
243 }
244
245 -static void nextkbd_event(DeviceState *dev, QemuConsole *src, InputEvent *evt)
245 +static void nextkbd_event(DeviceState *dev, QemuConsole *src,
246 + QemuInputEvent *evt)
247 {
248 NextKBDState *s = NEXTKBD(dev);
249 int qcode, keycode;
include/qemu/typedefs.h
+1
@@ -94,6 +94,7 @@ typedef struct QBool QBool;
94 typedef struct QDict QDict;
95 typedef struct QEMUBH QEMUBH;
96 typedef struct QemuConsole QemuConsole;
97 +typedef struct InputEvent QemuInputEvent;
98 typedef struct QEMUCursor QEMUCursor;
99 typedef struct QEMUFile QEMUFile;
100 typedef struct QemuMutex QemuMutex;
include/system/replay.h
+1 -1
@@ -126,7 +126,7 @@ void replay_bh_schedule_event(QEMUBH *bh);
126 void replay_bh_schedule_oneshot_event(AioContext *ctx,
127 QEMUBHFunc *cb, void *opaque);
128 /*! Adds input event to the queue */
129 -void replay_input_event(QemuConsole *src, InputEvent *evt);
129 +void replay_input_event(QemuConsole *src, QemuInputEvent *evt);
130 /*! Adds input sync event to the queue */
131 void replay_input_sync_event(void);
132 /*! Adds block layer event to the queue */
include/ui/input.h
+3 -3
@@ -19,7 +19,7 @@ typedef struct QemuInputHandler QemuInputHandler;
19 typedef struct QemuInputHandlerState QemuInputHandlerState;
20
21 typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src,
22 - InputEvent *evt);
22 + QemuInputEvent *evt);
23 typedef void (*QemuInputHandlerSync)(DeviceState *dev);
24
25 struct QemuInputHandler {
@@ -37,8 +37,8 @@ void qemu_input_handler_unregister(QemuInputHandlerState *s);
37 void qemu_input_handler_bind(QemuInputHandlerState *s,
38 const char *device_id, int head,
39 Error **errp);
40 -void qemu_input_event_send(QemuConsole *src, InputEvent *evt);
41 -void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt);
40 +void qemu_input_event_send(QemuConsole *src, QemuInputEvent *evt);
41 +void qemu_input_event_send_impl(QemuConsole *src, QemuInputEvent *evt);
42 void qemu_input_event_sync(void);
43 void qemu_input_event_sync_impl(void);
44
replay/replay-events.c
+2 -2
@@ -41,7 +41,7 @@ static void replay_run_event(Event *event)
41 ((QEMUBHFunc *)event->opaque)(event->opaque2);
42 break;
43 case REPLAY_ASYNC_EVENT_INPUT:
44 - qemu_input_event_send_impl(NULL, (InputEvent *)event->opaque);
44 + qemu_input_event_send_impl(NULL, (QemuInputEvent *)event->opaque);
45 qapi_free_InputEvent((InputEvent *)event->opaque);
46 break;
47 case REPLAY_ASYNC_EVENT_INPUT_SYNC:
@@ -143,7 +143,7 @@ void replay_bh_schedule_oneshot_event(AioContext *ctx,
143 }
144 }
145
146 -void replay_add_input_event(struct InputEvent *event)
146 +void replay_add_input_event(QemuInputEvent *event)
147 {
148 replay_add_event(REPLAY_ASYNC_EVENT_INPUT, event, NULL, 0);
149 }
replay/replay-input.c
+4 -4
@@ -17,7 +17,7 @@
17 #include "qapi/clone-visitor.h"
18 #include "qapi/qapi-visit-ui.h"
19
20 -void replay_save_input_event(InputEvent *evt)
20 +void replay_save_input_event(QemuInputEvent *evt)
21 {
22 InputKeyEvent *key;
23 InputBtnEvent *btn;
@@ -73,9 +73,9 @@ void replay_save_input_event(InputEvent *evt)
73 }
74 }
75
76 -InputEvent *replay_read_input_event(void)
76 +QemuInputEvent *replay_read_input_event(void)
77 {
78 - InputEvent evt;
78 + QemuInputEvent evt;
79 KeyValue keyValue;
80 InputKeyEvent key;
81 key.key = &keyValue;
@@ -135,7 +135,7 @@ InputEvent *replay_read_input_event(void)
135 return QAPI_CLONE(InputEvent, &evt);
136 }
137
138 -void replay_input_event(QemuConsole *src, InputEvent *evt)
138 +void replay_input_event(QemuConsole *src, QemuInputEvent *evt)
139 {
140 if (replay_mode == REPLAY_MODE_PLAY) {
141 /* Nothing */
replay/replay-internal.h
+3 -3
@@ -171,11 +171,11 @@ void replay_add_event(ReplayAsyncEventKind event_kind, void *opaque,
171 /* Input events */
172
173 /*! Saves input event to the log */
174 -void replay_save_input_event(InputEvent *evt);
174 +void replay_save_input_event(QemuInputEvent *evt);
175 /*! Reads input event from the log */
176 -InputEvent *replay_read_input_event(void);
176 +QemuInputEvent *replay_read_input_event(void);
177 /*! Adds input event to the queue */
178 -void replay_add_input_event(struct InputEvent *event);
178 +void replay_add_input_event(QemuInputEvent *event);
179 /*! Adds input sync event to the queue */
180 void replay_add_input_sync_event(void);
181
replay/stubs-system.c
+1 -1
@@ -2,7 +2,7 @@
2 #include "system/replay.h"
3 #include "ui/input.h"
4
5 -void replay_input_event(QemuConsole *src, InputEvent *evt)
5 +void replay_input_event(QemuConsole *src, QemuInputEvent *evt)
6 {
7 qemu_input_event_send_impl(src, evt);
8 }
ui/input-legacy.c
+1 -1
@@ -110,7 +110,7 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time,
110 }
111
112 static void legacy_mouse_event(DeviceState *dev, QemuConsole *src,
113 - InputEvent *evt)
113 + QemuInputEvent *evt)
114 {
115 static const int bmap[INPUT_BUTTON__MAX] = {
116 [INPUT_BUTTON_LEFT] = MOUSE_EVENT_LBUTTON,
ui/input.c
+13 -13
@@ -30,7 +30,7 @@ struct QemuInputEventQueue {
30 QEMUTimer *timer;
31 uint32_t delay_ms;
32 QemuConsole *src;
33 - InputEvent *evt;
33 + QemuInputEvent *evt;
34 QTAILQ_ENTRY(QemuInputEventQueue) node;
35 };
36
@@ -174,7 +174,7 @@ void qmp_input_send_event(const char *device,
174 qemu_input_event_sync();
175 }
176
177 -static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)
177 +static void qemu_input_event_trace(QemuConsole *src, QemuInputEvent *evt)
178 {
179 const char *name;
180 int qcode, idx = -1;
@@ -283,7 +283,7 @@ static void qemu_input_queue_delay(QemuInputEventQueueHead *queue,
283 }
284
285 static void qemu_input_queue_event(QemuInputEventQueueHead *queue,
286 - QemuConsole *src, InputEvent *evt)
286 + QemuConsole *src, QemuInputEvent *evt)
287 {
288 QemuInputEventQueue *item = g_new0(QemuInputEventQueue, 1);
289
@@ -303,7 +303,7 @@ static void qemu_input_queue_sync(QemuInputEventQueueHead *queue)
303 queue_count++;
304 }
305
306 -void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt)
306 +void qemu_input_event_send_impl(QemuConsole *src, QemuInputEvent *evt)
307 {
308 QemuInputHandlerState *s;
309
@@ -318,7 +318,7 @@ void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt)
318 s->events++;
319 }
320
321 -void qemu_input_event_send(QemuConsole *src, InputEvent *evt)
321 +void qemu_input_event_send(QemuConsole *src, QemuInputEvent *evt)
322 {
323 /* Expect all parts of QEMU to send events with QCodes exclusively.
324 * Key numbers are only supported as end-user input via QMP */
@@ -372,9 +372,9 @@ void qemu_input_event_sync(void)
372 replay_input_sync_event();
373 }
374
375 -static InputEvent *qemu_input_event_new_key(KeyValue *key, bool down)
375 +static QemuInputEvent *qemu_input_event_new_key(KeyValue *key, bool down)
376 {
377 - InputEvent *evt = g_new0(InputEvent, 1);
377 + QemuInputEvent *evt = g_new0(QemuInputEvent, 1);
378 evt->u.key.data = g_new0(InputKeyEvent, 1);
379 evt->type = INPUT_EVENT_KIND_KEY;
380 evt->u.key.data->key = key;
@@ -384,7 +384,7 @@ static InputEvent *qemu_input_event_new_key(KeyValue *key, bool down)
384
385 void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down)
386 {
387 - InputEvent *evt;
387 + QemuInputEvent *evt;
388 evt = qemu_input_event_new_key(key, down);
389 if (QTAILQ_EMPTY(&kbd_queue)) {
390 qemu_input_event_send(src, evt);
@@ -435,7 +435,7 @@ void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down)
435 .button = btn,
436 .down = down,
437 };
438 - InputEvent evt = {
438 + QemuInputEvent evt = {
439 .type = INPUT_EVENT_KIND_BTN,
440 .u.btn.data = &bevt,
441 };
@@ -486,7 +486,7 @@ void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value)
486 .axis = axis,
487 .value = value,
488 };
489 - InputEvent evt = {
489 + QemuInputEvent evt = {
490 .type = INPUT_EVENT_KIND_REL,
491 .u.rel.data = &move,
492 };
@@ -503,7 +503,7 @@ void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
503 INPUT_EVENT_ABS_MIN,
504 INPUT_EVENT_ABS_MAX),
505 };
506 - InputEvent evt = {
506 + QemuInputEvent evt = {
507 .type = INPUT_EVENT_KIND_ABS,
508 .u.abs.data = &move,
509 };
@@ -519,7 +519,7 @@ void qemu_input_queue_mtt(QemuConsole *src, InputMultiTouchType type,
519 .slot = slot,
520 .tracking_id = tracking_id,
521 };
522 - InputEvent evt = {
522 + QemuInputEvent evt = {
523 .type = INPUT_EVENT_KIND_MTT,
524 .u.mtt.data = &mtt,
525 };
@@ -539,7 +539,7 @@ void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value,
539 INPUT_EVENT_ABS_MIN,
540 INPUT_EVENT_ABS_MAX),
541 };
542 - InputEvent evt = {
542 + QemuInputEvent evt = {
543 .type = INPUT_EVENT_KIND_MTT,
544 .u.mtt.data = &mtt,
545 };
ui/vdagent.c
+1 -1
@@ -226,7 +226,7 @@ static void vdagent_send_mouse(VDAgentChardev *vd)
226 }
227
228 static void vdagent_pointer_event(DeviceState *dev, QemuConsole *src,
229 - InputEvent *evt)
229 + QemuInputEvent *evt)
230 {
231 static const int bmap[INPUT_BUTTON__MAX] = {
232 [INPUT_BUTTON_LEFT] = VD_AGENT_LBUTTON_MASK,