summaryrefslogtreecommitdiff
path: root/hw/usb/hid-logitech-dj.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-03-24 17:16:24 +0100
committerPeter Wu <peter@lekensteyn.nl>2014-03-24 17:16:24 +0100
commit3615170bd1ed6f09f878a8b538321044efddd8e0 (patch)
tree67f457ba2eb226a302c309845662e4e2d6276d8d /hw/usb/hid-logitech-dj.c
parentd26faef5d3e70ab8072f6387dd97b2527b8f0e39 (diff)
downloadqemu-3615170bd1ed6f09f878a8b538321044efddd8e0.tar.gz
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 <peter@lekensteyn.nl>
Diffstat (limited to 'hw/usb/hid-logitech-dj.c')
-rw-r--r--hw/usb/hid-logitech-dj.c17
1 files changed, 5 insertions, 12 deletions
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));