From 7beab627e87ee378969fd46b7c799de696fc500a Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 31 Mar 2014 12:41:55 +0200 Subject: unifying: fix Pairing info register Fix LSB/MSB mix-up, fix incorrect matching against request type. Signed-off-by: Peter Wu --- hw/usb/hid-logitech-dj.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'hw') diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c index 58d4aecc59..0728be47f6 100644 --- a/hw/usb/hid-logitech-dj.c +++ b/hw/usb/hid-logitech-dj.c @@ -259,28 +259,29 @@ static void hidpp_process_receiver_report(USBLtunifyState *s, HidppMsg *msg) if ((parms[0] >> 4) >= 2 && (parms[0] >> 4) <= 4 && hidpp_device_available(s, 1 + (parms[0] & 0xF))) { LHidDevice *hd = &s->devices[parms[0] & 0xF]; + uint8_t nn = parms[0] & 0xf0; ml->report_id = HIDPP_LONG; memset(parms + 1, 0, sizeof(ml->value) - 1); - if (parms[0] & 0x20) { + if (nn == 0x20) { /* Unifying Device pairing information */ parms[1] = 0x42; /* Destination ID (???) */ parms[2] = hd->report_interval; - parms[3] = (uint8_t) hd->info.wireless_pid; - parms[4] = (uint8_t) (hd->info.wireless_pid >> 8); + parms[3] = hd->info.wireless_pid >> 8; + parms[4] = (uint8_t) hd->info.wireless_pid; parms[7] = hd->info.device_type; - } else if (parms[0] & 0x30) { + } else if (nn == 0x30) { /* Unifying Device extended pairing info */ - parms[1] = (uint8_t) hd->info.serial; - parms[2] = (uint8_t) (hd->info.serial >> 8); - parms[3] = (uint8_t) (hd->info.serial >> 16); - parms[4] = (uint8_t) (hd->info.serial >> 24); - parms[5] = (uint8_t) hd->info.report_types; - parms[6] = (uint8_t) (hd->info.report_types >> 8); - parms[7] = (uint8_t) (hd->info.report_types >> 16); - parms[8] = (uint8_t) (hd->info.report_types >> 24); + parms[1] = hd->info.serial >> 24; + parms[2] = (uint8_t) (hd->info.serial >> 16); + parms[3] = (uint8_t) (hd->info.serial >> 8); + parms[4] = (uint8_t) hd->info.serial; + parms[5] = hd->info.report_types >> 24; + parms[6] = (uint8_t) (hd->info.report_types >> 16); + parms[7] = (uint8_t) (hd->info.report_types >> 8); + parms[8] = (uint8_t) hd->info.report_types; parms[9] = hd->info.usability_info; - } else if (parms[0] & 0x40) { + } else if (nn == 0x40) { /* Unifying Device name */ parms[1] = strlen(hd->info.name); memcpy(parms + 2, hd->info.name, parms[1]); -- cgit v1.2.1