4 #include "migration/vmstate.h"
10 typedef struct HIDPointerEvent
{
11 int32_t xdx
, ydy
; /* relative iff it's a mouse, otherwise absolute */
12 int32_t dz
, buttons_state
;
15 #define QUEUE_LENGTH 16 /* should be enough for a triple-click */
16 #define QUEUE_MASK (QUEUE_LENGTH-1u)
17 #define QUEUE_INCR(v) ((v)++, (v) &= QUEUE_MASK)
19 typedef struct HIDState HIDState
;
20 typedef void (*HIDEventFunc
)(HIDState
*s
);
22 typedef struct HIDMouseState
{
23 HIDPointerEvent queue
[QUEUE_LENGTH
];
25 QEMUPutMouseEntry
*eh_entry
;
28 typedef struct HIDKeyboardState
{
29 uint32_t keycodes
[QUEUE_LENGTH
];
41 uint32_t head
; /* index into circular queue */
47 QEMUTimer
*idle_timer
;
51 void hid_init(HIDState
*hs
, int kind
, HIDEventFunc event
);
52 void hid_reset(HIDState
*hs
);
53 void hid_free(HIDState
*hs
);
55 bool hid_has_events(HIDState
*hs
);
56 void hid_set_next_idle(HIDState
*hs
);
57 void hid_pointer_activate(HIDState
*hs
);
58 int hid_pointer_poll(HIDState
*hs
, uint8_t *buf
, int len
);
59 int hid_keyboard_poll(HIDState
*hs
, uint8_t *buf
, int len
);
60 int hid_keyboard_write(HIDState
*hs
, uint8_t *buf
, int len
);
62 extern const VMStateDescription vmstate_hid_keyboard_device
;
64 #define VMSTATE_HID_KEYBOARD_DEVICE(_field, _state) { \
65 .name = (stringify(_field)), \
66 .size = sizeof(HIDState), \
67 .vmsd = &vmstate_hid_keyboard_device, \
68 .flags = VMS_STRUCT, \
69 .offset = vmstate_offset_value(_state, _field, HIDState), \
72 extern const VMStateDescription vmstate_hid_ptr_device
;
74 #define VMSTATE_HID_POINTER_DEVICE(_field, _state) { \
75 .name = (stringify(_field)), \
76 .size = sizeof(HIDState), \
77 .vmsd = &vmstate_hid_ptr_device, \
78 .flags = VMS_STRUCT, \
79 .offset = vmstate_offset_value(_state, _field, HIDState), \
83 #endif /* QEMU_HID_H */