Fix bug where GetPairingInfo would be offset by -1.
This commit is contained in:
parent
d3d4a2755a
commit
89b9829b84
|
@ -157,17 +157,17 @@ struct Receiver::PairingInfo
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> request(1);
|
std::vector<uint8_t> request(1);
|
||||||
request[0] = index;
|
request[0] = index;
|
||||||
request[0] += 0x19;
|
request[0] += 0x1f;
|
||||||
|
|
||||||
auto response = _hidpp10_device.getRegister(PairingInfo, request,
|
auto response = _hidpp10_device.getRegister(PairingInfo, request,
|
||||||
hidpp::ReportType::Long);
|
hidpp::ReportType::Long);
|
||||||
|
|
||||||
struct PairingInfo info{};
|
struct PairingInfo info{};
|
||||||
info.destinationId = response[0];
|
info.destinationId = response[1];
|
||||||
info.reportInterval = response[1];
|
info.reportInterval = response[2];
|
||||||
info.pid = response[2];
|
info.pid = response[4];
|
||||||
info.pid |= (response[3] << 8);
|
info.pid |= (response[3] << 8);
|
||||||
info.deviceType = static_cast<DeviceType::DeviceType>(response[6]);
|
info.deviceType = static_cast<DeviceType::DeviceType>(response[7]);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ struct Receiver::ExtendedPairingInfo
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> request(1);
|
std::vector<uint8_t> request(1);
|
||||||
request[0] = index;
|
request[0] = index;
|
||||||
request[0] += 0x29;
|
request[0] += 0x2f;
|
||||||
|
|
||||||
auto response = _hidpp10_device.getRegister(PairingInfo, request,
|
auto response = _hidpp10_device.getRegister(PairingInfo, request,
|
||||||
hidpp::ReportType::Long);
|
hidpp::ReportType::Long);
|
||||||
|
@ -186,10 +186,10 @@ struct Receiver::ExtendedPairingInfo
|
||||||
|
|
||||||
info.serialNumber = 0;
|
info.serialNumber = 0;
|
||||||
for(uint8_t i = 0; i < 4; i++)
|
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++)
|
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;
|
uint8_t psl = response[8] & 0xf;
|
||||||
if(psl > 0xc)
|
if(psl > 0xc)
|
||||||
|
@ -204,17 +204,17 @@ std::string Receiver::getDeviceName(hidpp::DeviceIndex index)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> request(1);
|
std::vector<uint8_t> request(1);
|
||||||
request[0] = index;
|
request[0] = index;
|
||||||
request[0] += 0x39;
|
request[0] += 0x3f;
|
||||||
|
|
||||||
auto response = _hidpp10_device.getRegister(PairingInfo, request,
|
auto response = _hidpp10_device.getRegister(PairingInfo, request,
|
||||||
hidpp::ReportType::Long);
|
hidpp::ReportType::Long);
|
||||||
|
|
||||||
uint8_t size = response[0];
|
uint8_t size = response[1];
|
||||||
assert(size <= 14);
|
assert(size <= 14);
|
||||||
|
|
||||||
std::string name(size, ' ');
|
std::string name(size, ' ');
|
||||||
for(std::size_t i = 0; i < size; i++)
|
for(std::size_t i = 0; i < size; i++)
|
||||||
name[i] = response[i + 1];
|
name[i] = response[i + 2];
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user