Initial Commit for new device Coolermaster Small ARGB Controller
* Added a new controller class * Compiles cleanly Commits squashed by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
88eb979544
commit
2b2478fea5
6 changed files with 659 additions and 0 deletions
237
Controllers/CoolerMasterController/CMSmallARGBController.cpp
Normal file
237
Controllers/CoolerMasterController/CMSmallARGBController.cpp
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| CMSmallARGBController.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster Small ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 31st Jan 2021 |
|
||||
| |
|
||||
| Simple RGB device with 5 modes |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "CMSmallARGBController.h"
|
||||
#include <cstring>
|
||||
|
||||
CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx)
|
||||
{
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
zone_index = _zone_idx;
|
||||
current_speed = CM_SMALL_ARGB_SPEED_NORMAL;
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
device_name = std::string(wName.begin(), wName.end());
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
device_name.append(" ").append(std::string(wName.begin(), wName.end()));
|
||||
|
||||
hid_get_serial_number_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
serial = std::string(wName.begin(), wName.end());
|
||||
|
||||
GetStatus();
|
||||
}
|
||||
|
||||
CMSmallARGBController::~CMSmallARGBController()
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
void CMSmallARGBController::GetStatus()
|
||||
{
|
||||
unsigned char buffer[CM_SMALL_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x01, 0x01 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
int header = zone_index - 1;
|
||||
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = header;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x01;
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
memset(buffer, 0x00, buffer_size );
|
||||
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x0B;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = 0x01;
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = 0x01;
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
current_mode = buffer[4];
|
||||
current_speed = buffer[5];
|
||||
bool_random = buffer[6] == 0x00;
|
||||
current_brightness = buffer[7];
|
||||
current_red = buffer[8];
|
||||
current_green = buffer[9];
|
||||
current_blue = buffer[10];
|
||||
}
|
||||
|
||||
std::string CMSmallARGBController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string CMSmallARGBController::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string CMSmallARGBController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetZoneIndex()
|
||||
{
|
||||
return zone_index;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetMode()
|
||||
{
|
||||
return current_mode;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetLedRed()
|
||||
{
|
||||
return current_red;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetLedGreen()
|
||||
{
|
||||
return current_green;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetLedBlue()
|
||||
{
|
||||
return current_blue;
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetLedSpeed()
|
||||
{
|
||||
return current_speed;
|
||||
}
|
||||
|
||||
bool CMSmallARGBController::GetRandomColours()
|
||||
{
|
||||
return bool_random;
|
||||
}
|
||||
|
||||
void CMSmallARGBController::SetLedCount(int zone, int led_count)
|
||||
{
|
||||
unsigned char buffer[CM_SMALL_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x0D, 0x02 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = zone;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = (0x0F - led_count > 0) ? 0x0F - led_count : 0x01;
|
||||
buffer[CM_SMALL_ARGB_SPEED_BYTE] = led_count;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
}
|
||||
|
||||
void CMSmallARGBController::SetMode(unsigned char mode, unsigned char speed, RGBColor colour, bool random_colours)
|
||||
{
|
||||
current_mode = mode;
|
||||
current_speed = speed;
|
||||
current_red = RGBGetRValue(colour);
|
||||
current_green = RGBGetGValue(colour);
|
||||
current_blue = RGBGetBValue(colour);
|
||||
bool_random = random_colours;
|
||||
|
||||
SendUpdate();
|
||||
}
|
||||
|
||||
void CMSmallARGBController::SetLedsDirect(RGBColor *led_colours, unsigned int led_count)
|
||||
{
|
||||
// Mode not yet Tested
|
||||
/*
|
||||
const unsigned char buffer_size = 0x41;
|
||||
unsigned char buffer[buffer_size] = { 0x00 };
|
||||
unsigned char packet_count = 0x00;
|
||||
std::vector<unsigned char> colours;
|
||||
|
||||
//Set up the RGB triplets to send
|
||||
for(int i = 0; i < led_count; i++)
|
||||
{
|
||||
RGBColor colour = led_colours[i];
|
||||
unsigned char r = RGBGetRValue(colour);
|
||||
unsigned char g = RGBGetGValue(colour);
|
||||
unsigned char b = RGBGetBValue(colour);
|
||||
|
||||
colours.push_back(r);
|
||||
colours.push_back(g);
|
||||
colours.push_back(b);
|
||||
}
|
||||
|
||||
//buffer[CM_ARGB_REPORT_BYTE] = packet_count;
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x10;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = 0x02;
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = small_argb_header_data[zone_index].header;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x30; //30 might be the LED count??
|
||||
unsigned char buffer_idx = CM_SMALL_ARGB_MODE_BYTE + 1; //Start colour info from
|
||||
|
||||
for (std::vector<unsigned char>::iterator it = colours.begin(); it != colours.end(); buffer_idx = 0)
|
||||
{
|
||||
//Fill the write buffer till its full or the colour buffer is empty
|
||||
buffer[CM_SMALL_ARGB_REPORT_BYTE] = packet_count;
|
||||
while (( buffer_idx < buffer_size) && ( it != colours.end() ))
|
||||
{
|
||||
buffer[buffer_idx] = *it;
|
||||
buffer_idx++;
|
||||
it++;
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
|
||||
//reset the write buffer
|
||||
memset(buffer, 0x00, sizeof(buffer) );
|
||||
packet_count++;
|
||||
}
|
||||
buffer[CM_SMALL_ARGB_REPORT_BYTE] = 0x82;
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x62;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = 0x00;
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = 0x73;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x00;
|
||||
buffer[CM_SMALL_ARGB_SPEED_BYTE] = 0x33;
|
||||
buffer[CM_SMALL_ARGB_COLOUR_INDEX_BYTE] = 0x18;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
*/
|
||||
}
|
||||
|
||||
void CMSmallARGBController::SendUpdate()
|
||||
{
|
||||
unsigned char buffer[CM_SMALL_ARGB_PACKET_SIZE] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
bool boolPassthru = ( current_mode == CM_SMALL_ARGB_MODE_PASSTHRU );
|
||||
bool boolDirect = ( current_mode == CM_SMALL_ARGB_MODE_DIRECT );
|
||||
unsigned char function = boolPassthru ? 0x02 : 0x01;
|
||||
buffer[CM_SMALL_ARGB_REPORT_BYTE] = 0x80;
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = boolDirect ? 0x10 : 0x01;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = boolDirect ? 0x01 : function;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = boolPassthru ? 0x00 : 0x02;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
|
||||
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x0b;
|
||||
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02; //This controls custom mode TODO
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = small_argb_header_data[zone_index].header;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = current_mode;
|
||||
buffer[CM_SMALL_ARGB_SPEED_BYTE] = current_speed;
|
||||
buffer[CM_SMALL_ARGB_COLOUR_INDEX_BYTE] = (bool_random) ? 0x00 : 0x10; //This looks to still be the colour index and controls random colours
|
||||
buffer[CM_SMALL_ARGB_BRIGHTNESS_BYTE] = 0xFF;
|
||||
buffer[CM_SMALL_ARGB_RED_BYTE] = current_red;
|
||||
buffer[CM_SMALL_ARGB_GREEN_BYTE] = current_green;
|
||||
buffer[CM_SMALL_ARGB_BLUE_BYTE] = current_blue;
|
||||
|
||||
hid_write(dev, buffer, buffer_size);
|
||||
hid_read_timeout(dev, buffer, buffer_size, CM_SMALL_ARGB_INTERRUPT_TIMEOUT);
|
||||
}
|
||||
113
Controllers/CoolerMasterController/CMSmallARGBController.h
Normal file
113
Controllers/CoolerMasterController/CMSmallARGBController.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| CMSmallARGBController.h |
|
||||
| |
|
||||
| Driver for Coolermaster Small ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 31st Jan 2021 |
|
||||
| |
|
||||
| Simple RGB device with 5 modes |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <hidapi/hidapi.h>
|
||||
#include "RGBController.h" //Needed to set the direct mode
|
||||
|
||||
#pragma once
|
||||
|
||||
#define CM_SMALL_ARGB_PACKET_SIZE 65
|
||||
#define CM_SMALL_ARGB_INTERRUPT_TIMEOUT 250
|
||||
|
||||
enum
|
||||
{
|
||||
CM_SMALL_ARGB_REPORT_BYTE = 1,
|
||||
CM_SMALL_ARGB_COMMAND_BYTE = 2,
|
||||
CM_SMALL_ARGB_FUNCTION_BYTE = 3,
|
||||
CM_SMALL_ARGB_ZONE_BYTE = 4,
|
||||
CM_SMALL_ARGB_MODE_BYTE = 5,
|
||||
CM_SMALL_ARGB_SPEED_BYTE = 6,
|
||||
CM_SMALL_ARGB_COLOUR_INDEX_BYTE = 7, //Not used on the small controller
|
||||
CM_SMALL_ARGB_BRIGHTNESS_BYTE = 8, //0x00 thru 0xFF
|
||||
CM_SMALL_ARGB_RED_BYTE = 9,
|
||||
CM_SMALL_ARGB_GREEN_BYTE = 10,
|
||||
CM_SMALL_ARGB_BLUE_BYTE = 11,
|
||||
};
|
||||
|
||||
struct _argb_headers
|
||||
{
|
||||
const char* name;
|
||||
unsigned char header;
|
||||
bool digital;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
static _argb_headers small_argb_header_data[1] =
|
||||
{
|
||||
{ "CM Small ARGB", 0x01, true, 12 }
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_SMALL_ARGB_MODE_SPECTRUM = 0x01, //Spectrum Mode
|
||||
CM_SMALL_ARGB_MODE_RELOAD = 0x02, //Reload Mode
|
||||
CM_SMALL_ARGB_MODE_RECOIL = 0x03, //Recoil Mode
|
||||
CM_SMALL_ARGB_MODE_BREATHING = 0x04, //Breathing Mode
|
||||
CM_SMALL_ARGB_MODE_REFILL = 0x05, //Refill Mode
|
||||
CM_SMALL_ARGB_MODE_DEMO = 0x06, //Demo Mode
|
||||
CM_SMALL_ARGB_MODE_OFF = 0x09, //Turn off
|
||||
CM_SMALL_ARGB_MODE_DIRECT = 0xFE, //Direct Led Control (possibly N?A for small controller)
|
||||
CM_SMALL_ARGB_MODE_PASSTHRU = 0xFF //Motherboard Pass Thru Mode
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CM_SMALL_ARGB_SPEED_SLOWEST = 0x00, // Slowest speed
|
||||
CM_SMALL_ARGB_SPEED_SLOW = 0x01, // Slower speed
|
||||
CM_SMALL_ARGB_SPEED_NORMAL = 0x02, // Normal speed
|
||||
CM_SMALL_ARGB_SPEED_FAST = 0x03, // Fast speed
|
||||
CM_SMALL_ARGB_SPEED_FASTEST = 0x04, // Fastest speed
|
||||
};
|
||||
|
||||
class CMSmallARGBController
|
||||
{
|
||||
public:
|
||||
CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx);
|
||||
~CMSmallARGBController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
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(unsigned char mode, unsigned char speed, RGBColor colour, bool random_colours);
|
||||
void SetLedsDirect(RGBColor * led_colours, unsigned int led_count);
|
||||
private:
|
||||
std::string device_name;
|
||||
std::string serial;
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
|
||||
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;
|
||||
|
||||
unsigned int GetLargestColour(unsigned int red, unsigned int green, unsigned int blue);
|
||||
unsigned char GetColourIndex(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void GetStatus();
|
||||
void SendUpdate();
|
||||
};
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
#include "Detector.h"
|
||||
#include "CMMP750Controller.h"
|
||||
#include "CMARGBcontroller.h"
|
||||
#include "CMSmallARGBController.h"
|
||||
#include "CMR6000Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CMMP750Controller.h"
|
||||
#include "RGBController_CMARGBController.h"
|
||||
#include "RGBController_CMSmallARGBController.h"
|
||||
#include "RGBController_CMR6000Controller.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
|
|
@ -13,6 +15,7 @@
|
|||
#define COOLERMASTER_MP750_XL_PID 0x0109
|
||||
#define COOLERMASTER_MP750_MEDIUM_PID 0x0105
|
||||
#define COOLERMASTER_ARGB_PID 0x1011
|
||||
#define COOLERMASTER_SMALL_ARGB_PID 0x1000
|
||||
#define COOLERMASTER_RADEON_6000_PID 0x014D
|
||||
|
||||
/******************************************************************************************\
|
||||
|
|
@ -50,6 +53,18 @@ void DetectCoolerMasterARGB(hid_device_info* info, const std::string&)
|
|||
}
|
||||
}
|
||||
|
||||
void DetectCoolerMasterSmallARGB(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path, 0);
|
||||
RGBController_CMSmallARGBController* rgb_controller = new RGBController_CMSmallARGBController(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectCoolerMasterGPU(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
|
@ -65,4 +80,5 @@ void DetectCoolerMasterGPU(hid_device_info* info, const std::string&)
|
|||
REGISTER_HID_DETECTOR_IPU("Cooler Master MP750 XL", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_XL_PID, 0, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cooler Master MP750 Medium", DetectCoolerMasterMousemats, COOLERMASTER_VID, COOLERMASTER_MP750_MEDIUM_PID, 0, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cooler Master ARGB", DetectCoolerMasterARGB, COOLERMASTER_VID, COOLERMASTER_ARGB_PID, 0, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cooler Master Smalll ARGB", DetectCoolerMasterSmallARGB, COOLERMASTER_VID, COOLERMASTER_SMALL_ARGB_PID, 0, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_I("Cooler Master Radeon 6000 GPU",DetectCoolerMasterGPU, COOLERMASTER_VID, COOLERMASTER_RADEON_6000_PID, 1);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,251 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMSmallARGBController.cpp |
|
||||
| |
|
||||
| Driver for Coolermaster Small ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 31st Jan 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_CMSmallARGBController.h"
|
||||
|
||||
RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmallARGBController *cmargb_ptr)
|
||||
{
|
||||
cmargb = cmargb_ptr;
|
||||
unsigned char speed = cmargb->GetLedSpeed();
|
||||
|
||||
name = small_argb_header_data[cmargb->GetZoneIndex()].name;
|
||||
vendor = "Cooler Master";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = cmargb->GetDeviceName();
|
||||
version = "1.0";
|
||||
serial = cmargb->GetSerial();
|
||||
location = cmargb->GetLocation();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Turn Off";
|
||||
Off.value = CM_SMALL_ARGB_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Reload;
|
||||
Reload.name = "Reload";
|
||||
Reload.value = CM_SMALL_ARGB_MODE_RELOAD;
|
||||
Reload.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Reload.colors_min = 1;
|
||||
Reload.colors_max = 1;
|
||||
Reload.colors.resize(Reload.colors_max);
|
||||
Reload.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Reload.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Reload.color_mode = MODE_COLORS_RANDOM;
|
||||
Reload.speed = speed;
|
||||
modes.push_back(Reload);
|
||||
|
||||
mode Recoil;
|
||||
Recoil.name = "Recoil";
|
||||
Recoil.value = CM_SMALL_ARGB_MODE_RECOIL;
|
||||
Recoil.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Recoil.colors_min = 1;
|
||||
Recoil.colors_max = 1;
|
||||
Recoil.colors.resize(Recoil.colors_max);
|
||||
Recoil.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Recoil.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Recoil.color_mode = MODE_COLORS_RANDOM;
|
||||
Recoil.speed = speed;
|
||||
modes.push_back(Recoil);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = CM_SMALL_ARGB_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(Breathing.colors_max);
|
||||
Breathing.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Breathing.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Breathing.color_mode = MODE_COLORS_RANDOM;
|
||||
Breathing.speed = speed;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Refill;
|
||||
Refill.name = "Refill";
|
||||
Refill.value = CM_SMALL_ARGB_MODE_REFILL;
|
||||
Refill.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
|
||||
Refill.colors_min = 1;
|
||||
Refill.colors_max = 1;
|
||||
Refill.colors.resize(Refill.colors_max);
|
||||
Refill.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Refill.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Refill.color_mode = MODE_COLORS_RANDOM;
|
||||
Refill.speed = speed;
|
||||
modes.push_back(Refill);
|
||||
|
||||
mode Demo;
|
||||
Demo.name = "Demo";
|
||||
Demo.value = CM_SMALL_ARGB_MODE_DEMO;
|
||||
Demo.flags = MODE_FLAG_HAS_SPEED;
|
||||
Demo.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Demo.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Demo.color_mode = MODE_COLORS_NONE;
|
||||
Demo.speed = speed;
|
||||
modes.push_back(Demo);
|
||||
|
||||
mode Spectrum;
|
||||
Spectrum.name = "Spectrum";
|
||||
Spectrum.value = CM_SMALL_ARGB_MODE_SPECTRUM;
|
||||
Spectrum.flags = MODE_FLAG_HAS_SPEED;
|
||||
Spectrum.speed_min = CM_SMALL_ARGB_SPEED_SLOWEST;
|
||||
Spectrum.speed_max = CM_SMALL_ARGB_SPEED_FASTEST;
|
||||
Spectrum.color_mode = MODE_COLORS_NONE;
|
||||
Spectrum.speed = speed;
|
||||
modes.push_back(Spectrum);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = CM_SMALL_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_SMALL_ARGB_MODE_PASSTHRU;
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
|
||||
Init_Controller(); //Only processed on first run
|
||||
SetupZones();
|
||||
|
||||
int temp_mode = cmargb->GetMode();
|
||||
for(std::size_t mode_idx = 0; mode_idx < modes.size() ; mode_idx++)
|
||||
{
|
||||
if (temp_mode == modes[mode_idx].value)
|
||||
{
|
||||
active_mode = mode_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
|
||||
{
|
||||
modes[active_mode].colors[0] = ToRGBColor(cmargb->GetLedRed(), cmargb->GetLedGreen(), cmargb->GetLedBlue());
|
||||
}
|
||||
modes[active_mode].color_mode = (cmargb->GetRandomColours()) ? MODE_COLORS_RANDOM : MODE_COLORS_MODE_SPECIFIC;
|
||||
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
modes[active_mode].speed = cmargb->GetLedSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_CMSmallARGBController::~RGBController_CMSmallARGBController()
|
||||
{
|
||||
delete cmargb;
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::Init_Controller()
|
||||
{
|
||||
int zone_idx = cmargb->GetZoneIndex();
|
||||
int zone_led_count = small_argb_header_data[zone_idx].count;
|
||||
bool boolSingleLED = ( zone_led_count == 1 ); //If argb_header_data[zone_idx].count == 1 then the zone is ZONE_TYPE_SINGLE
|
||||
|
||||
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 = CM_SMALL_ARGB_MIN_LEDS;
|
||||
ARGB_zone.leds_max = CM_SMALL_ARGB_MAX_LEDS;
|
||||
ARGB_zone.leds_count = zone_led_count;
|
||||
ARGB_zone.matrix_map = NULL;
|
||||
zones.push_back(ARGB_zone);
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE); //Calculated for later use
|
||||
|
||||
if (!boolSingleLED)
|
||||
{
|
||||
cmargb->SetLedCount(small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if(boolSingleLED)
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.value = small_argb_header_data[i].header;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.name.append(" LED " + std::to_string(lp_idx));
|
||||
new_led.value = small_argb_header_data[i].header;
|
||||
}
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::DeviceUpdateLEDs()
|
||||
{
|
||||
for(size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
UpdateZoneLEDs(zone_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
bool random_colours = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
|
||||
|
||||
//cmargb->SetLedsDirect(zones[zone].colors, random_colours);
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::UpdateSingleLED(int led)
|
||||
{
|
||||
//cmargb->SetMode( modes[active_mode].value, modes[active_mode].speed );
|
||||
//cmargb->SetLedsDirect( zones[0].colors, zones[0].leds_count );
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::SetCustomMode()
|
||||
{
|
||||
active_mode = CM_SMALL_ARGB_MODE_DIRECT; //The small ARGB may not support "Direct" mode
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::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;
|
||||
|
||||
cmargb->SetMode( modes[active_mode].value, modes[active_mode].speed, colour, random_colours );
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_CMSmallARGBController.h |
|
||||
| |
|
||||
| Driver for Coolermaster Small ARGB USB Controller |
|
||||
| |
|
||||
| Chris M (Dr_No) 31st Jan 2021 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "CMSmallARGBController.h"
|
||||
#include <vector>
|
||||
|
||||
#define CM_SMALL_ARGB_MIN_LEDS 4
|
||||
#define CM_SMALL_ARGB_MAX_LEDS 48
|
||||
|
||||
class RGBController_CMSmallARGBController : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CMSmallARGBController(CMSmallARGBController* cmargb_ptr);
|
||||
~RGBController_CMSmallARGBController();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
private:
|
||||
void Init_Controller();
|
||||
int GetDeviceMode();
|
||||
|
||||
CMSmallARGBController* cmargb;
|
||||
};
|
||||
|
|
@ -165,9 +165,11 @@ HEADERS +=
|
|||
Controllers/AsusAuraUSBController/RGBController_AsusAuraUSB.h \
|
||||
Controllers/CoolerMasterController/CMARGBcontroller.h \
|
||||
Controllers/CoolerMasterController/CMMP750Controller.h \
|
||||
Controllers/CoolerMasterController/CMSmallARGBController.h \
|
||||
Controllers/CoolerMasterController/CMR6000Controller.h \
|
||||
Controllers/CoolerMasterController/RGBController_CMARGBController.h \
|
||||
Controllers/CoolerMasterController/RGBController_CMMP750Controller.h \
|
||||
Controllers/CoolerMasterController/RGBController_CMSmallARGBController.h \
|
||||
Controllers/CoolerMasterController/RGBController_CMR6000Controller.h \
|
||||
Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumController.h \
|
||||
Controllers/CorsairDominatorPlatinumController/RGBController_CorsairDominatorPlatinum.h \
|
||||
|
|
@ -372,10 +374,12 @@ SOURCES +=
|
|||
Controllers/AsusAuraUSBController/RGBController_AsusAuraUSB.cpp \
|
||||
Controllers/CoolerMasterController/CMARGBcontroller.cpp \
|
||||
Controllers/CoolerMasterController/CMMP750Controller.cpp \
|
||||
Controllers/CoolerMasterController/CMSmallARGBController.cpp \
|
||||
Controllers/CoolerMasterController/CMR6000Controller.cpp \
|
||||
Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp \
|
||||
Controllers/CoolerMasterController/RGBController_CMARGBController.cpp \
|
||||
Controllers/CoolerMasterController/RGBController_CMMP750Controller.cpp \
|
||||
Controllers/CoolerMasterController/RGBController_CMSmallARGBController.cpp \
|
||||
Controllers/CoolerMasterController/RGBController_CMR6000Controller.cpp \
|
||||
Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumController.cpp \
|
||||
Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumControllerDetect.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue