qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

virtio-input.h (4125B)


      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 
     32 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHID, VIRTIO_INPUT_HID)
     33 #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
     34         OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
     35 
     36 #define TYPE_VIRTIO_INPUT_HOST   "virtio-input-host-device"
     37 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHost, VIRTIO_INPUT_HOST)
     38 #define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
     39         OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
     40 
     41 #define TYPE_VHOST_USER_INPUT   "vhost-user-input"
     42 OBJECT_DECLARE_SIMPLE_TYPE(VHostUserInput, VHOST_USER_INPUT)
     43 #define VHOST_USER_INPUT_GET_PARENT_CLASS(obj)             \
     44     OBJECT_GET_PARENT_CLASS(obj, TYPE_VHOST_USER_INPUT)
     45 
     46 typedef struct VirtIOInputConfig VirtIOInputConfig;
     47 
     48 struct VirtIOInputConfig {
     49     virtio_input_config               config;
     50     QTAILQ_ENTRY(VirtIOInputConfig)   node;
     51 };
     52 
     53 struct VirtIOInput {
     54     VirtIODevice                      parent_obj;
     55     uint8_t                           cfg_select;
     56     uint8_t                           cfg_subsel;
     57     uint32_t                          cfg_size;
     58     QTAILQ_HEAD(, VirtIOInputConfig)  cfg_list;
     59     VirtQueue                         *evt, *sts;
     60     char                              *serial;
     61 
     62     struct {
     63         virtio_input_event event;
     64         VirtQueueElement *elem;
     65     }                                 *queue;
     66     uint32_t                          qindex, qsize;
     67 
     68     bool                              active;
     69 };
     70 
     71 struct VirtIOInputClass {
     72     /*< private >*/
     73     VirtioDeviceClass parent;
     74     /*< public >*/
     75 
     76     DeviceRealize realize;
     77     DeviceUnrealize unrealize;
     78     void (*change_active)(VirtIOInput *vinput);
     79     void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event);
     80 };
     81 
     82 struct VirtIOInputHID {
     83     VirtIOInput                       parent_obj;
     84     char                              *display;
     85     uint32_t                          head;
     86     QemuInputHandler                  *handler;
     87     QemuInputHandlerState             *hs;
     88     int                               ledstate;
     89     bool                              wheel_axis;
     90 };
     91 
     92 struct VirtIOInputHost {
     93     VirtIOInput                       parent_obj;
     94     char                              *evdev;
     95     int                               fd;
     96 };
     97 
     98 struct VHostUserInput {
     99     VirtIOInput                       parent_obj;
    100 
    101     VhostUserBackend                  *vhost;
    102 };
    103 
    104 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
    105 void virtio_input_init_config(VirtIOInput *vinput,
    106                               virtio_input_config *config);
    107 virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
    108                                               uint8_t select,
    109                                               uint8_t subsel);
    110 void virtio_input_add_config(VirtIOInput *vinput,
    111                              virtio_input_config *config);
    112 void virtio_input_idstr_config(VirtIOInput *vinput,
    113                                uint8_t select, const char *string);
    114 
    115 #endif /* QEMU_VIRTIO_INPUT_H */