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
12#define INPUT_EVENT_ABS_MIN 0x0000
13#define INPUT_EVENT_ABS_MAX 0x7FFF
14
15typedef struct QemuInputHandler QemuInputHandler;
16typedef struct QemuInputHandlerState QemuInputHandlerState;
17
18typedef void (*QemuInputHandlerEvent)(DeviceState *dev, QemuConsole *src,
19 InputEvent *evt);
20typedef void (*QemuInputHandlerSync)(DeviceState *dev);
21
22struct QemuInputHandler {
23 const char *name;
24 uint32_t mask;
25 QemuInputHandlerEvent event;
26 QemuInputHandlerSync sync;
27};
28
29QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev,
30 QemuInputHandler *handler);
31void qemu_input_handler_activate(QemuInputHandlerState *s);
32void qemu_input_handler_deactivate(QemuInputHandlerState *s);
33void qemu_input_handler_unregister(QemuInputHandlerState *s);
34void qemu_input_handler_bind(QemuInputHandlerState *s,
35 const char *device_id, int head,
36 Error **errp);
37void qemu_input_event_send(QemuConsole *src, InputEvent *evt);
38void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt);
39void qemu_input_event_sync(void);
40void qemu_input_event_sync_impl(void);
41
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(unsigned int 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
53void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
54void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
55 uint32_t button_old, uint32_t button_new);
56
57bool qemu_input_is_absolute(void);
58int qemu_input_scale_axis(int value,
59 int min_in, int max_in,
60 int min_out, int max_out);
61void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value);
62void qemu_input_queue_abs(QemuConsole *src, InputAxis axis, int value,
63 int min_in, int max_in);
64
65void qemu_input_check_mode_change(void);
66void qemu_add_mouse_mode_change_notifier(Notifier *notify);
67void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
68
69extern const guint qemu_input_map_atset1_to_qcode_len;
70extern const guint16 qemu_input_map_atset1_to_qcode[];
71
72extern const guint qemu_input_map_linux_to_qcode_len;
73extern const guint16 qemu_input_map_linux_to_qcode[];
74
75extern const guint qemu_input_map_qcode_to_atset1_len;
76extern const guint16 qemu_input_map_qcode_to_atset1[];
77
78extern const guint qemu_input_map_qcode_to_atset2_len;
79extern const guint16 qemu_input_map_qcode_to_atset2[];
80
81extern const guint qemu_input_map_qcode_to_atset3_len;
82extern const guint16 qemu_input_map_qcode_to_atset3[];
83
84extern const guint qemu_input_map_qcode_to_linux_len;
85extern const guint16 qemu_input_map_qcode_to_linux[];
86
87extern const guint qemu_input_map_qcode_to_qnum_len;
88extern const guint16 qemu_input_map_qcode_to_qnum[];
89
90extern const guint qemu_input_map_qcode_to_sun_len;
91extern const guint16 qemu_input_map_qcode_to_sun[];
92
93extern const guint qemu_input_map_qnum_to_qcode_len;
94extern const guint16 qemu_input_map_qnum_to_qcode[];
95
96extern const guint qemu_input_map_usb_to_qcode_len;
97extern const guint16 qemu_input_map_usb_to_qcode[];
98
99extern const guint qemu_input_map_win32_to_qcode_len;
100extern const guint16 qemu_input_map_win32_to_qcode[];
101
102extern const guint qemu_input_map_x11_to_qcode_len;
103extern const guint16 qemu_input_map_x11_to_qcode[];
104
105extern const guint qemu_input_map_xorgevdev_to_qcode_len;
106extern const guint16 qemu_input_map_xorgevdev_to_qcode[];
107
108extern const guint qemu_input_map_xorgkbd_to_qcode_len;
109extern const guint16 qemu_input_map_xorgkbd_to_qcode[];
110
111extern const guint qemu_input_map_xorgxquartz_to_qcode_len;
112extern const guint16 qemu_input_map_xorgxquartz_to_qcode[];
113
114extern const guint qemu_input_map_xorgxwin_to_qcode_len;
115extern const guint16 qemu_input_map_xorgxwin_to_qcode[];
116
117extern const guint qemu_input_map_osx_to_qcode_len;
118extern const guint16 qemu_input_map_osx_to_qcode[];
119
120#endif
121