1#ifndef INPUT_H
2#define INPUT_H
3
4#include "qapi-types.h"
5
6#define INPUT_EVENT_MASK_KEY (1<<INPUT_EVENT_KIND_KEY)
7#define INPUT_EVENT_MASK_BTN (1<<INPUT_EVENT_KIND_BTN)
8#define INPUT_EVENT_MASK_REL (1<<INPUT_EVENT_KIND_REL)
9#define INPUT_EVENT_MASK_ABS (1<<INPUT_EVENT_KIND_ABS)
10
11#define INPUT_EVENT_ABS_MIN 0x0000
12#define INPUT_EVENT_ABS_MAX 0x7FFF
13
14typedef struct QemuInputHandler QemuInputHandler;
15typedef struct QemuInputHandlerState QemuInputHandlerState;
16
17typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src,
18 InputEvent *evt);
19typedef void (*QemuInputHandlerSync)(DeviceState *dev);
20
21struct QemuInputHandler {
22 const char *name;
23 uint32_t mask;
24 QemuInputHandlerEvent event;
25 QemuInputHandlerSync sync;
26};
27
28QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
29 QemuInputHandler *handler);
30void qemu_input_handler_activate(QemuInputHandlerState *s);
31void qemu_input_handler_deactivate(QemuInputHandlerState *s);
32void qemu_input_handler_unregister(QemuInputHandlerState *s);
33void qemu_input_handler_bind(QemuInputHandlerState *s,
34 const char *device_id, int head,
35 Error **errp);
36void qemu_input_event_send(QemuConsole *src, InputEvent *evt);
37void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt);
38void qemu_input_event_sync(void);
39void qemu_input_event_sync_impl(void);
40
41InputEvent *qemu_input_event_new_key(KeyValue *key, bool down);
42void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
43void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
44void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
45void qemu_input_event_send_key_delay(uint32_t delay_ms);
46int qemu_input_key_number_to_qcode(uint8_t nr);
47int qemu_input_key_value_to_number(const KeyValue *value);
48int qemu_input_key_value_to_qcode(const KeyValue *value);
49int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
50 int *codes);
51int qemu_input_linux_to_qcode(unsigned int lnx);
52
53InputEvent *qemu_input_event_new_btn(InputButton btn, bool down);
54void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
55void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
56 uint32_t button_old, uint32_t button_new);
57
58bool qemu_input_is_absolute(void);
59int qemu_input_scale_axis(int value,
60 int min_in, int max_in,
61 int min_out, int max_out);
62InputEvent *qemu_input_event_new_move(InputEventKind kind,
63 InputAxis axis, int value);
64void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
65void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
66 int min_in, int max_in);
67
68void qemu_input_check_mode_change(void);
69void qemu_add_mouse_mode_change_notifier(Notifier *notify);
70void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
71
72#endif
73