2015-11-08 16:31:18 +01:00
|
|
|
#include "LedDeviceRawHID.h"
|
|
|
|
|
|
|
|
// Use feature report HID device
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDeviceRawHID::LedDeviceRawHID(const QJsonObject &deviceConfig)
|
2016-10-08 08:14:36 +02:00
|
|
|
: ProviderHID()
|
2015-11-08 16:31:18 +01:00
|
|
|
{
|
2020-02-10 15:21:58 +01:00
|
|
|
_devConfig = deviceConfig;
|
2020-07-12 20:27:56 +02:00
|
|
|
_isDeviceReady = false;
|
|
|
|
|
|
|
|
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
_useFeature = true;
|
2015-11-08 16:31:18 +01:00
|
|
|
}
|
|
|
|
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDevice* LedDeviceRawHID::construct(const QJsonObject &deviceConfig)
|
2016-08-23 20:07:12 +02:00
|
|
|
{
|
|
|
|
return new LedDeviceRawHID(deviceConfig);
|
|
|
|
}
|
|
|
|
|
2020-02-10 15:21:58 +01:00
|
|
|
bool LedDeviceRawHID::init(const QJsonObject &deviceConfig)
|
|
|
|
{
|
2020-07-12 20:27:56 +02:00
|
|
|
bool isInitOK = false;
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
// Initialise sub-class
|
|
|
|
if ( ProviderHID::init(deviceConfig) )
|
|
|
|
{
|
|
|
|
_ledBuffer.resize(_ledRGBCount);
|
|
|
|
isInitOK = true;
|
|
|
|
}
|
2020-02-10 15:21:58 +01:00
|
|
|
return isInitOK;
|
|
|
|
}
|
|
|
|
|
2015-11-08 16:31:18 +01:00
|
|
|
int LedDeviceRawHID::write(const std::vector<ColorRgb> & ledValues)
|
|
|
|
{
|
|
|
|
// write data
|
2016-10-08 08:14:36 +02:00
|
|
|
memcpy(_ledBuffer.data(), ledValues.data(), _ledRGBCount);
|
2015-11-08 16:31:18 +01:00
|
|
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
|
|
}
|