Refer to receiver from receiver devices
This commit is contained in:
@@ -65,7 +65,8 @@ Device::Device(std::shared_ptr<raw::RawDevice> raw_device, DeviceIndex index) :
|
||||
|
||||
Device::Device(std::shared_ptr<dj::Receiver> receiver,
|
||||
hidpp::DeviceConnectionEvent event) :
|
||||
_raw_device (receiver->rawDevice()), _index (event.index)
|
||||
_raw_device (receiver->rawDevice()), _receiver (receiver),
|
||||
_path (receiver->rawDevice()->hidrawPath()), _index (event.index)
|
||||
{
|
||||
// Device will throw an error soon, just do it now
|
||||
if(!event.linkEstablished)
|
||||
@@ -78,6 +79,15 @@ Device::Device(std::shared_ptr<dj::Receiver> receiver,
|
||||
_init();
|
||||
}
|
||||
|
||||
Device::Device(std::shared_ptr<dj::Receiver> receiver,
|
||||
DeviceIndex index) : _raw_device (receiver->rawDevice()),
|
||||
_receiver (receiver), _path (receiver->rawDevice()->hidrawPath()),
|
||||
_index (index)
|
||||
{
|
||||
_pid = receiver->getPairingInfo(_index).pid;
|
||||
_init();
|
||||
}
|
||||
|
||||
std::string Device::devicePath() const
|
||||
{
|
||||
return _path;
|
||||
@@ -125,7 +135,16 @@ void Device::_init()
|
||||
_name = _raw_device->name();
|
||||
}
|
||||
} else {
|
||||
_name = _receiver->getDeviceName(_index);
|
||||
if(std::get<0>(_version) >= 2) {
|
||||
try {
|
||||
hidpp20::EssentialDeviceName deviceName(this);
|
||||
_name = deviceName.getName();
|
||||
} catch(hidpp20::UnsupportedFeature &e) {
|
||||
_name = _receiver->getDeviceName(_index);
|
||||
}
|
||||
} else {
|
||||
_name = _receiver->getDeviceName(_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -62,10 +62,12 @@ namespace hidpp
|
||||
};
|
||||
|
||||
explicit Device(const std::string& path, DeviceIndex index);
|
||||
explicit Device(std::shared_ptr<raw::RawDevice> raw_device,
|
||||
Device(std::shared_ptr<raw::RawDevice> raw_device,
|
||||
DeviceIndex index);
|
||||
explicit Device(std::shared_ptr<dj::Receiver> receiver,
|
||||
Device(std::shared_ptr<dj::Receiver> receiver,
|
||||
hidpp::DeviceConnectionEvent event);
|
||||
Device(std::shared_ptr<dj::Receiver> receiver,
|
||||
DeviceIndex index);
|
||||
~Device();
|
||||
|
||||
std::string devicePath() const;
|
||||
|
@@ -36,6 +36,12 @@ Device::Device(std::shared_ptr<raw::RawDevice> raw_dev,
|
||||
assert(version() == std::make_tuple(1, 0));
|
||||
}
|
||||
|
||||
Device::Device(std::shared_ptr<dj::Receiver> receiver, hidpp::DeviceIndex index)
|
||||
: hidpp::Device(receiver, index)
|
||||
{
|
||||
assert(version() == std::make_tuple(1, 0));
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Device::getRegister(uint8_t address,
|
||||
const std::vector<uint8_t>& params, hidpp::Report::Type type)
|
||||
{
|
||||
|
@@ -31,6 +31,8 @@ namespace hidpp10
|
||||
Device(const std::string& path, hidpp::DeviceIndex index);
|
||||
Device(std::shared_ptr<raw::RawDevice> raw_dev,
|
||||
hidpp::DeviceIndex index);
|
||||
Device(std::shared_ptr<dj::Receiver> receiver,
|
||||
hidpp::DeviceIndex index);
|
||||
|
||||
std::vector<uint8_t> getRegister(uint8_t address,
|
||||
const std::vector<uint8_t>& params, hidpp::Report::Type type);
|
||||
|
@@ -35,6 +35,12 @@ Device::Device(std::shared_ptr<raw::RawDevice> raw_device, hidpp::DeviceIndex in
|
||||
assert(std::get<0>(version()) >= 2);
|
||||
}
|
||||
|
||||
Device::Device(std::shared_ptr<dj::Receiver> receiver, hidpp::DeviceIndex index)
|
||||
: hidpp::Device(receiver, index)
|
||||
{
|
||||
assert(std::get<0>(version()) >= 2);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Device::callFunction(uint8_t feature_index,
|
||||
uint8_t function, std::vector<uint8_t>& params)
|
||||
{
|
||||
|
@@ -30,6 +30,8 @@ namespace hidpp20 {
|
||||
public:
|
||||
Device(std::string path, hidpp::DeviceIndex index);
|
||||
Device(std::shared_ptr<raw::RawDevice> raw_device, hidpp::DeviceIndex index);
|
||||
Device(std::shared_ptr<dj::Receiver> receiver, hidpp::DeviceIndex
|
||||
index);
|
||||
|
||||
std::vector<uint8_t> callFunction(uint8_t feature_index,
|
||||
uint8_t function,
|
||||
|
Reference in New Issue
Block a user