From c23420020f9b6f23e1f2e45cd7050ae9e17e4087 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 19 Mar 2014 15:42:49 +0100 Subject: unifying: fix device indices, fix error format Also enable processing of input reports. Now at least keyboard events work and the enumeration order is slightly more sane, yay! Signed-off-by: Peter Wu --- hw/usb/hid-logitech-dj.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c index 87291ae5b0..a1dfeb9534 100644 --- a/hw/usb/hid-logitech-dj.c +++ b/hw/usb/hid-logitech-dj.c @@ -66,10 +66,11 @@ static void hidpp_queue_error(USBLtunifyState *s, HidppMsg *msg, uint8_t err) report = &s->error_queue.reports[slot]; report->report_id = HIDPP_SHORT; report->device_index = msg->device_index; - report->sub_id = msg->hidpp_s.sub_id; - report->address = msg->hidpp_s.address; - report->value[0] = err; - report->value[1] = report->value[2] = 0; + report->sub_id = 0x8F; + report->address = msg->hidpp_s.sub_id; + report->value[0] = msg->hidpp_s.address; + report->value[1] = err; + report->value[2] = 0; } } @@ -120,7 +121,7 @@ static void hidpp_process_input_report(USBLtunifyState *s, HidppMsg msg) parms[0] = 1; /* more notifications will follow bit. */ for (i = 0; i < MAX_DEVICES; i++) { hd = &s->devices[i]; - if (!hidpp_device_available(s, i)) { + if (!hidpp_device_available(s, i + 1)) { continue; } @@ -254,7 +255,7 @@ void usb_ltunify_handle_datain_hidpp(USBDevice *dev, USBPacket *p) assert(p->ep->nr == 3); /* process input reports */ - if (s->input_queue.n > 0 && 0) { + if (s->input_queue.n > 0) { slot = s->input_queue.head; LQUEUE_INCR(s->input_queue, s->input_queue.head); s->input_queue.n--; @@ -292,7 +293,10 @@ void usb_ltunify_handle_datain_hidpp(USBDevice *dev, USBPacket *p) static void hidpp_init_device(USBLtunifyState *s, int device_index, int devtype) { - LHidDevice *hd = &s->devices[device_index]; + LHidDevice *hd; + + assert(device_index >= 1 && device_index <= MAX_DEVICES); + hd = &s->devices[device_index - 1]; memset(hd, 0, sizeof(*hd)); @@ -318,7 +322,7 @@ void hidpp_reset(USBLtunifyState *s) for (i = 0; i < MAX_DEVICES; i++) { LHidDevice *hd = &s->devices[i]; if (hd->info.device_type) { - hidpp_init_device(s, i, hd->info.device_type); + hidpp_init_device(s, i + 1, hd->info.device_type); } } } -- cgit v1.2.1