From 3615170bd1ed6f09f878a8b538321044efddd8e0 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 24 Mar 2014 17:16:24 +0100 Subject: unifying: fix mouse report format, DRY Introduce new function to retrieve HID data for a given HIDState (if any) and fix the incompatibility between the HID format for mice as used by QEMU and the format described by the report (it contains an extra field for buttons). Signed-off-by: Peter Wu --- hw/usb/hid-logitech-dj.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'hw/usb/hid-logitech-dj.c') diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c index 6097f16822..91277b00fe 100644 --- a/hw/usb/hid-logitech-dj.c +++ b/hw/usb/hid-logitech-dj.c @@ -481,34 +481,27 @@ static void hidpp_handle_hid(USBDevice *dev, USBPacket *p) int i; msg.report_id = DJ_SHORT; + memset(hid_data, 0, sizeof(msg.payload)); /* TODO: be more fair, right now the first device always takes all events, * causing delays for other devices. */ for (i = 0; i < MAX_DEVICES; i++) { LHidDevice *hd = &s->devices[i]; - if (!hd->info.device_type) { + /* ignore empty slots and unreachable devices */ + if (!hd->info.device_type || !hd->powered_on) { continue; } - if (hd->hid->kind == HID_MOUSE) { - /* start accepting pointer events if not already */ - hid_pointer_activate(hd->hid); + if (usb_ltunify_poll_hid(hd->hid, hid_data, sizeof(msg.payload)) <= 0) { + return; } - if (!hid_has_events(hd->hid)) { - continue; - } - - hid_set_next_idle(hd->hid); - msg.device_index = i + 1; if (hd->hid->kind == HID_MOUSE) { msg.report_type = 0x02; - hid_pointer_poll(hd->hid, hid_data, sizeof(msg.payload)); } else if (hd->hid->kind == HID_KEYBOARD) { msg.report_type = 0x01; - hid_keyboard_poll(hd->hid, hid_data, sizeof(msg.payload)); } usb_dump_complete_data(s->usb_dump_state, p, data, sizeof(msg)); -- cgit v1.2.1