1 #ifndef _QEMU_VIRTIO_INPUT_H
2 #define _QEMU_VIRTIO_INPUT_H
6 /* ----------------------------------------------------------------- */
7 /* virtio input protocol */
9 #include "standard-headers/linux/virtio_ids.h"
10 #include "standard-headers/linux/virtio_input.h"
12 typedef struct virtio_input_absinfo virtio_input_absinfo
;
13 typedef struct virtio_input_config virtio_input_config
;
14 typedef struct virtio_input_event virtio_input_event
;
16 #if defined(HOST_WORDS_BIGENDIAN)
17 # define const_le32(_x) \
18 (((_x & 0x000000ffU) << 24) | \
19 ((_x & 0x0000ff00U) << 8) | \
20 ((_x & 0x00ff0000U) >> 8) | \
21 ((_x & 0xff000000U) >> 24))
22 # define const_le16(_x) \
23 (((_x & 0x00ff) << 8) | \
26 # define const_le32(_x) (_x)
27 # define const_le16(_x) (_x)
30 /* ----------------------------------------------------------------- */
33 #define TYPE_VIRTIO_INPUT "virtio-input-device"
34 #define VIRTIO_INPUT(obj) \
35 OBJECT_CHECK(VirtIOInput, (obj), TYPE_VIRTIO_INPUT)
36 #define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \
37 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT)
38 #define VIRTIO_INPUT_GET_CLASS(obj) \
39 OBJECT_GET_CLASS(VirtIOInputClass, obj, TYPE_VIRTIO_INPUT)
40 #define VIRTIO_INPUT_CLASS(klass) \
41 OBJECT_CLASS_CHECK(VirtIOInputClass, klass, TYPE_VIRTIO_INPUT)
43 #define TYPE_VIRTIO_INPUT_HID "virtio-input-hid-device"
44 #define TYPE_VIRTIO_KEYBOARD "virtio-keyboard-device"
45 #define TYPE_VIRTIO_MOUSE "virtio-mouse-device"
46 #define TYPE_VIRTIO_TABLET "virtio-tablet-device"
48 #define VIRTIO_INPUT_HID(obj) \
49 OBJECT_CHECK(VirtIOInputHID, (obj), TYPE_VIRTIO_INPUT_HID)
50 #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
51 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
53 #define TYPE_VIRTIO_INPUT_HOST "virtio-input-host-device"
54 #define VIRTIO_INPUT_HOST(obj) \
55 OBJECT_CHECK(VirtIOInputHost, (obj), TYPE_VIRTIO_INPUT_HOST)
56 #define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
57 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
59 typedef struct VirtIOInput VirtIOInput
;
60 typedef struct VirtIOInputClass VirtIOInputClass
;
61 typedef struct VirtIOInputConfig VirtIOInputConfig
;
62 typedef struct VirtIOInputHID VirtIOInputHID
;
63 typedef struct VirtIOInputHost VirtIOInputHost
;
65 struct VirtIOInputConfig
{
66 virtio_input_config config
;
67 QTAILQ_ENTRY(VirtIOInputConfig
) node
;
71 VirtIODevice parent_obj
;
75 QTAILQ_HEAD(, VirtIOInputConfig
) cfg_list
;
79 virtio_input_event
*queue
;
80 uint32_t qindex
, qsize
;
85 struct VirtIOInputClass
{
87 VirtioDeviceClass parent
;
90 DeviceRealize realize
;
91 DeviceUnrealize unrealize
;
92 void (*change_active
)(VirtIOInput
*vinput
);
93 void (*handle_status
)(VirtIOInput
*vinput
, virtio_input_event
*event
);
96 struct VirtIOInputHID
{
97 VirtIOInput parent_obj
;
100 QemuInputHandler
*handler
;
101 QemuInputHandlerState
*hs
;
105 struct VirtIOInputHost
{
106 VirtIOInput parent_obj
;
111 void virtio_input_send(VirtIOInput
*vinput
, virtio_input_event
*event
);
112 void virtio_input_init_config(VirtIOInput
*vinput
,
113 virtio_input_config
*config
);
114 void virtio_input_add_config(VirtIOInput
*vinput
,
115 virtio_input_config
*config
);
116 void virtio_input_idstr_config(VirtIOInput
*vinput
,
117 uint8_t select
, const char *string
);
119 #endif /* _QEMU_VIRTIO_INPUT_H */