1#ifndef INPUT_H
2#define INPUT_H
3
4#include "qapi/qapi-types-ui.h"
5#include "qemu/notify.h"
6
7#define INPUT_EVENT_MASK_KEY (1<<INPUT_EVENT_KIND_KEY)
8#define INPUT_EVENT_MASK_BTN (1<<INPUT_EVENT_KIND_BTN)
9#define INPUT_EVENT_MASK_REL (1<<INPUT_EVENT_KIND_REL)
10#define INPUT_EVENT_MASK_ABS (1<<INPUT_EVENT_KIND_ABS)
11#define INPUT_EVENT_MASK_MTT (1<<INPUT_EVENT_KIND_MTT)
12
13#define INPUT_EVENT_ABS_MIN 0x0000
14#define INPUT_EVENT_ABS_MAX 0x7FFF
15#define INPUT_EVENT_SLOTS_MIN 0x0
16#define INPUT_EVENT_SLOTS_MAX 0xa
17
18typedef struct QemuInputHandler QemuInputHandler;
19typedef struct QemuInputHandlerState QemuInputHandlerState;
20
21typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src,
22 InputEvent *evt);
23typedef void (*QemuInputHandlerSync)(DeviceState *dev);
24
25struct QemuInputHandler {
26 const char *name;
27 uint32_t mask;
28 QemuInputHandlerEvent event;
29 QemuInputHandlerSync sync;
30};
31
32QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
33 QemuInputHandler *handler);
34void qemu_input_handler_activate(QemuInputHandlerState *s);
35void qemu_input_handler_deactivate(QemuInputHandlerState *s);
36void qemu_input_handler_unregister(QemuInputHandlerState *s);
37void qemu_input_handler_bind(QemuInputHandlerState *s,
38 const char *device_id, int head,
39 Error **errp);
40void qemu_input_event_send(QemuConsole *src, InputEvent *evt);
41void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt);
42void qemu_input_event_sync(void);
43void qemu_input_event_sync_impl(void);
44
45void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down);
46void qemu_input_event_send_key_number(QemuConsole *src, int num, bool down);
47void qemu_input_event_send_key_qcode(QemuConsole *src, QKeyCode q, bool down);
48void qemu_input_event_send_key_delay(uint32_t delay_ms);
49int qemu_input_key_number_to_qcode(unsigned int nr);
50int qemu_input_key_value_to_number(const KeyValue *value);
51int qemu_input_key_value_to_qcode(const KeyValue *value);
52int qemu_input_key_value_to_scancode(const KeyValue *value, bool down,
53 int *codes);
54int qemu_input_linux_to_qcode(unsigned int lnx);
55
56void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
57void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
58 uint32_t button_old, uint32_t button_new);
59
60bool qemu_input_is_absolute(void);
61int qemu_input_scale_axis(int value,
62 int min_in, int max_in,
63 int min_out, int max_out);
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);
67void qemu_input_queue_mtt(QemuConsole *src, InputMultiTouchType type, int slot,
68 int tracking_id);
69void qemu_input_queue_mtt_abs(QemuConsole *src, InputAxis axis, int value,
70 int min_in, int max_in,
71 int slot, int tracking_id);
72
73void qemu_input_check_mode_change(void);
74void qemu_add_mouse_mode_change_notifier(Notifier *notify);
75void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
76
77extern const guint qemu_input_map_atset1_to_qcode_len;
78extern const guint16 qemu_input_map_atset1_to_qcode[];
79
80extern const guint qemu_input_map_linux_to_qcode_len;
81extern const guint16 qemu_input_map_linux_to_qcode[];
82
83extern const guint qemu_input_map_qcode_to_atset1_len;
84extern const guint16 qemu_input_map_qcode_to_atset1[];
85
86extern const guint qemu_input_map_qcode_to_atset2_len;
87extern const guint16 qemu_input_map_qcode_to_atset2[];
88
89extern const guint qemu_input_map_qcode_to_atset3_len;
90extern const guint16 qemu_input_map_qcode_to_atset3[];
91
92extern const guint qemu_input_map_qcode_to_linux_len;
93extern const guint16 qemu_input_map_qcode_to_linux[];
94
95extern const guint qemu_input_map_qcode_to_qnum_len;
96extern const guint16 qemu_input_map_qcode_to_qnum[];
97
98extern const guint qemu_input_map_qcode_to_sun_len;
99extern const guint16 qemu_input_map_qcode_to_sun[];
100
101extern const guint qemu_input_map_qnum_to_qcode_len;
102extern const guint16 qemu_input_map_qnum_to_qcode[];
103
104extern const guint qemu_input_map_usb_to_qcode_len;
105extern const guint16 qemu_input_map_usb_to_qcode[];
106
107extern const guint qemu_input_map_win32_to_qcode_len;
108extern const guint16 qemu_input_map_win32_to_qcode[];
109
110extern const guint qemu_input_map_x11_to_qcode_len;
111extern const guint16 qemu_input_map_x11_to_qcode[];
112
113extern const guint qemu_input_map_xorgevdev_to_qcode_len;
114extern const guint16 qemu_input_map_xorgevdev_to_qcode[];
115
116extern const guint qemu_input_map_xorgkbd_to_qcode_len;
117extern const guint16 qemu_input_map_xorgkbd_to_qcode[];
118
119extern const guint qemu_input_map_xorgxquartz_to_qcode_len;
120extern const guint16 qemu_input_map_xorgxquartz_to_qcode[];
121
122extern const guint qemu_input_map_xorgxwin_to_qcode_len;
123extern const guint16 qemu_input_map_xorgxwin_to_qcode[];
124
125extern const guint qemu_input_map_osx_to_qcode_len;
126extern const guint16 qemu_input_map_osx_to_qcode[];
127
128#endif
129