LedDeviceRawHID.cpp 741 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "LedDeviceRawHID.h"
  2. // Use feature report HID device
  3. LedDeviceRawHID::LedDeviceRawHID(const QJsonObject &deviceConfig)
  4. : ProviderHID(deviceConfig)
  5. {
  6. _useFeature = true;
  7. }
  8. LedDevice* LedDeviceRawHID::construct(const QJsonObject &deviceConfig)
  9. {
  10. return new LedDeviceRawHID(deviceConfig);
  11. }
  12. bool LedDeviceRawHID::init(const QJsonObject &deviceConfig)
  13. {
  14. bool isInitOK = false;
  15. // Initialise sub-class
  16. if ( ProviderHID::init(deviceConfig) )
  17. {
  18. _ledBuffer.resize(_ledRGBCount);
  19. isInitOK = true;
  20. }
  21. return isInitOK;
  22. }
  23. int LedDeviceRawHID::write(const std::vector<ColorRgb> & ledValues)
  24. {
  25. // write data
  26. memcpy(_ledBuffer.data(), ledValues.data(), _ledRGBCount);
  27. return writeBytes(_ledBuffer.size(), _ledBuffer.data());
  28. }