Fully implement Root and virutal Feature class

This commit is contained in:
pixl
2020-06-18 02:22:05 -04:00
parent c21a923ab2
commit cc025d3b96
4 changed files with 34 additions and 14 deletions
+17 -7
View File
@@ -1,13 +1,15 @@
#include "Feature.h"
#include "feature_defs.h"
#include "features/Root.h"
using namespace logid::backend::hidpp20;
const char* Feature::UnsupportedFeature::what() const noexcept
const char* UnsupportedFeature::what() const noexcept
{
return "Unsupported feature";
}
uint16_t Feature::UnsupportedFeature::code() const noexcept
uint16_t UnsupportedFeature::code() const noexcept
{
return _f_id;
}
@@ -17,12 +19,20 @@ std::vector<uint8_t> Feature::callFunction(uint8_t function_id, std::vector<uint
return _device->callFunction(_index, function_id, params);
}
Feature::Feature(Device* dev, uint16_t _id) : _device (dev), _index (0xff)
Feature::Feature(Device* dev, uint16_t _id) : _device (dev)
{
///TODO: Set index
}
_index = hidpp20::FeatureID::ROOT;
Feature::Feature(Device* dev, uint8_t _index) : _device (dev), _index (_index)
{
if(_id)
{
std::vector<uint8_t> getFunc_req(2);
getFunc_req[0] = _id & 0xff;
getFunc_req[1] = (_id >> 8) & 0xff;
auto getFunc_resp = this->callFunction(Root::GetFeature, getFunc_req);
_index = getFunc_resp[0];
// 0 if not found
if(!_index)
throw UnsupportedFeature(_id);
}
}