From 89b9829b844ff725b3ebc690d06a01a8d9b6c761 Mon Sep 17 00:00:00 2001 From: pixl Date: Tue, 14 Jul 2020 16:20:06 -0400 Subject: [PATCH] Fix bug where GetPairingInfo would be offset by -1. --- src/logid/backend/dj/Receiver.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/logid/backend/dj/Receiver.cpp b/src/logid/backend/dj/Receiver.cpp index 0377778..78909da 100644 --- a/src/logid/backend/dj/Receiver.cpp +++ b/src/logid/backend/dj/Receiver.cpp @@ -157,17 +157,17 @@ struct Receiver::PairingInfo { std::vector request(1); request[0] = index; - request[0] += 0x19; + request[0] += 0x1f; auto response = _hidpp10_device.getRegister(PairingInfo, request, hidpp::ReportType::Long); struct PairingInfo info{}; - info.destinationId = response[0]; - info.reportInterval = response[1]; - info.pid = response[2]; + info.destinationId = response[1]; + info.reportInterval = response[2]; + info.pid = response[4]; info.pid |= (response[3] << 8); - info.deviceType = static_cast(response[6]); + info.deviceType = static_cast(response[7]); return info; } @@ -177,7 +177,7 @@ struct Receiver::ExtendedPairingInfo { std::vector request(1); request[0] = index; - request[0] += 0x29; + request[0] += 0x2f; auto response = _hidpp10_device.getRegister(PairingInfo, request, hidpp::ReportType::Long); @@ -186,10 +186,10 @@ struct Receiver::ExtendedPairingInfo info.serialNumber = 0; for(uint8_t i = 0; i < 4; i++) - info.serialNumber |= (response[i] << 8*i); + info.serialNumber |= (response[i+1] << 8*i); for(uint8_t i = 0; i < 4; i++) - info.reportTypes[i] = response[i + 4]; + info.reportTypes[i] = response[i + 5]; uint8_t psl = response[8] & 0xf; if(psl > 0xc) @@ -204,17 +204,17 @@ std::string Receiver::getDeviceName(hidpp::DeviceIndex index) { std::vector request(1); request[0] = index; - request[0] += 0x39; + request[0] += 0x3f; auto response = _hidpp10_device.getRegister(PairingInfo, request, hidpp::ReportType::Long); - uint8_t size = response[0]; + uint8_t size = response[1]; assert(size <= 14); std::string name(size, ' '); for(std::size_t i = 0; i < size; i++) - name[i] = response[i + 1]; + name[i] = response[i + 2]; return name; }