aboutsummaryrefslogtreecommitdiff
path: root/hw/usb-hid.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/usb-hid.c')
-rw-r--r--hw/usb-hid.c58
1 files changed, 5 insertions, 53 deletions
diff --git a/hw/usb-hid.c b/hw/usb-hid.c
index e5d57de888..ba79466401 100644
--- a/hw/usb-hid.c
+++ b/hw/usb-hid.c
@@ -45,8 +45,6 @@
typedef struct USBHIDState {
USBDevice dev;
HIDState hid;
- void *datain_opaque;
- void (*datain)(void *);
} USBHIDState;
enum {
@@ -362,10 +360,6 @@ static void usb_hid_changed(HIDState *hs)
{
USBHIDState *us = container_of(hs, USBHIDState, hid);
- if (us->datain) {
- us->datain(us->datain_opaque);
- }
-
usb_wakeup(&us->dev);
}
@@ -454,6 +448,9 @@ static int usb_hid_handle_control(USBDevice *dev, USBPacket *p,
case SET_IDLE:
hs->idle = (uint8_t) (value >> 8);
hid_set_next_idle(hs, qemu_get_clock_ns(vm_clock));
+ if (hs->kind == HID_MOUSE || hs->kind == HID_TABLET) {
+ hid_pointer_activate(hs);
+ }
ret = 0;
break;
default:
@@ -530,49 +527,13 @@ static int usb_keyboard_initfn(USBDevice *dev)
return usb_hid_initfn(dev, HID_KEYBOARD);
}
-void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *))
-{
- USBHIDState *s = (USBHIDState *)dev;
-
- s->datain_opaque = opaque;
- s->datain = datain;
-}
-
-static int usb_hid_post_load(void *opaque, int version_id)
-{
- USBHIDState *s = opaque;
-
- if (s->hid.idle) {
- hid_set_next_idle(&s->hid, qemu_get_clock_ns(vm_clock));
- }
- return 0;
-}
-
-static const VMStateDescription vmstate_usb_ptr_queue = {
- .name = "usb-ptr-queue",
- .version_id = 1,
- .minimum_version_id = 1,
- .fields = (VMStateField []) {
- VMSTATE_INT32(xdx, HIDPointerEvent),
- VMSTATE_INT32(ydy, HIDPointerEvent),
- VMSTATE_INT32(dz, HIDPointerEvent),
- VMSTATE_INT32(buttons_state, HIDPointerEvent),
- VMSTATE_END_OF_LIST()
- }
-};
static const VMStateDescription vmstate_usb_ptr = {
.name = "usb-ptr",
.version_id = 1,
.minimum_version_id = 1,
- .post_load = usb_hid_post_load,
.fields = (VMStateField []) {
VMSTATE_USB_DEVICE(dev, USBHIDState),
- VMSTATE_STRUCT_ARRAY(hid.ptr.queue, USBHIDState, QUEUE_LENGTH, 0,
- vmstate_usb_ptr_queue, HIDPointerEvent),
- VMSTATE_UINT32(hid.head, USBHIDState),
- VMSTATE_UINT32(hid.n, USBHIDState),
- VMSTATE_INT32(hid.protocol, USBHIDState),
- VMSTATE_UINT8(hid.idle, USBHIDState),
+ VMSTATE_HID_POINTER_DEVICE(hid, USBHIDState),
VMSTATE_END_OF_LIST()
}
};
@@ -581,18 +542,9 @@ static const VMStateDescription vmstate_usb_kbd = {
.name = "usb-kbd",
.version_id = 1,
.minimum_version_id = 1,
- .post_load = usb_hid_post_load,
.fields = (VMStateField []) {
VMSTATE_USB_DEVICE(dev, USBHIDState),
- VMSTATE_UINT32_ARRAY(hid.kbd.keycodes, USBHIDState, QUEUE_LENGTH),
- VMSTATE_UINT32(hid.head, USBHIDState),
- VMSTATE_UINT32(hid.n, USBHIDState),
- VMSTATE_UINT16(hid.kbd.modifiers, USBHIDState),
- VMSTATE_UINT8(hid.kbd.leds, USBHIDState),
- VMSTATE_UINT8_ARRAY(hid.kbd.key, USBHIDState, 16),
- VMSTATE_INT32(hid.kbd.keys, USBHIDState),
- VMSTATE_INT32(hid.protocol, USBHIDState),
- VMSTATE_UINT8(hid.idle, USBHIDState),
+ VMSTATE_HID_KEYBOARD_DEVICE(hid, USBHIDState),
VMSTATE_END_OF_LIST()
}
};