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:
Adam Honse
2026-02-22 23:31:00 -06:00
parent 3cffbd45b5
commit 02b9f3b299
114 changed files with 4008 additions and 2971 deletions

View File

@@ -46,8 +46,11 @@ static unsigned int debug_keyboard_underglow_map[3][10] =
{ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 },
{ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 } };
RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_settings)
RGBController_Debug::RGBController_Debug(bool custom, json settings)
{
custom_controller = custom;
debug_settings = settings;
if(custom_controller)
{
/*-------------------------------------------------*\
@@ -80,19 +83,109 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
location = debug_settings["DeviceLocation"];
version = debug_settings["DeviceVersion"];
serial = debug_settings["DeviceSerial"];
}
else
{
std::string name_setting = "";
std::string type_setting = "keyboard";
/*-------------------------------------------------*\
| Create the mode |
\*-------------------------------------------------*/
mode Direct;
if(debug_settings.contains("name"))
{
name_setting = debug_settings["name"];
}
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
if(debug_settings.contains("type"))
{
type_setting = debug_settings["type"];
}
modes.push_back(Direct);
if(type_setting == "motherboard")
{
name = "Debug Motherboard";
type = DEVICE_TYPE_MOTHERBOARD;
}
else if(type_setting == "dram")
{
name = "Debug DRAM";
type = DEVICE_TYPE_DRAM;
}
else if(type_setting == "gpu")
{
name = "Debug GPU";
type = DEVICE_TYPE_GPU;
}
else if(type_setting == "keyboard")
{
name = "Debug Keyboard";
type = DEVICE_TYPE_KEYBOARD;
}
else if(type_setting == "mouse")
{
name = "Debug Mouse";
type = DEVICE_TYPE_MOUSE;
}
else if(type_setting == "argb")
{
name = "Debug ARGB Controller";
type = DEVICE_TYPE_LEDSTRIP;
}
/*---------------------------------------------------------*\
| Fill in debug controller information |
\*---------------------------------------------------------*/
description = name + " Device";
vendor = name + " Vendor String";
location = name + " Location String";
version = name + " Version String";
serial = name + " Serial String";
if(name_setting != "")
{
name = name_setting;
}
}
/*-----------------------------------------------------*\
| Create the mode |
\*-----------------------------------------------------*/
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
RGBController_Debug::~RGBController_Debug()
{
Shutdown();
}
void RGBController_Debug::SetupZones()
{
/*-------------------------------------------------*\
| Only set LED count on the first run |
\*-------------------------------------------------*/
bool first_run = false;
std::size_t zone_idx = 0;
if(zones.size() == 0)
{
first_run = true;
}
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
leds.clear();
colors.clear();
if(custom_controller)
{
/*-------------------------------------------------*\
| Fill in zones |
\*-------------------------------------------------*/
@@ -237,28 +330,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
zones.push_back(custom_zone);
}
SetupColors();
}
else
{
bool zone_single = true;
bool zone_linear = true;
bool zone_resizable = false;
bool zone_keyboard = false;
bool zone_underglow = false;
std::string name_setting = "";
std::string type_setting = "keyboard";
if(debug_settings.contains("name"))
{
name_setting = debug_settings["name"];
}
if(debug_settings.contains("type"))
{
type_setting = debug_settings["type"];
}
bool zone_single = true;
bool zone_linear = true;
bool zone_resizable = false;
bool zone_keyboard = false;
bool zone_underglow = false;
if(debug_settings.contains("single"))
{
@@ -285,66 +364,9 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
zone_underglow = debug_settings["underglow"];
}
if(type_setting == "motherboard")
{
name = "Debug Motherboard";
type = DEVICE_TYPE_MOTHERBOARD;
}
else if(type_setting == "dram")
{
name = "Debug DRAM";
type = DEVICE_TYPE_DRAM;
}
else if(type_setting == "gpu")
{
name = "Debug GPU";
type = DEVICE_TYPE_GPU;
}
else if(type_setting == "keyboard")
{
name = "Debug Keyboard";
type = DEVICE_TYPE_KEYBOARD;
}
else if(type_setting == "mouse")
{
name = "Debug Mouse";
type = DEVICE_TYPE_MOUSE;
}
else if(type_setting == "argb")
{
name = "Debug ARGB Controller";
type = DEVICE_TYPE_LEDSTRIP;
}
/*---------------------------------------------------------*\
| Fill in debug controller information |
\*---------------------------------------------------------*/
description = name + " Device";
vendor = name + " Vendor String";
location = name + " Location String";
version = name + " Version String";
serial = name + " Serial String";
if(name_setting != "")
{
name = name_setting;
}
/*---------------------------------------------------------*\
| Create a direct mode |
\*---------------------------------------------------------*/
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
/*---------------------------------------------------------*\
| Create a single zone/LED |
\*---------------------------------------------------------*/
/*-------------------------------------------------*\
| Create a single zone/LED |
\*-------------------------------------------------*/
if(zone_single)
{
zone single_zone;
@@ -355,7 +377,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
single_zone.leds_max = 1;
single_zone.leds_count = 1;
zones.push_back(single_zone);
if(first_run)
{
zones.push_back(single_zone);
}
else
{
zones[zone_idx] = single_zone;
}
led single_led;
@@ -364,11 +393,13 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
leds.push_back(single_led);
led_alt_names.push_back("");
zone_idx++;
}
/*---------------------------------------------------------*\
| Create a linear zone |
\*---------------------------------------------------------*/
/*-------------------------------------------------*\
| Create a linear zone |
\*-------------------------------------------------*/
if(zone_linear)
{
zone linear_zone;
@@ -379,7 +410,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
linear_zone.leds_max = 10;
linear_zone.leds_count = 10;
zones.push_back(linear_zone);
if(first_run)
{
zones.push_back(linear_zone);
}
else
{
zones[zone_idx] = linear_zone;
}
for(std::size_t led_idx = 0; led_idx < 10; led_idx++)
{
@@ -391,10 +429,13 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
led_alt_names.push_back("");
}
zone_idx++;
}
/*---------------------------------------------------------*\
| Create a keyboard matrix zone |
\*---------------------------------------------------------*/
/*-------------------------------------------------*\
| Create a keyboard matrix zone |
\*-------------------------------------------------*/
if(zone_keyboard)
{
KEYBOARD_LAYOUT layout = KEYBOARD_LAYOUT::KEYBOARD_LAYOUT_ANSI_QWERTY;
@@ -419,9 +460,9 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
description += ", Layout: " + layout_names[layout] + ", Size: " + new_kb.GetName();
/*-----------------------------------------------------*\
| Check for custom key inserts and swaps |
\*-----------------------------------------------------*/
/*---------------------------------------------*\
| Check for custom key inserts and swaps |
\*---------------------------------------------*/
const char* change_keys = "change_keys";
if(debug_settings.contains(change_keys))
@@ -486,7 +527,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
keyboard_zone.leds_count = new_kb.GetKeyCount();
keyboard_zone.matrix_map = new_kb.GetKeyMap(KEYBOARD_MAP_FILL_TYPE_COUNT);
zones.push_back(keyboard_zone);
if(first_run)
{
zones.push_back(keyboard_zone);
}
else
{
zones[zone_idx] = keyboard_zone;
}
for(unsigned int led_idx = 0; led_idx < keyboard_zone.leds_count; led_idx++)
{
@@ -498,10 +546,13 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
led_alt_names.push_back(new_kb.GetKeyAltNameAt(led_idx));
}
zone_idx++;
}
/*---------------------------------------------------------*\
| Create an underglow matrix zone |
\*---------------------------------------------------------*/
/*-------------------------------------------------*\
| Create an underglow matrix zone |
\*-------------------------------------------------*/
if(zone_underglow)
{
zone underglow_zone;
@@ -513,7 +564,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
underglow_zone.leds_count = 30;
underglow_zone.matrix_map.Set(3, 10, (unsigned int*)&debug_keyboard_underglow_map);
zones.push_back(underglow_zone);
if(first_run)
{
zones.push_back(underglow_zone);
}
else
{
zones[zone_idx] = underglow_zone;
}
for(std::size_t led_idx = 0; led_idx < underglow_zone.leds_count; led_idx++)
{
@@ -525,70 +583,75 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
led_alt_names.push_back("");
}
zone_idx++;
}
/*---------------------------------------------------------*\
| Create a resizable linear zone |
\*---------------------------------------------------------*/
/*-------------------------------------------------*\
| Create a resizable linear zone |
\*-------------------------------------------------*/
if(zone_resizable)
{
zone resizable_zone;
resizable_zone.name = "Resizable Zone";
resizable_zone.type = ZONE_TYPE_LINEAR;
resizable_zone.leds_min = 0;
resizable_zone.leds_max = 100;
resizable_zone.leds_count = 0;
zones.push_back(resizable_zone);
if(first_run)
{
resizable_zone.flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
zones.push_back(resizable_zone);
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
zones[zone_idx].name = "Resizable Zone";
}
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(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led resizable_led;
resizable_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx);
leds.push_back(resizable_led);
led_alt_names.push_back("");
}
zone_idx++;
}
}
SetupColors();
}
RGBController_Debug::~RGBController_Debug()
void RGBController_Debug::DeviceConfigureZone(int zone_idx)
{
Shutdown();
}
void RGBController_Debug::DeviceResizeZone(int index, int new_size)
{
//Make sure that it isn't out of bounds (negative numbers)
if(new_size < int(zones[index].leds_min))
if((size_t)zone_idx < zones.size())
{
new_size = zones[index].leds_min;
SetupZones();
}
// Same thing as the above line except for over 100
if(new_size > int(zones[index].leds_max))
{
new_size = zones[index].leds_max;
}
// Store the previous amount of LEDs
int old_size = zones[index].leds_count;
// Set the LED count in the zone to the new ammount
zones[index].leds_count = new_size;
// Set the new ammount of LEDs for to the new size
size_t old_leds_size = leds.size();
// Add the new ammount of LEDs to the old ammount
size_t new_leds_size = leds.size() - old_size + new_size;
leds.resize(std::max(old_leds_size, new_leds_size));
memmove((void *)(&leds[zones[index].start_idx] + old_leds_size), (const void *)(&leds[zones[index].start_idx] + new_leds_size), (old_leds_size - zones[index].start_idx - old_size) * sizeof(led));
leds.resize(new_leds_size);
for(int i = 0; i < new_size; ++i)
{
leds[zones[index].start_idx + i].name = "Linear LED " + std::to_string(i);
}
SetupColors();
}
void RGBController_Debug::DeviceUpdateLEDs()