OpenRGB/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2SoftwareController.cpp
Chris 3a71b76075 Initial commit for the Corsair MM700 to resolve #1718
+ Adding CorsairPeripheralV2Controller base class
+ Adding CorsairPeripheralV2Devices.h metadata file
+ Renaming CorsairK55RGBPROController to CorsairPeripheralV2SWController
+ Adjusting CorsairPeripheralV2SWController to accomodate base class changes
+ Renaming RGBController_CorsairK55RGBPRO to RGBController_CorsairV2SW
+ Adjusting RGBController_CorsairV2SW to handle device set up from meta data
+ Adding PID `0x1B9B` and registering detector in CorsairPeripheralV2ControllerDetect.cpp
2022-08-15 12:43:49 +10:00

46 lines
1.6 KiB
C++

/*---------------------------------------------------------------------*\
| CorsairPeripheralV2SoftwareController.cpp |
| |
| Common driver for the newer Corsair peripherals that use |
| the `08` based USB protocol |
| |
| Chris M (Dr_No) 11 Aug 2022 |
\*---------------------------------------------------------------------*/
#pragma once
#include "LogManager.h"
#include "CorsairPeripheralV2SoftwareController.h"
CorsairPeripheralV2SWController::CorsairPeripheralV2SWController(hid_device* dev_handle, const char* path, std::string name, uint16_t pid) : CorsairPeripheralV2Controller(dev_handle, path, name, pid)
{
SetRenderMode(CORSAIR_V2_MODE_SW);
LightingControl(0x5F, 0x00);
}
CorsairPeripheralV2SWController::~CorsairPeripheralV2SWController()
{
}
void CorsairPeripheralV2SWController::SetLedsDirect(std::vector<RGBColor>colors)
{
uint16_t count = colors.size();
uint16_t green = count;
uint16_t blue = count * 2;
uint16_t length = count * 3;
uint8_t* buffer = new uint8_t[length];
memset(buffer, 0, length);
for(std::size_t i = 0; i < count; i++)
{
RGBColor color = colors[i];
buffer[i] = RGBGetRValue(color);
buffer[green + i] = RGBGetGValue(color);
buffer[blue + i] = RGBGetBValue(color);
}
SetLEDs(buffer, length);
delete[] buffer;
}