mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 14:35:01 -04:00
Zone and Segment type updates
* Add zone flags to indicate if fields are manually configurable and if they have been manually configured * Add flags field to segment type * Add segment flags for group start and group member * Add color mode support flags to zone (RGB, RBG, GRB, GBR, BRG, BGR) * Add color mode enum to zone * Update zone and segment description functions to support new fields * Rename the effects-only configurable size flag * Remove zone type and matrix map configuration from E1.31 manual configuration, use zone editor instead * Rework DeviceResizeZone to DeviceConfigureZone * Rework most ARGB controllers to allow zone customizations * Rework DRGBController to define devices in DRGBDevices list (similar to RazerDevices) * Rework NollieController to define devices in NollieDevices list (similar to RazerDevices)
This commit is contained in:
@@ -398,29 +398,46 @@ void RGBController_CMARGBController::SetupZones()
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int channel_idx = 0; channel_idx < 4; channel_idx++)
|
||||
{
|
||||
char ch_idx_string[2];
|
||||
snprintf(ch_idx_string, 2, "%d", channel_idx + 1);
|
||||
|
||||
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;
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = 48;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[channel_idx].leds_count = 0;
|
||||
zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
|
||||
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
|
||||
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
|
||||
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
|
||||
}
|
||||
|
||||
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
|
||||
{
|
||||
zones[channel_idx].name = "Addressable RGB Header ";
|
||||
zones[channel_idx].name.append(std::to_string(channel_idx + 1));
|
||||
}
|
||||
|
||||
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
|
||||
{
|
||||
zones[channel_idx].leds_count = 0;
|
||||
}
|
||||
|
||||
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
|
||||
{
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
}
|
||||
|
||||
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
|
||||
{
|
||||
zones[channel_idx].matrix_map.width = 0;
|
||||
zones[channel_idx].matrix_map.height = 0;
|
||||
zones[channel_idx].matrix_map.map.resize(0);
|
||||
}
|
||||
|
||||
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.name.append(std::to_string(led_ch_idx + 1));
|
||||
new_led.value = channel_idx;
|
||||
|
||||
leds.push_back(new_led);
|
||||
@@ -444,18 +461,11 @@ void RGBController_CMARGBController::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CMARGBController::DeviceResizeZone(int zone, int new_size)
|
||||
void RGBController_CMARGBController::DeviceConfigureZone(int zone_idx)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
if((size_t)zone_idx < 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;
|
||||
|
||||
controller->SetPortLEDCount(zone, zones[zone].leds_count);
|
||||
controller->SetPortLEDCount(zone_idx, zones[zone_idx].leds_count);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
void SetupModes();
|
||||
void SetupZones();
|
||||
|
||||
void DeviceResizeZone(int zone, int new_size);
|
||||
void DeviceConfigureZone(int zone_idx);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void DeviceUpdateZoneLEDs(int zone);
|
||||
|
||||
@@ -220,10 +220,8 @@ void RGBController_CMARGBGen2A1Controller::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CMARGBGen2A1Controller::DeviceResizeZone(int zone, int new_size)
|
||||
void RGBController_CMARGBGen2A1Controller::DeviceConfigureZone(int zone_idx)
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
unsigned int total_leds = 0;
|
||||
|
||||
for(unsigned int channel = 0; channel < CM_ARGB_GEN2_A1_CHANNEL_COUNT; channel++)
|
||||
@@ -238,7 +236,7 @@ void RGBController_CMARGBGen2A1Controller::DeviceResizeZone(int zone, int new_si
|
||||
leds[i].name = "LED " + std::to_string(i + 1);
|
||||
}
|
||||
|
||||
controller->SetupZoneSize(zone, new_size);
|
||||
controller->SetupZoneSize(zone_idx, zones[zone_idx].leds_count);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
~RGBController_CMARGBGen2A1Controller();
|
||||
|
||||
void SetupZones();
|
||||
void DeviceResizeZone(int zone, int new_size);
|
||||
void DeviceConfigureZone(int zone_idx);
|
||||
void DeviceUpdateLEDs();
|
||||
void DeviceUpdateZoneLEDs(int zone);
|
||||
void UpdateSegmentLEDs(int zone, int subchannel);
|
||||
|
||||
@@ -18,11 +18,10 @@ cm_small_argb_headers cm_small_argb_header_data[1] =
|
||||
{ "CM Small ARGB", 0x01, true, 12 }
|
||||
};
|
||||
|
||||
CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx)
|
||||
CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
zone_index = _zone_idx;
|
||||
current_speed = CM_SMALL_ARGB_SPEED_NORMAL;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -51,7 +50,7 @@ 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;
|
||||
int header = 0 - 1;
|
||||
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = header;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x01;
|
||||
@@ -98,11 +97,6 @@ std::string CMSmallARGBController::GetLocation()
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetZoneIndex()
|
||||
{
|
||||
return(zone_index);
|
||||
}
|
||||
|
||||
unsigned char CMSmallARGBController::GetMode()
|
||||
{
|
||||
return(current_mode);
|
||||
@@ -177,7 +171,7 @@ void CMSmallARGBController::SetLedsDirect(RGBColor* led_colours, unsigned int le
|
||||
colours.push_back( RGBGetBValue(colour) );
|
||||
}
|
||||
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = zone_index - 1; //argb_header_data[zone_index].header;
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = 0 - 1; //argb_header_data[zone_index].header;
|
||||
buffer[CM_SMALL_ARGB_MODE_BYTE] = led_count;
|
||||
unsigned char buffer_idx = CM_SMALL_ARGB_MODE_BYTE + 1;
|
||||
|
||||
@@ -225,7 +219,7 @@ void CMSmallARGBController::SendUpdate()
|
||||
|
||||
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] = cm_small_argb_header_data[zone_index].header;
|
||||
buffer[CM_SMALL_ARGB_ZONE_BYTE] = cm_small_argb_header_data[0].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
|
||||
|
||||
@@ -74,14 +74,13 @@ enum
|
||||
class CMSmallARGBController
|
||||
{
|
||||
public:
|
||||
CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx);
|
||||
CMSmallARGBController(hid_device* dev_handle, char *_path);
|
||||
~CMSmallARGBController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
unsigned char GetZoneIndex();
|
||||
unsigned char GetMode();
|
||||
unsigned char GetLedRed();
|
||||
unsigned char GetLedGreen();
|
||||
@@ -97,7 +96,6 @@ private:
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
|
||||
unsigned char zone_index;
|
||||
unsigned char current_mode;
|
||||
unsigned char current_speed;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmall
|
||||
controller = controller_ptr;
|
||||
unsigned char speed = controller->GetLedSpeed();
|
||||
|
||||
name = cm_small_argb_header_data[controller->GetZoneIndex()].name;
|
||||
name = cm_small_argb_header_data[0].name;
|
||||
vendor = "Cooler Master";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = controller->GetDeviceName();
|
||||
@@ -152,7 +152,6 @@ RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmall
|
||||
PassThru.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(PassThru);
|
||||
|
||||
Init_Controller(); //Only processed on first run
|
||||
SetupZones();
|
||||
|
||||
int temp_mode = controller->GetMode();
|
||||
@@ -186,57 +185,69 @@ RGBController_CMSmallARGBController::~RGBController_CMSmallARGBController()
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::Init_Controller()
|
||||
{
|
||||
int zone_idx = controller->GetZoneIndex();
|
||||
int zone_led_count = cm_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;
|
||||
zones.push_back(ARGB_zone);
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::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(1);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up zones and LEDs |
|
||||
\*-----------------------------------------------------*/
|
||||
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
|
||||
zones[zone_idx].leds_min = 0;
|
||||
zones[zone_idx].leds_max = CM_SMALL_ARGB_MAX_LEDS;
|
||||
|
||||
if (!boolSingleLED)
|
||||
if(first_run)
|
||||
{
|
||||
controller->SetLedCount(cm_small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count);
|
||||
zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
|
||||
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
|
||||
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
|
||||
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
|
||||
}
|
||||
|
||||
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
|
||||
{
|
||||
zones[zone_idx].name = "Addressable RGB Header";
|
||||
zones[zone_idx].name.append(std::to_string(zone_idx + 1));
|
||||
}
|
||||
|
||||
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
|
||||
{
|
||||
zones[zone_idx].leds_count = 0;
|
||||
}
|
||||
|
||||
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
|
||||
{
|
||||
zones[zone_idx].type = ZONE_TYPE_LINEAR;
|
||||
}
|
||||
|
||||
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
|
||||
{
|
||||
zones[zone_idx].matrix_map.width = 0;
|
||||
zones[zone_idx].matrix_map.height = 0;
|
||||
zones[zone_idx].matrix_map.map.resize(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);
|
||||
|
||||
if(boolSingleLED)
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.value = cm_small_argb_header_data[i].header;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_led.name = i;
|
||||
new_led.name.append(" LED " + std::to_string(lp_idx));
|
||||
new_led.value = cm_small_argb_header_data[i].header;
|
||||
}
|
||||
led new_led;
|
||||
new_led.name = zones[zone_idx].name;
|
||||
new_led.name.append(", LED " + std::to_string(lp_idx));
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
@@ -245,16 +256,11 @@ void RGBController_CMSmallARGBController::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CMSmallARGBController::DeviceResizeZone(int zone, int new_size)
|
||||
void RGBController_CMSmallARGBController::DeviceConfigureZone(int zone_idx)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
if((size_t)zone_idx < 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;
|
||||
controller->SetLedCount(cm_small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
~RGBController_CMSmallARGBController();
|
||||
|
||||
void SetupZones();
|
||||
void DeviceResizeZone(int zone, int new_size);
|
||||
void DeviceConfigureZone(int zone_idx);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void DeviceUpdateZoneLEDs(int zone);
|
||||
|
||||
@@ -326,7 +326,7 @@ DetectedControllers DetectCoolerMasterSmallARGB(hid_device_info* info, const std
|
||||
|
||||
if(dev)
|
||||
{
|
||||
CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path, 0);
|
||||
CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path);
|
||||
RGBController_CMSmallARGBController* rgb_controller = new RGBController_CMSmallARGBController(controller);
|
||||
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
|
||||
Reference in New Issue
Block a user