Print version number of device 1 on each raw dev.

Only works on HID++ >=2.0 so far. Also solves a race condition where
the wrong response can be sent to a request.
This commit is contained in:
pixl
2020-06-18 01:34:25 -04:00
parent 14d07c220e
commit c21a923ab2
19 changed files with 518 additions and 123 deletions
+15 -8
View File
@@ -96,15 +96,15 @@ const char *Report::InvalidReportLength::what() const noexcept
Report::Report(Report::Type type, DeviceIndex device_index,
uint8_t feature_index, uint8_t function, uint8_t sw_id)
{
assert(!(function & functionMask));
assert(!(sw_id & swIdMask));
assert(function <= functionMask);
assert(sw_id <= swIdMask);
switch(type)
{
case Short:
case Type::Short:
_data.resize(HeaderLength + ShortParamLength);
break;
case Long:
case Type::Long:
_data.resize(HeaderLength + LongParamLength);
break;
default:
@@ -123,10 +123,10 @@ Report::Report(const std::vector<uint8_t>& data)
switch(_data[Offset::Type])
{
case Short:
case Type::Short:
_data.resize(HeaderLength + ShortParamLength);
break;
case Long:
case Type::Long:
_data.resize(HeaderLength + LongParamLength);
break;
default:
@@ -138,10 +138,10 @@ void Report::setType(Report::Type type)
{
switch(type)
{
case Short:
case Type::Short:
_data.resize(HeaderLength + ShortParamLength);
break;
case Long:
case Type::Long:
_data.resize(HeaderLength + LongParamLength);
break;
default:
@@ -158,3 +158,10 @@ void Report::setParams(const std::vector<uint8_t>& _params)
for(std::size_t i = 0; i < _params.size(); i++)
_data[Offset::Parameters + i] = _params[i];
}
bool Report::isError20(Report::hidpp20_error* error)
{
if(_data[Offset::Type] != Type::Long ||
_data[Offset::Feature] != 0xff)
return false;
}