]> git.proxmox.com Git - mirror_qemu.git/blob - include/hw/virtio/virtio-input.h
virtio-input: add a virtio-mulitouch device
[mirror_qemu.git] / include / hw / virtio / virtio-input.h
1 #ifndef QEMU_VIRTIO_INPUT_H
2 #define QEMU_VIRTIO_INPUT_H
3
4 #include "ui/input.h"
5 #include "sysemu/vhost-user-backend.h"
6
7 /* ----------------------------------------------------------------- */
8 /* virtio input protocol */
9
10 #include "standard-headers/linux/virtio_ids.h"
11 #include "standard-headers/linux/virtio_input.h"
12 #include "qom/object.h"
13
14 typedef struct virtio_input_absinfo virtio_input_absinfo;
15 typedef struct virtio_input_config virtio_input_config;
16 typedef struct virtio_input_event virtio_input_event;
17
18 /* ----------------------------------------------------------------- */
19 /* qemu internals */
20
21 #define TYPE_VIRTIO_INPUT "virtio-input-device"
22 OBJECT_DECLARE_TYPE(VirtIOInput, VirtIOInputClass,
23 VIRTIO_INPUT)
24 #define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \
25 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT)
26
27 #define TYPE_VIRTIO_INPUT_HID "virtio-input-hid-device"
28 #define TYPE_VIRTIO_KEYBOARD "virtio-keyboard-device"
29 #define TYPE_VIRTIO_MOUSE "virtio-mouse-device"
30 #define TYPE_VIRTIO_TABLET "virtio-tablet-device"
31 #define TYPE_VIRTIO_MULTITOUCH "virtio-multitouch-device"
32
33 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHID, VIRTIO_INPUT_HID)
34 #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
35 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
36
37 #define TYPE_VIRTIO_INPUT_HOST "virtio-input-host-device"
38 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHost, VIRTIO_INPUT_HOST)
39 #define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
40 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
41
42 #define TYPE_VHOST_USER_INPUT "vhost-user-input"
43 OBJECT_DECLARE_SIMPLE_TYPE(VHostUserInput, VHOST_USER_INPUT)
44 #define VHOST_USER_INPUT_GET_PARENT_CLASS(obj) \
45 OBJECT_GET_PARENT_CLASS(obj, TYPE_VHOST_USER_INPUT)
46
47 typedef struct VirtIOInputConfig VirtIOInputConfig;
48
49 struct VirtIOInputConfig {
50 virtio_input_config config;
51 QTAILQ_ENTRY(VirtIOInputConfig) node;
52 };
53
54 struct VirtIOInput {
55 VirtIODevice parent_obj;
56 uint8_t cfg_select;
57 uint8_t cfg_subsel;
58 uint32_t cfg_size;
59 QTAILQ_HEAD(, VirtIOInputConfig) cfg_list;
60 VirtQueue *evt, *sts;
61 char *serial;
62
63 struct {
64 virtio_input_event event;
65 VirtQueueElement *elem;
66 } *queue;
67 uint32_t qindex, qsize;
68
69 bool active;
70 };
71
72 struct VirtIOInputClass {
73 /*< private >*/
74 VirtioDeviceClass parent;
75 /*< public >*/
76
77 DeviceRealize realize;
78 DeviceUnrealize unrealize;
79 void (*change_active)(VirtIOInput *vinput);
80 void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event);
81 };
82
83 struct VirtIOInputHID {
84 VirtIOInput parent_obj;
85 char *display;
86 uint32_t head;
87 QemuInputHandler *handler;
88 QemuInputHandlerState *hs;
89 int ledstate;
90 bool wheel_axis;
91 };
92
93 struct VirtIOInputHost {
94 VirtIOInput parent_obj;
95 char *evdev;
96 int fd;
97 };
98
99 struct VHostUserInput {
100 VirtIOInput parent_obj;
101
102 VhostUserBackend *vhost;
103 };
104
105 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
106 void virtio_input_init_config(VirtIOInput *vinput,
107 virtio_input_config *config);
108 virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
109 uint8_t select,
110 uint8_t subsel);
111 void virtio_input_add_config(VirtIOInput *vinput,
112 virtio_input_config *config);
113 void virtio_input_idstr_config(VirtIOInput *vinput,
114 uint8_t select, const char *string);
115
116 #endif /* QEMU_VIRTIO_INPUT_H */