Rework CoolerMaster ARGB controller so that it doesn't create multiple devices and prepare it for per-zone mode support
This commit is contained in:
@@ -12,16 +12,27 @@
|
||||
#include "CMARGBController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
CMARGBController::CMARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx, std::shared_ptr<std::mutex> cm_mutex)
|
||||
/*---------------------------------------------------------*\
|
||||
| Map to convert port index to port ID used in protocol |
|
||||
\*---------------------------------------------------------*/
|
||||
static unsigned char cm_argb_port_index_to_id[5] =
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
zone_index = _zone_idx;
|
||||
mutex_ptr = cm_mutex;
|
||||
CM_ARGB_PORT_ARGB_1,
|
||||
CM_ARGB_PORT_ARGB_2,
|
||||
CM_ARGB_PORT_ARGB_3,
|
||||
CM_ARGB_PORT_ARGB_4,
|
||||
CM_ARGB_PORT_RGB
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device name from HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
CMARGBController::CMARGBController(hid_device* dev_handle, char *path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get device name from HID manufacturer and product |
|
||||
| strings |
|
||||
\*-----------------------------------------------------*/
|
||||
wchar_t name_string[HID_MAX_STR];
|
||||
|
||||
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
|
||||
@@ -29,57 +40,11 @@ CMARGBController::CMARGBController(hid_device* dev_handle, char *_path, unsigned
|
||||
|
||||
hid_get_product_string(dev, name_string, HID_MAX_STR);
|
||||
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
|
||||
|
||||
GetStatus();
|
||||
}
|
||||
|
||||
CMARGBController::~CMARGBController()
|
||||
{
|
||||
if(mutex_ptr.use_count() <= 1)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
void CMARGBController::GetStatus()
|
||||
{
|
||||
unsigned char buffer[CM_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x0B, 0x01 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
int rgb_offset = 0;
|
||||
int zone;
|
||||
|
||||
if (argb_header_data[zone_index].digital)
|
||||
{
|
||||
zone = argb_header_data[zone_index].header;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B;
|
||||
}
|
||||
else
|
||||
{
|
||||
zone = 0x00;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0A;
|
||||
rgb_offset = 1;
|
||||
}
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Guard the writes to the controller until the |
|
||||
| for loop has completed to avoid collisons |
|
||||
\*---------------------------------------------*/
|
||||
std::lock_guard<std::mutex> guard(*mutex_ptr);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| If this is the group then just return the first status |
|
||||
\*---------------------------------------------------------*/
|
||||
buffer[CM_ARGB_ZONE_BYTE] = ( zone > 0x08 ) ? 0x01 : zone;
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
current_mode = buffer[4 - rgb_offset];
|
||||
bool_random = ( buffer[5 - rgb_offset] == 0x00 );
|
||||
current_speed = buffer[6 - rgb_offset];
|
||||
current_brightness = buffer[7 - rgb_offset];
|
||||
current_red = buffer[8 - rgb_offset];
|
||||
current_green = buffer[9 - rgb_offset];
|
||||
current_blue = buffer[10 - rgb_offset];
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string CMARGBController::GetDeviceName()
|
||||
@@ -87,6 +52,33 @@ std::string CMARGBController::GetDeviceName()
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
std::string CMARGBController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string CMARGBController::GetVersion()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| This device uses the serial value to determine the |
|
||||
| version. It does not report a proper unique serial. |
|
||||
\*-----------------------------------------------------*/
|
||||
std::string serial_string = GetSerial();
|
||||
|
||||
if(serial_string == CM_ARGB_FW0023)
|
||||
{
|
||||
return("0023");
|
||||
}
|
||||
else if(serial_string == CM_ARGB_FW0028)
|
||||
{
|
||||
return("0028");
|
||||
}
|
||||
else
|
||||
{
|
||||
return("Unsupported");
|
||||
}
|
||||
}
|
||||
|
||||
std::string CMARGBController::GetSerial()
|
||||
{
|
||||
wchar_t serial_string[HID_MAX_STR];
|
||||
@@ -100,118 +92,187 @@ std::string CMARGBController::GetSerial()
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string CMARGBController::GetLocation()
|
||||
void CMARGBController::GetPortStatus
|
||||
(
|
||||
unsigned char port_idx,
|
||||
unsigned char* port_mode,
|
||||
unsigned char* port_speed,
|
||||
unsigned char* port_brightness,
|
||||
bool* port_random,
|
||||
unsigned char* port_red,
|
||||
unsigned char* port_green,
|
||||
unsigned char* port_blue
|
||||
)
|
||||
{
|
||||
return("HID: " + location);
|
||||
unsigned char buffer[CM_ARGB_PACKET_SIZE] = {0x00, 0x80, 0x0B, 0x01};
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
int rgb_offset = 0;
|
||||
int zone;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| RGB port is handled differently from ARGB ports |
|
||||
\*-----------------------------------------------------*/
|
||||
if(cm_argb_port_index_to_id[port_idx] != CM_ARGB_PORT_RGB)
|
||||
{
|
||||
zone = cm_argb_port_index_to_id[port_idx];
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B;
|
||||
}
|
||||
else
|
||||
{
|
||||
zone = 0x00;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0A;
|
||||
rgb_offset = 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If this is the group then just return the first |
|
||||
| status |
|
||||
\*-----------------------------------------------------*/
|
||||
buffer[CM_ARGB_ZONE_BYTE] = ( zone > 0x08 ) ? 0x01 : zone;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the command and read the response |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Read data out of response |
|
||||
\*-----------------------------------------------------*/
|
||||
*port_mode = buffer[4 - rgb_offset];
|
||||
*port_random = (buffer[5 - rgb_offset] == 0x00);
|
||||
*port_speed = buffer[6 - rgb_offset];
|
||||
*port_brightness = buffer[7 - rgb_offset];
|
||||
*port_red = buffer[8 - rgb_offset];
|
||||
*port_green = buffer[9 - rgb_offset];
|
||||
*port_blue = buffer[10 - rgb_offset];
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetZoneIndex()
|
||||
void CMARGBController::SetPortLEDCount(unsigned char port_idx, unsigned char led_count)
|
||||
{
|
||||
return(zone_index);
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetMode()
|
||||
{
|
||||
return(current_mode);
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetLedRed()
|
||||
{
|
||||
return(current_red);
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetLedGreen()
|
||||
{
|
||||
return(current_green);
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetLedBlue()
|
||||
{
|
||||
return(current_blue);
|
||||
}
|
||||
|
||||
unsigned char CMARGBController::GetLedSpeed()
|
||||
{
|
||||
return(current_speed);
|
||||
}
|
||||
|
||||
bool CMARGBController::GetRandomColours()
|
||||
{
|
||||
return(bool_random);
|
||||
}
|
||||
|
||||
void CMARGBController::SetLedCount(int zone, int led_count)
|
||||
{
|
||||
unsigned char buffer[CM_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x0D, 0x02 };
|
||||
unsigned char buffer[CM_ARGB_PACKET_SIZE] = {0x00, 0x80, 0x0D, 0x02};
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
buffer[CM_ARGB_ZONE_BYTE] = zone;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = cm_argb_port_index_to_id[port_idx];
|
||||
buffer[CM_ARGB_MODE_BYTE] = led_count;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = (0x0F - led_count > 0) ? 0x0F - led_count : 0x01;
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Guard the writes to the controller until the |
|
||||
| for loop has completed to avoid collisons |
|
||||
\*---------------------------------------------*/
|
||||
std::lock_guard<std::mutex> guard(*mutex_ptr);
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = 1;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the command |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
|
||||
void CMARGBController::SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, RGBColor colour, bool random_colours)
|
||||
void CMARGBController::SetPortMode
|
||||
(
|
||||
unsigned char port_idx,
|
||||
unsigned char port_mode,
|
||||
unsigned char port_speed,
|
||||
unsigned char port_brightness,
|
||||
bool port_random,
|
||||
unsigned char port_red,
|
||||
unsigned char port_green,
|
||||
unsigned char port_blue
|
||||
)
|
||||
{
|
||||
bool needs_update = !( (current_mode == mode) && (current_speed == speed) && (current_brightness == brightness) && (ToRGBColor(current_red, current_green, current_blue) == colour));
|
||||
unsigned char buffer[CM_ARGB_PACKET_SIZE] = {0x00};
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
bool boolARGB_header = (cm_argb_port_index_to_id[port_idx] != CM_ARGB_PORT_RGB);
|
||||
bool boolPassthru = (port_mode == CM_ARGB_MODE_PASSTHRU) || (port_mode == CM_RGB_MODE_PASSTHRU);
|
||||
bool boolDirect = (port_mode == CM_ARGB_MODE_DIRECT);
|
||||
unsigned char function = boolPassthru ? (boolARGB_header ? 0x02 : 0x04) : (boolARGB_header ? 0x01 : 0x03);
|
||||
buffer[CM_ARGB_REPORT_BYTE] = 0x80;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x01;
|
||||
|
||||
if (needs_update)
|
||||
if(boolDirect)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_brightness = brightness;
|
||||
current_red = RGBGetRValue(colour);
|
||||
current_green = RGBGetGValue(colour);
|
||||
current_blue = RGBGetBValue(colour);
|
||||
bool_random = random_colours;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = 0x01;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = 0x02;
|
||||
|
||||
SendUpdate();
|
||||
/*-------------------------------------------------*\
|
||||
| Send the command |
|
||||
\*-------------------------------------------------*/
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Direct mode is now set up and no other mode |
|
||||
| packet is required |
|
||||
\*-------------------------------------------------*/
|
||||
return;
|
||||
}
|
||||
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = function;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the command |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| ARGB ports send command 0x0B, RGB port sends 0x04 |
|
||||
\*-----------------------------------------------------*/
|
||||
if(boolARGB_header)
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = cm_argb_port_index_to_id[port_idx];
|
||||
buffer[CM_ARGB_MODE_BYTE] = port_mode;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = port_random ? 0x00 : 0x10;
|
||||
buffer[CM_ARGB_SPEED_BYTE] = port_speed;
|
||||
buffer[CM_ARGB_BRIGHTNESS_BYTE] = port_brightness;
|
||||
buffer[CM_ARGB_RED_BYTE] = port_red;
|
||||
buffer[CM_ARGB_GREEN_BYTE] = port_green;
|
||||
buffer[CM_ARGB_BLUE_BYTE] = port_blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = boolPassthru ? 0x01 : 0x04;
|
||||
buffer[CM_ARGB_MODE_BYTE + CM_RGB_OFFSET] = port_mode;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE + CM_RGB_OFFSET] = port_random ? 0x00 : 0x10;
|
||||
buffer[CM_ARGB_SPEED_BYTE + CM_RGB_OFFSET] = port_speed;
|
||||
buffer[CM_ARGB_BRIGHTNESS_BYTE + CM_RGB_OFFSET] = port_brightness;
|
||||
buffer[CM_ARGB_RED_BYTE + CM_RGB_OFFSET] = port_red;
|
||||
buffer[CM_ARGB_GREEN_BYTE + CM_RGB_OFFSET] = port_green;
|
||||
buffer[CM_ARGB_BLUE_BYTE + CM_RGB_OFFSET] = port_blue;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send the command and wait for response |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
|
||||
void CMARGBController::SetLedsDirect(RGBColor *led_colours, unsigned int led_count)
|
||||
void CMARGBController::SetPortLEDsDirect(unsigned char port_idx, RGBColor *led_colours, unsigned int led_count)
|
||||
{
|
||||
const unsigned char buffer_size = CM_ARGB_PACKET_SIZE;
|
||||
unsigned char buffer[buffer_size] = { 0x00, 0x00, 0x07, 0x02 };
|
||||
unsigned char packet_count = 0;
|
||||
std::vector<uint8_t> colours;
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Set up the RGB triplets to send |
|
||||
\*---------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up the RGB triplets to send |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int i = 0; i < led_count; i++)
|
||||
{
|
||||
RGBColor colour = led_colours[i];
|
||||
|
||||
colours.push_back( RGBGetRValue(colour) );
|
||||
colours.push_back( RGBGetGValue(colour) );
|
||||
colours.push_back( RGBGetBValue(colour) );
|
||||
colours.push_back(RGBGetRValue(colour));
|
||||
colours.push_back(RGBGetGValue(colour));
|
||||
colours.push_back(RGBGetBValue(colour));
|
||||
}
|
||||
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = zone_index - 1;
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = port_idx;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = led_count;
|
||||
unsigned char buffer_idx = CM_ARGB_MODE_BYTE;
|
||||
|
||||
/*---------------------------------------------*\
|
||||
| Guard the writes to the controller until the |
|
||||
| for loop has completed to avoid collisons |
|
||||
\*---------------------------------------------*/
|
||||
std::lock_guard<std::mutex> guard(*mutex_ptr);
|
||||
|
||||
for(std::vector<unsigned char>::iterator it = colours.begin(); it != colours.end(); buffer_idx = CM_ARGB_COMMAND_BYTE)
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Fill the write buffer till its full or the colour buffer is empty |
|
||||
\*-----------------------------------------------------------------*/
|
||||
/*-------------------------------------------------*\
|
||||
| Fill the write buffer till its full or the |
|
||||
| colour buffer is empty |
|
||||
\*-------------------------------------------------*/
|
||||
buffer[CM_ARGB_REPORT_BYTE] = packet_count;
|
||||
while (( buffer_idx < buffer_size) && ( it != colours.end() ))
|
||||
while((buffer_idx < buffer_size) && (it != colours.end()))
|
||||
{
|
||||
buffer[buffer_idx] = *it;
|
||||
buffer_idx++;
|
||||
@@ -223,76 +284,15 @@ void CMARGBController::SetLedsDirect(RGBColor *led_colours, unsigned int led_cou
|
||||
buffer[CM_ARGB_REPORT_BYTE] += 0x80;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Send the buffer |
|
||||
\*-------------------------------------------------*/
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Reset the write buffer |
|
||||
\*-----------------------------------------------------------------*/
|
||||
/*-------------------------------------------------*\
|
||||
| Reset the write buffer |
|
||||
\*-------------------------------------------------*/
|
||||
memset(buffer, 0x00, buffer_size );
|
||||
packet_count++;
|
||||
}
|
||||
}
|
||||
|
||||
void CMARGBController::SendUpdate()
|
||||
{
|
||||
/*---------------------------------------------*\
|
||||
| Guard the writes to the controller |
|
||||
\*---------------------------------------------*/
|
||||
std::lock_guard<std::mutex> guard(*mutex_ptr);
|
||||
|
||||
unsigned char buffer[CM_ARGB_PACKET_SIZE] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
bool boolARGB_header = argb_header_data[zone_index].digital;
|
||||
bool boolPassthru = ( current_mode == CM_ARGB_MODE_PASSTHRU ) || ( current_mode == CM_RGB_MODE_PASSTHRU );
|
||||
bool boolDirect = ( current_mode == CM_ARGB_MODE_DIRECT );
|
||||
unsigned char function = boolPassthru ? (boolARGB_header ? 0x02 : 0x04) : (boolARGB_header ? 0x01 : 0x03);
|
||||
buffer[CM_ARGB_REPORT_BYTE] = 0x80;
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x01;
|
||||
|
||||
if(boolDirect)
|
||||
{
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = 0x01;
|
||||
buffer[CM_ARGB_ZONE_BYTE] = 0x02;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Direct mode is now set up and no other mode packet is required |
|
||||
\*-----------------------------------------------------------------*/
|
||||
return;
|
||||
}
|
||||
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = function;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
if(boolARGB_header)
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B; //ARGB sends 0x0B (1011) RGB sends 0x04 (0100)
|
||||
buffer[CM_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02; //This controls direct mode TODO
|
||||
buffer[CM_ARGB_ZONE_BYTE] = argb_header_data[zone_index].header;
|
||||
buffer[CM_ARGB_MODE_BYTE] = current_mode;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = bool_random ? 0x00 : 0x10;
|
||||
buffer[CM_ARGB_SPEED_BYTE] = current_speed;
|
||||
buffer[CM_ARGB_BRIGHTNESS_BYTE] = current_brightness;
|
||||
buffer[CM_ARGB_RED_BYTE] = current_red;
|
||||
buffer[CM_ARGB_GREEN_BYTE] = current_green;
|
||||
buffer[CM_ARGB_BLUE_BYTE] = current_blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[CM_ARGB_COMMAND_BYTE] = boolPassthru ? 0x01 : 0x04; //ARGB sends 0x0b (1011) RGB sends 0x04 (0100)
|
||||
buffer[CM_ARGB_MODE_BYTE + CM_RGB_OFFSET] = current_mode;
|
||||
buffer[CM_ARGB_COLOUR_INDEX_BYTE + CM_RGB_OFFSET] = bool_random ? 0x00 : 0x10;
|
||||
buffer[CM_ARGB_SPEED_BYTE + CM_RGB_OFFSET] = current_speed;
|
||||
buffer[CM_ARGB_BRIGHTNESS_BYTE + CM_RGB_OFFSET] = current_brightness;
|
||||
buffer[CM_ARGB_RED_BYTE + CM_RGB_OFFSET] = current_red;
|
||||
buffer[CM_ARGB_GREEN_BYTE + CM_RGB_OFFSET] = current_green;
|
||||
buffer[CM_ARGB_BLUE_BYTE + CM_RGB_OFFSET] = current_blue;
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
|
||||
@@ -16,19 +16,20 @@
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h" //Needed to set the direct mode
|
||||
#include "RGBController.h"
|
||||
|
||||
#define CM_ARGB_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data[0]) / sizeof(colour_mode_data[0][0]))
|
||||
#define CM_ARGB_HEADER_DATA_SIZE (sizeof(argb_header_data) / sizeof(argb_headers) )
|
||||
#define CM_ARGB_INTERRUPT_TIMEOUT 250
|
||||
#define CM_ARGB_PACKET_SIZE 65
|
||||
#define CM_ARGB_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
|
||||
#define CM_RGB_OFFSET -2
|
||||
#define HID_MAX_STR 255
|
||||
#define CM_ARGB_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data[0]) / sizeof(colour_mode_data[0][0]))
|
||||
#define CM_ARGB_HEADER_DATA_SIZE (sizeof(argb_header_data) / sizeof(argb_headers) )
|
||||
#define CM_ARGB_INTERRUPT_TIMEOUT 250
|
||||
#define CM_ARGB_PACKET_SIZE 65
|
||||
#define CM_ARGB_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
|
||||
#define CM_RGB_OFFSET -2
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
#define CM_ARGB_BRIGHTNESS_MAX 255
|
||||
#define CM_ARGB_FW0023 std::string("A202011171238")
|
||||
#define CM_ARGB_FW0028 std::string("A202105291658")
|
||||
#define CM_ARGB_BRIGHTNESS_MAX 255
|
||||
#define CM_ARGB_FW0000 std::string("A201804091608")
|
||||
#define CM_ARGB_FW0023 std::string("A202011171238")
|
||||
#define CM_ARGB_FW0028 std::string("A202105291658")
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -45,22 +46,13 @@ enum
|
||||
CM_ARGB_BLUE_BYTE = 11
|
||||
};
|
||||
|
||||
struct argb_headers
|
||||
enum
|
||||
{
|
||||
const char* name;
|
||||
unsigned char header;
|
||||
bool digital;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static argb_headers argb_header_data[] =
|
||||
{
|
||||
{ "RGB Header", 0xFE, false, 1 },
|
||||
{ "Digital ARGB1", 0x01, true, 12 },
|
||||
{ "Digital ARGB2", 0x02, true, 12 },
|
||||
{ "Digital ARGB3", 0x04, true, 12 },
|
||||
{ "Digital ARGB4", 0x08, true, 12 },
|
||||
//{ "All Digital ARGB", 0xFF, true, 12 }
|
||||
CM_ARGB_PORT_ARGB_1 = 0x01,
|
||||
CM_ARGB_PORT_ARGB_2 = 0x02,
|
||||
CM_ARGB_PORT_ARGB_3 = 0x04,
|
||||
CM_ARGB_PORT_ARGB_4 = 0x08,
|
||||
CM_ARGB_PORT_RGB = 0xFE,
|
||||
};
|
||||
|
||||
enum
|
||||
@@ -101,40 +93,44 @@ enum
|
||||
class CMARGBController
|
||||
{
|
||||
public:
|
||||
CMARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx, std::shared_ptr<std::mutex> cm_mutex);
|
||||
CMARGBController(hid_device* dev_handle, char* path);
|
||||
~CMARGBController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
std::string GetVersion();
|
||||
|
||||
unsigned char GetZoneIndex();
|
||||
unsigned char GetMode();
|
||||
unsigned char GetLedRed();
|
||||
unsigned char GetLedGreen();
|
||||
unsigned char GetLedBlue();
|
||||
unsigned char GetLedSpeed();
|
||||
bool GetRandomColours();
|
||||
void SetLedCount(int zone, int led_count);
|
||||
void SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, RGBColor colour, bool random_colours);
|
||||
void SetLedsDirect(RGBColor * led_colours, unsigned int led_count);
|
||||
void GetPortStatus
|
||||
(
|
||||
unsigned char port_idx,
|
||||
unsigned char* port_mode,
|
||||
unsigned char* port_speed,
|
||||
unsigned char* port_brightness,
|
||||
bool* port_random,
|
||||
unsigned char* port_red,
|
||||
unsigned char* port_green,
|
||||
unsigned char* port_blue
|
||||
);
|
||||
|
||||
void SetPortLEDCount(unsigned char port_idx, unsigned char led_count);
|
||||
|
||||
void SetPortMode
|
||||
(
|
||||
unsigned char port_idx,
|
||||
unsigned char port_mode,
|
||||
unsigned char port_speed,
|
||||
unsigned char port_brightness,
|
||||
bool port_random,
|
||||
unsigned char port_red,
|
||||
unsigned char port_green,
|
||||
unsigned char port_blue
|
||||
);
|
||||
|
||||
void SetPortLEDsDirect(unsigned char port_idx, RGBColor *led_colours, unsigned int led_count);
|
||||
|
||||
private:
|
||||
std::string device_name;
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
std::shared_ptr<std::mutex> mutex_ptr;
|
||||
|
||||
unsigned char zone_index;
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
unsigned char current_red;
|
||||
unsigned char current_green;
|
||||
unsigned char current_blue;
|
||||
unsigned char current_brightness;
|
||||
bool bool_random;
|
||||
|
||||
void GetStatus();
|
||||
void SendUpdate();
|
||||
hid_device* dev;
|
||||
std::string device_name;
|
||||
std::string location;
|
||||
};
|
||||
|
||||
+325
-313
@@ -27,268 +27,220 @@
|
||||
RGBController_CMARGBController::RGBController_CMARGBController(CMARGBController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
unsigned char speed = controller->GetLedSpeed();
|
||||
|
||||
name = argb_header_data[controller->GetZoneIndex()].name;
|
||||
name = controller->GetDeviceName();
|
||||
vendor = "Cooler Master";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = controller->GetDeviceName();
|
||||
version = "3.0 for FW0028";
|
||||
description = "Cooler Master ARGB Controller Device";
|
||||
version = controller->GetVersion();
|
||||
serial = controller->GetSerial();
|
||||
location = controller->GetLocation();
|
||||
|
||||
if(argb_header_data[controller->GetZoneIndex()].digital)
|
||||
{
|
||||
mode Off;
|
||||
Off.name = "Turn Off";
|
||||
Off.value = CM_ARGB_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
/*-----------------------------------------------------*\
|
||||
| The ARGB ports support more modes than the RGB port. |
|
||||
| Define all of the modes the ARGB ports support and |
|
||||
| map RGB modes to them as best as we can. Per-zone |
|
||||
| support will be added in the future. |
|
||||
\*-----------------------------------------------------*/
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = CM_ARGB_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Reload;
|
||||
Reload.name = "Reload";
|
||||
Reload.value = CM_ARGB_MODE_RELOAD;
|
||||
Reload.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Reload.colors_min = 1;
|
||||
Reload.colors_max = 1;
|
||||
Reload.colors.resize(Reload.colors_max);
|
||||
Reload.brightness_min = 0;
|
||||
Reload.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Reload.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Reload.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Reload.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Reload.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Reload.speed = speed;
|
||||
modes.push_back(Reload);
|
||||
mode Reload;
|
||||
Reload.name = "Reload";
|
||||
Reload.value = CM_ARGB_MODE_RELOAD;
|
||||
Reload.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Reload.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Reload.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Reload.speed = CM_ARGB_SPEED_NORMAL;
|
||||
Reload.brightness_min = 0;
|
||||
Reload.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Reload.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Reload.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Reload.colors_min = 1;
|
||||
Reload.colors_max = 1;
|
||||
Reload.colors.resize(Reload.colors_max);
|
||||
modes.push_back(Reload);
|
||||
|
||||
mode Recoil;
|
||||
Recoil.name = "Recoil";
|
||||
Recoil.value = CM_ARGB_MODE_RECOIL;
|
||||
Recoil.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Recoil.colors_min = 1;
|
||||
Recoil.colors_max = 1;
|
||||
Recoil.colors.resize(Recoil.colors_max);
|
||||
Recoil.brightness_min = 0;
|
||||
Recoil.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Recoil.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Recoil.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Recoil.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Recoil.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Recoil.speed = speed;
|
||||
modes.push_back(Recoil);
|
||||
mode Recoil;
|
||||
Recoil.name = "Recoil";
|
||||
Recoil.value = CM_ARGB_MODE_RECOIL;
|
||||
Recoil.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Recoil.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Recoil.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Recoil.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Recoil.speed = CM_ARGB_SPEED_NORMAL;
|
||||
Recoil.brightness_min = 0;
|
||||
Recoil.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Recoil.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Recoil.colors_min = 1;
|
||||
Recoil.colors_max = 1;
|
||||
Recoil.colors.resize(Recoil.colors_max);
|
||||
modes.push_back(Recoil);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_ARGB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(Breathing.colors_max);
|
||||
Breathing.brightness_min = 0;
|
||||
Breathing.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Breathing.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.speed = speed;
|
||||
modes.push_back(Breathing);
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_ARGB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Breathing.speed = CM_ARGB_SPEED_NORMAL;
|
||||
Breathing.brightness_min = 0;
|
||||
Breathing.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Breathing.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(Breathing.colors_max);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Refill;
|
||||
Refill.name = "Refill";
|
||||
Refill.value = CM_ARGB_MODE_REFILL;
|
||||
Refill.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Refill.colors_min = 1;
|
||||
Refill.colors_max = 1;
|
||||
Refill.colors.resize(Refill.colors_max);
|
||||
Refill.brightness_min = 0;
|
||||
Refill.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Refill.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Refill.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Refill.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Refill.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Refill.speed = speed;
|
||||
modes.push_back(Refill);
|
||||
mode Refill;
|
||||
Refill.name = "Refill";
|
||||
Refill.value = CM_ARGB_MODE_REFILL;
|
||||
Refill.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Refill.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Refill.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Refill.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Refill.speed = CM_ARGB_SPEED_NORMAL;
|
||||
Refill.brightness_min = 0;
|
||||
Refill.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Refill.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Refill.colors_min = 1;
|
||||
Refill.colors_max = 1;
|
||||
Refill.colors.resize(Refill.colors_max);
|
||||
modes.push_back(Refill);
|
||||
|
||||
mode Demo;
|
||||
Demo.name = "Demo";
|
||||
Demo.value = CM_ARGB_MODE_DEMO;
|
||||
Demo.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Demo.brightness_min = 0;
|
||||
Demo.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Demo.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Demo.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Demo.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Demo.color_mode = MODE_COLORS_NONE;
|
||||
Demo.speed = speed;
|
||||
modes.push_back(Demo);
|
||||
mode Demo;
|
||||
Demo.name = "Demo";
|
||||
Demo.value = CM_ARGB_MODE_DEMO;
|
||||
Demo.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Demo.color_mode = MODE_COLORS_NONE;
|
||||
Demo.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Demo.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Demo.speed = CM_ARGB_SPEED_NORMAL;
|
||||
Demo.brightness_min = 0;
|
||||
Demo.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Demo.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
modes.push_back(Demo);
|
||||
|
||||
mode Spectrum;
|
||||
Spectrum.name = "Spectrum";
|
||||
Spectrum.value = CM_ARGB_MODE_SPECTRUM;
|
||||
Spectrum.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Spectrum.brightness_min = 0;
|
||||
Spectrum.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Spectrum.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Spectrum.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Spectrum.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Spectrum.color_mode = MODE_COLORS_NONE;
|
||||
Spectrum.speed = speed;
|
||||
modes.push_back(Spectrum);
|
||||
mode Spectrum;
|
||||
Spectrum.name = "Rainbow Wave";
|
||||
Spectrum.value = CM_ARGB_MODE_SPECTRUM;
|
||||
Spectrum.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Spectrum.color_mode = MODE_COLORS_NONE;
|
||||
Spectrum.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Spectrum.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Spectrum.speed = CM_ARGB_SPEED_NORMAL;
|
||||
Spectrum.brightness_min = 0;
|
||||
Spectrum.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Spectrum.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
modes.push_back(Spectrum);
|
||||
|
||||
mode FillFlow;
|
||||
FillFlow.name = "Fill Flow";
|
||||
FillFlow.value = CM_ARGB_MODE_FILLFLOW;
|
||||
FillFlow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
FillFlow.brightness_min = 0;
|
||||
FillFlow.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
FillFlow.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
FillFlow.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
FillFlow.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
FillFlow.color_mode = MODE_COLORS_NONE;
|
||||
FillFlow.speed = speed;
|
||||
modes.push_back(FillFlow);
|
||||
mode FillFlow;
|
||||
FillFlow.name = "Fill Flow";
|
||||
FillFlow.value = CM_ARGB_MODE_FILLFLOW;
|
||||
FillFlow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
FillFlow.color_mode = MODE_COLORS_NONE;
|
||||
FillFlow.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
FillFlow.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
FillFlow.speed = CM_ARGB_SPEED_NORMAL;
|
||||
FillFlow.brightness_min = 0;
|
||||
FillFlow.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
FillFlow.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
modes.push_back(FillFlow);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CM_ARGB_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Rainbow.brightness_min = 0;
|
||||
Rainbow.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Rainbow.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Rainbow.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Rainbow.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
Rainbow.speed = speed;
|
||||
modes.push_back(Rainbow);
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow";
|
||||
Rainbow.value = CM_ARGB_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
Rainbow.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Rainbow.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Rainbow.speed = CM_ARGB_SPEED_NORMAL;
|
||||
Rainbow.brightness_min = 0;
|
||||
Rainbow.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Rainbow.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CM_ARGB_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(Static.colors_max);
|
||||
Static.brightness_min = 0;
|
||||
Static.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Static.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Static.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Static.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.speed = speed;
|
||||
modes.push_back(Static);
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CM_ARGB_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Static.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Static.speed = CM_ARGB_SPEED_NORMAL;
|
||||
Static.brightness_min = 0;
|
||||
Static.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Static.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(Static.colors_max);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = (serial >= CM_ARGB_FW0028) ? "Direct" : "Custom";
|
||||
Direct.value = CM_ARGB_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
mode Direct;
|
||||
Direct.name = (serial >= CM_ARGB_FW0028) ? "Direct" : "Custom";
|
||||
Direct.value = CM_ARGB_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode PassThru;
|
||||
PassThru.name = "Pass Thru";
|
||||
PassThru.value = CM_ARGB_MODE_PASSTHRU;
|
||||
PassThru.flags = 0;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
}
|
||||
else
|
||||
{
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = CM_RGB_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(Static.colors_max);
|
||||
Static.brightness_min = 0;
|
||||
Static.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Static.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.speed = 0;
|
||||
modes.push_back(Static);
|
||||
mode PassThru;
|
||||
PassThru.name = "Pass Thru";
|
||||
PassThru.value = CM_ARGB_MODE_PASSTHRU;
|
||||
PassThru.flags = 0;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_RGB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(Breathing.colors_max);
|
||||
Breathing.brightness_min = 0;
|
||||
Breathing.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Breathing.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.speed = CM_ARGB_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Flash;
|
||||
Flash.name = "Flash";
|
||||
Flash.value = CM_RGB_MODE_FLASH;
|
||||
Flash.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Flash.colors_min = 1;
|
||||
Flash.colors_max = 1;
|
||||
Flash.colors.resize(Flash.colors_max);
|
||||
Flash.brightness_min = 0;
|
||||
Flash.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Flash.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Flash.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Flash.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Flash.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flash.speed = CM_ARGB_SPEED_NORMAL;
|
||||
modes.push_back(Flash);
|
||||
|
||||
mode Mirage;
|
||||
Mirage.name = "Mirage";
|
||||
Mirage.value = CM_RGB_MODE_MIRAGE;
|
||||
Mirage.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Mirage.colors_min = 1;
|
||||
Mirage.colors_max = 1;
|
||||
Mirage.colors.resize(Mirage.colors_max);
|
||||
Mirage.brightness_min = 0;
|
||||
Mirage.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Mirage.brightness = CM_ARGB_BRIGHTNESS_MAX;
|
||||
Mirage.speed_min = CM_ARGB_SPEED_SLOWEST;
|
||||
Mirage.speed_max = CM_ARGB_SPEED_FASTEST;
|
||||
Mirage.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Mirage.speed = CM_ARGB_SPEED_NORMAL;
|
||||
modes.push_back(Mirage);
|
||||
|
||||
mode PassThru;
|
||||
PassThru.name = "Pass Thru";
|
||||
PassThru.value = CM_RGB_MODE_PASSTHRU;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Turn Off";
|
||||
Off.value = CM_RGB_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
}
|
||||
|
||||
Init_Controller();
|
||||
SetupZones();
|
||||
|
||||
int temp_mode = controller->GetMode();
|
||||
for(int mode_idx = 0; mode_idx < (int)modes.size() ; mode_idx++)
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize the active mode to port 0 |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned char port_mode;
|
||||
unsigned char port_speed;
|
||||
unsigned char port_brightness;
|
||||
bool port_random;
|
||||
unsigned char port_red;
|
||||
unsigned char port_green;
|
||||
unsigned char port_blue;
|
||||
|
||||
controller->GetPortStatus(0, &port_mode, &port_speed, &port_brightness, &port_random, &port_red, &port_green, &port_blue);
|
||||
|
||||
for(std::size_t mode_idx = 0; mode_idx < modes.size(); mode_idx++)
|
||||
{
|
||||
if (temp_mode == modes[mode_idx].value)
|
||||
if(modes[mode_idx].value == port_mode)
|
||||
{
|
||||
active_mode = mode_idx;
|
||||
|
||||
if((modes[mode_idx].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR) && (modes[mode_idx].colors.size() > 0))
|
||||
{
|
||||
modes[mode_idx].colors[0] = ToRGBColor(port_red, port_green, port_blue);
|
||||
}
|
||||
|
||||
if(modes[mode_idx].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[mode_idx].speed = port_speed;
|
||||
}
|
||||
|
||||
if(modes[mode_idx].flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
{
|
||||
modes[mode_idx].brightness = port_brightness;
|
||||
}
|
||||
|
||||
if(modes[mode_idx].flags & MODE_FLAG_HAS_RANDOM_COLOR)
|
||||
{
|
||||
if(port_random)
|
||||
{
|
||||
modes[mode_idx].color_mode = MODE_COLORS_RANDOM;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
|
||||
{
|
||||
modes[active_mode].colors[0] = ToRGBColor(controller->GetLedRed(), controller->GetLedGreen(), controller->GetLedBlue());
|
||||
modes[active_mode].color_mode = (controller->GetRandomColours()) ? MODE_COLORS_RANDOM : MODE_COLORS_MODE_SPECIFIC;
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[active_mode].speed = controller->GetLedSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_CMARGBController::~RGBController_CMARGBController()
|
||||
@@ -296,68 +248,76 @@ RGBController_CMARGBController::~RGBController_CMARGBController()
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::Init_Controller()
|
||||
{
|
||||
int zone_idx = controller->GetZoneIndex();
|
||||
int zone_led_count = argb_header_data[zone_idx].count;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If argb_header_data[zone_idx].count == 1 then the |
|
||||
| zone is ZONE_TYPE_SINGLE |
|
||||
\*-------------------------------------------------*/
|
||||
bool boolSingleLED = ( zone_led_count == 1 );
|
||||
|
||||
zone ARGB_zone;
|
||||
ARGB_zone.name = std::to_string(zone_idx);
|
||||
ARGB_zone.type = (boolSingleLED) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
|
||||
ARGB_zone.leds_min = 4;
|
||||
ARGB_zone.leds_max = 48;
|
||||
ARGB_zone.leds_count = zone_led_count;
|
||||
ARGB_zone.matrix_map = NULL;
|
||||
zones.push_back(ARGB_zone);
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Only set LED count on the first run |
|
||||
\*-----------------------------------------------------*/
|
||||
bool first_run = false;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = true;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-----------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
zones.resize(5);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up addressable zones |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int channel_idx = 0; channel_idx < 4; channel_idx++)
|
||||
{
|
||||
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE);
|
||||
char ch_idx_string[2];
|
||||
snprintf(ch_idx_string, 2, "%d", channel_idx + 1);
|
||||
|
||||
if (!boolSingleLED)
|
||||
zones[channel_idx].name = "Addressable RGB Header ";
|
||||
zones[channel_idx].name.append(ch_idx_string);
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = 48;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
controller->SetLedCount( std::stoi(zones[zone_idx].name), zones[zone_idx].leds_count);
|
||||
zones[channel_idx].leds_count = 0;
|
||||
}
|
||||
|
||||
for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
|
||||
{
|
||||
led new_led;
|
||||
unsigned int i = std::stoi(zones[zone_idx].name);
|
||||
zones[channel_idx].matrix_map = NULL;
|
||||
|
||||
if(boolSingleLED)
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.value = argb_header_data[i].header;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.name.append(" LED " + std::to_string(lp_idx));
|
||||
new_led.value = argb_header_data[i].header;
|
||||
}
|
||||
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
char led_idx_string[4];
|
||||
snprintf(led_idx_string, 4, "%d", led_ch_idx + 1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = zones[channel_idx].name;
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(led_idx_string);
|
||||
new_led.value = channel_idx;
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up RGB zone |
|
||||
\*-----------------------------------------------------*/
|
||||
zones[4].name = "RGB Header";
|
||||
zones[4].type = ZONE_TYPE_SINGLE;
|
||||
zones[4].leds_min = 1;
|
||||
zones[4].leds_max = 1;
|
||||
zones[4].leds_count = 1;
|
||||
zones[4].matrix_map = NULL;
|
||||
|
||||
led new_led;
|
||||
new_led.name = "RGB Header";
|
||||
new_led.value = 4;
|
||||
leds.push_back(new_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
@@ -367,24 +327,20 @@ void RGBController_CMARGBController::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint8_t end_zone = last_zone(zone);
|
||||
|
||||
for(std::size_t zone_idx = first_zone(zone); zone_idx < end_zone; zone_idx++)
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
if(((unsigned int)new_size >= zones[zone_idx].leds_min) && ((unsigned int)new_size <= zones[zone_idx].leds_max))
|
||||
{
|
||||
zones[zone_idx].leds_count = new_size;
|
||||
}
|
||||
}
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
controller->SetPortLEDCount(zone, zones[zone].leds_count);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::DeviceUpdateLEDs()
|
||||
{
|
||||
uint8_t end_zone = last_zone(cmargb->GetZoneIndex());
|
||||
|
||||
for(int zone_idx = first_zone(cmargb->GetZoneIndex()); zone_idx < end_zone; zone_idx++)
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
UpdateZoneLEDs(zone_idx);
|
||||
}
|
||||
@@ -392,37 +348,93 @@ void RGBController_CMARGBController::DeviceUpdateLEDs()
|
||||
|
||||
void RGBController_CMARGBController::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
controller->SetLedsDirect( zones[zone].colors, zones[zone].leds_count );
|
||||
/*-----------------------------------------------------*\
|
||||
| The RGB zone doesn't have a separate Direct mode, so |
|
||||
| use static mode with the per-LED color for it |
|
||||
\*-----------------------------------------------------*/
|
||||
if(zone < 4)
|
||||
{
|
||||
controller->SetPortLEDsDirect(zone, zones[zone].colors, zones[zone].leds_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetPortMode(zone, CM_RGB_MODE_STATIC, 0, 255, false, RGBGetRValue(zones[zone].colors[0]), RGBGetGValue(zones[zone].colors[0]), RGBGetBValue(zones[zone].colors[0]));
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(GetLED_Zone(led));
|
||||
unsigned int zone_idx = leds[led].value;
|
||||
|
||||
UpdateZoneLEDs(zone_idx);
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::DeviceUpdateMode()
|
||||
{
|
||||
bool random_colours = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
RGBColor colour = (modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) ? modes[active_mode].colors[0] : 0;
|
||||
/*-----------------------------------------------------*\
|
||||
| Determine mode parameters |
|
||||
\*-----------------------------------------------------*/
|
||||
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
RGBColor color = (modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) ? modes[active_mode].colors[0] : 0;
|
||||
int rgb_mode;
|
||||
bool rgb_random = random;
|
||||
|
||||
controller->SetMode( modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, colour, random_colours );
|
||||
}
|
||||
|
||||
int RGBController_CMARGBController::GetLED_Zone(int led_idx)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This may be more useful in the abstract RGBController.cpp |
|
||||
\*---------------------------------------------------------*/
|
||||
for(int zone_idx = 0; zone_idx < (int)zones.size(); zone_idx++)
|
||||
/*-----------------------------------------------------*\
|
||||
| Map ARGB modes with the equivalent RGB modes |
|
||||
\*-----------------------------------------------------*/
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
int zone_start = zones[zone_idx].start_idx;
|
||||
int zone_end = zone_start + zones[zone_idx].leds_count - 1;
|
||||
case CM_ARGB_MODE_SPECTRUM:
|
||||
case CM_ARGB_MODE_FILLFLOW:
|
||||
case CM_ARGB_MODE_RAINBOW:
|
||||
rgb_mode = CM_RGB_MODE_MIRAGE;
|
||||
rgb_random = true;
|
||||
break;
|
||||
|
||||
if(zone_start <= led_idx && zone_end >= led_idx)
|
||||
{
|
||||
return(zone_idx);
|
||||
}
|
||||
case CM_ARGB_MODE_RELOAD:
|
||||
case CM_ARGB_MODE_RECOIL:
|
||||
rgb_mode = CM_RGB_MODE_FLASH;
|
||||
break;
|
||||
|
||||
case CM_ARGB_MODE_BREATHING:
|
||||
rgb_mode = CM_RGB_MODE_BREATHING;
|
||||
break;
|
||||
|
||||
case CM_ARGB_MODE_REFILL:
|
||||
case CM_ARGB_MODE_STATIC:
|
||||
rgb_mode = CM_RGB_MODE_STATIC;
|
||||
break;
|
||||
|
||||
case CM_ARGB_MODE_DEMO:
|
||||
rgb_mode = CM_RGB_MODE_FLASH;
|
||||
rgb_random = true;
|
||||
break;
|
||||
|
||||
case CM_ARGB_MODE_OFF:
|
||||
default:
|
||||
rgb_mode = CM_RGB_MODE_OFF;
|
||||
break;
|
||||
|
||||
case CM_ARGB_MODE_PASSTHRU:
|
||||
rgb_mode = CM_RGB_MODE_PASSTHRU;
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
/*-----------------------------------------------------*\
|
||||
| Apply mode to all zones |
|
||||
\*-----------------------------------------------------*/
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
controller->SetPortMode
|
||||
(
|
||||
zone_idx,
|
||||
(zone_idx == 4) ? rgb_mode : modes[active_mode].value,
|
||||
modes[active_mode].speed,
|
||||
modes[active_mode].brightness,
|
||||
(zone_idx == 4) ? rgb_random : random,
|
||||
RGBGetRValue(color),
|
||||
RGBGetGValue(color),
|
||||
RGBGetBValue(color)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-9
@@ -12,11 +12,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "RGBController.h"
|
||||
#include "CMARGBController.h"
|
||||
|
||||
#define first_zone(zn) ((zones.size() > 1) ? 1 : 0)
|
||||
#define last_zone(zn) ((zones.size() > 1) ? 4 : 1)
|
||||
#include "RGBController.h"
|
||||
|
||||
class RGBController_CMARGBController : public RGBController
|
||||
{
|
||||
@@ -34,9 +31,6 @@ public:
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
void Init_Controller();
|
||||
int GetDeviceMode();
|
||||
int GetLED_Zone(int led_idx);
|
||||
|
||||
CMARGBController* controller;
|
||||
CMARGBController* controller;
|
||||
std::vector<unsigned int> leds_channel;
|
||||
};
|
||||
|
||||
@@ -96,19 +96,18 @@ void DetectCoolerMasterARGB(hid_device_info* info, const std::string&)
|
||||
|
||||
if(dev)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Create mutex to prevent the controllers sharing a |
|
||||
| receiver from interfering with each other |
|
||||
\*-------------------------------------------------*/
|
||||
std::shared_ptr<std::mutex> cm_mutex = std::make_shared<std::mutex>();
|
||||
CMARGBController* controller = new CMARGBController(dev, info->path);
|
||||
|
||||
for(unsigned char i = 0; i < CM_ARGB_HEADER_DATA_SIZE; i++)
|
||||
if(controller->GetVersion() != "Unsupported")
|
||||
{
|
||||
CMARGBController* controller = new CMARGBController(dev, info->path, i, cm_mutex);
|
||||
RGBController_CMARGBController* rgb_controller = new RGBController_CMARGBController(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("[CMARGBController] Unsupported firmware version");
|
||||
delete controller;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user