hyperion.ng/libsrc/leddevice/dev_hid/LedDeviceRawHID.cpp
2020-08-08 00:21:19 +02:00

34 lines
741 B
C++

#include "LedDeviceRawHID.h"
// Use feature report HID device
LedDeviceRawHID::LedDeviceRawHID(const QJsonObject &deviceConfig)
: ProviderHID(deviceConfig)
{
_useFeature = true;
}
LedDevice* LedDeviceRawHID::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceRawHID(deviceConfig);
}
bool LedDeviceRawHID::init(const QJsonObject &deviceConfig)
{
bool isInitOK = false;
// Initialise sub-class
if ( ProviderHID::init(deviceConfig) )
{
_ledBuffer.resize(_ledRGBCount);
isInitOK = true;
}
return isInitOK;
}
int LedDeviceRawHID::write(const std::vector<ColorRgb> & ledValues)
{
// write data
memcpy(_ledBuffer.data(), ledValues.data(), _ledRGBCount);
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
}