1 #ifndef _QEMU_VIRTIO_INPUT_H 2 #define _QEMU_VIRTIO_INPUT_H 3 4 #include "ui/input.h" 5 6 /* ----------------------------------------------------------------- */ 7 /* virtio input protocol */ 8 9 #include "standard-headers/linux/virtio_ids.h" 10 #include "standard-headers/linux/virtio_input.h" 11 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; 15 16 #if defined(HOST_WORDS_BIGENDIAN) 17 # define const_le32(_x) bswap32(_x) 18 # define const_le16(_x) bswap32(_x) 19 #else 20 # define const_le32(_x) (_x) 21 # define const_le16(_x) (_x) 22 #endif 23 24 /* ----------------------------------------------------------------- */ 25 /* qemu internals */ 26 27 #define TYPE_VIRTIO_INPUT "virtio-input-device" 28 #define VIRTIO_INPUT(obj) \ 29 OBJECT_CHECK(VirtIOInput, (obj), TYPE_VIRTIO_INPUT) 30 #define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \ 31 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT) 32 #define VIRTIO_INPUT_GET_CLASS(obj) \ 33 OBJECT_GET_CLASS(VirtIOInputClass, obj, TYPE_VIRTIO_INPUT) 34 #define VIRTIO_INPUT_CLASS(klass) \ 35 OBJECT_CLASS_CHECK(VirtIOInputClass, klass, TYPE_VIRTIO_INPUT) 36 37 #define TYPE_VIRTIO_INPUT_HID "virtio-input-hid" 38 #define TYPE_VIRTIO_KEYBOARD "virtio-keyboard" 39 #define TYPE_VIRTIO_MOUSE "virtio-mouse" 40 #define TYPE_VIRTIO_TABLET "virtio-tablet" 41 42 #define VIRTIO_INPUT_HID(obj) \ 43 OBJECT_CHECK(VirtIOInputHID, (obj), TYPE_VIRTIO_INPUT_HID) 44 #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \ 45 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID) 46 47 #define DEFINE_VIRTIO_INPUT_PROPERTIES(_state, _field) \ 48 DEFINE_PROP_STRING("serial", _state, _field.serial) 49 50 typedef struct VirtIOInput VirtIOInput; 51 typedef struct VirtIOInputClass VirtIOInputClass; 52 typedef struct VirtIOInputConfig VirtIOInputConfig; 53 typedef struct VirtIOInputHID VirtIOInputHID; 54 55 struct virtio_input_conf { 56 char *serial; 57 }; 58 59 struct VirtIOInputConfig { 60 virtio_input_config config; 61 QTAILQ_ENTRY(VirtIOInputConfig) node; 62 }; 63 64 struct VirtIOInput { 65 VirtIODevice parent_obj; 66 uint8_t cfg_select; 67 uint8_t cfg_subsel; 68 uint32_t cfg_size; 69 QTAILQ_HEAD(, VirtIOInputConfig) cfg_list; 70 VirtQueue *evt, *sts; 71 virtio_input_conf input; 72 73 virtio_input_event *queue; 74 uint32_t qindex, qsize; 75 76 bool active; 77 }; 78 79 struct VirtIOInputClass { 80 /*< private >*/ 81 VirtioDeviceClass parent; 82 /*< public >*/ 83 84 DeviceRealize realize; 85 DeviceUnrealize unrealize; 86 void (*change_active)(VirtIOInput *vinput); 87 void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event); 88 }; 89 90 struct VirtIOInputHID { 91 VirtIOInput parent_obj; 92 QemuInputHandler *handler; 93 QemuInputHandlerState *hs; 94 int ledstate; 95 }; 96 97 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event); 98 void virtio_input_init_config(VirtIOInput *vinput, 99 virtio_input_config *config); 100 void virtio_input_add_config(VirtIOInput *vinput, 101 virtio_input_config *config); 102 void virtio_input_idstr_config(VirtIOInput *vinput, 103 uint8_t select, const char *string); 104 105 #endif /* _QEMU_VIRTIO_INPUT_H */ 106