RGBController API Overhaul

* Reorganize and clean up RGBController API functions
    * Add functions to get protected RGBController member values
    * Make NetworkClient, ProfileManager, and ResourceManager friend classes so they can access protected members
    * Protected previously-public RGBController members
        * Information strings (name, vendor, description, version, serial location)
        * Device type
        * Active mode
        * Flags
        * LEDs vector
        * LED alternate names vector
        * Modes vector
        * Colors vector
        * Zones vector
    * Add CONTROLLER_FLAG_HIDDEN to allow plugins to hide controllers from control GUI
    * Add update reason codes to RGBController update callback and signal updates on more RGBController events
    * Add loop zone types and segmented zone type
    * Add matrix map field to segments
    * Rework matrix_map_type from using pointers to vector to prevent memory leaks
    * Rework KeyboardLayoutManager to return new matrix_map_type
    * Add access mutex to RGBController API
    * Add per-zone modes ot RGBController API
    * Add JSON description functions to RGBController API
This commit is contained in:
Adam Honse
2025-09-23 20:38:37 -05:00
parent fa20f4319a
commit dfd8656d9f
655 changed files with 9459 additions and 9022 deletions

View File

@@ -83,7 +83,6 @@ void RGBController_SteelSeriesApex3::SetupZones()
curr_zone.leds_min = led_count;
curr_zone.leds_max = led_count;
curr_zone.leds_count = led_count;
curr_zone.matrix_map = NULL;
zones.push_back(curr_zone);
for(size_t i = 0; i < curr_zone.leds_count; i++)
@@ -96,24 +95,17 @@ void RGBController_SteelSeriesApex3::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesApex3::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesApex3::DeviceUpdateLEDs()
{
controller->SetColor(colors, modes[active_mode].value, modes[active_mode].brightness);
}
void RGBController_SteelSeriesApex3::UpdateZoneLEDs(int /*zone*/)
void RGBController_SteelSeriesApex3::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_SteelSeriesApex3::UpdateSingleLED(int /*led*/)
void RGBController_SteelSeriesApex3::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -27,11 +27,10 @@ public:
~RGBController_SteelSeriesApex3();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceSaveMode();

View File

@@ -65,18 +65,6 @@ RGBController_SteelSeriesApex::RGBController_SteelSeriesApex(SteelSeriesApexBase
RGBController_SteelSeriesApex::~RGBController_SteelSeriesApex()
{
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
free(zones[zone_index].matrix_map->map);
delete zones[zone_index].matrix_map;
}
}
delete controller;
}
@@ -103,18 +91,15 @@ void RGBController_SteelSeriesApex::SetupZones()
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->map = (unsigned int *) malloc(matrix_mapsize*sizeof(unsigned int));
new_zone.matrix_map.height = MATRIX_HEIGHT;
new_zone.matrix_map.width = MATRIX_WIDTH;
new_zone.matrix_map.map.resize(MATRIX_HEIGHT * MATRIX_WIDTH);
if((proto_type == APEX) || (proto_type == APEX_M) || (proto_type == APEX_9_TKL) || (proto_type == APEX_9_MINI))
{
SetSkuRegion(*new_zone.matrix_map, sku);
SetSkuRegion(&new_zone.matrix_map, sku);
}
}
else
{
new_zone.matrix_map = NULL;
}
if((proto_type == APEX) || (proto_type == APEX_M) || (proto_type == APEX_9_TKL) || (proto_type == APEX_9_MINI))
{
@@ -130,25 +115,18 @@ void RGBController_SteelSeriesApex::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesApex::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesApex::DeviceUpdateLEDs()
{
last_update_time = std::chrono::steady_clock::now();
controller->SetLEDsDirect(colors);
}
void RGBController_SteelSeriesApex::UpdateZoneLEDs(int /*zone*/)
void RGBController_SteelSeriesApex::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_SteelSeriesApex::UpdateSingleLED(int /*led*/)
void RGBController_SteelSeriesApex::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -23,11 +23,10 @@ public:
~RGBController_SteelSeriesApex();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();

View File

@@ -434,12 +434,10 @@ static const std::map<std::string, sku_patch> patch_lookup =
{ "64533", { {}, apex_iso_region_patch, apex_nor_keyname_lookup }},
};
static void SetSkuRegion (matrix_map_type& input, std::string& sku)
static void SetSkuRegion(matrix_map_type* input, std::string& sku)
{
std::map<std::string, sku_patch>::const_iterator it = patch_lookup.find(sku);
unsigned int local_matrix [MATRIX_HEIGHT][MATRIX_WIDTH] = MATRIX_MAP_ANSI;
input.height = MATRIX_HEIGHT;
input.width = MATRIX_WIDTH;
if(it != patch_lookup.end())
{
@@ -452,7 +450,7 @@ static void SetSkuRegion (matrix_map_type& input, std::string& sku)
local_matrix[it->second.region_patch[i].row][it->second.region_patch[i].column] = it->second.region_patch[i].value;
}
}
memcpy(input.map, (unsigned int *)local_matrix, sizeof(unsigned int)*MATRIX_HEIGHT*MATRIX_WIDTH);
memcpy(input->map.data(), (unsigned int *)local_matrix, sizeof(unsigned int)*MATRIX_HEIGHT*MATRIX_WIDTH);
}
static void SetSkuLedNames (std::vector<led>& input, std::string& sku, unsigned int led_count)

View File

@@ -64,7 +64,6 @@ void RGBController_SteelSeriesArctis5::SetupZones()
zone.leds_min = 1;
zone.leds_max = 1;
zone.leds_count = 1;
zone.matrix_map = NULL;
zones.push_back(zone);
led mouse_led;
@@ -75,29 +74,22 @@ void RGBController_SteelSeriesArctis5::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesArctis5::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesArctis5::DeviceUpdateLEDs()
{
for(unsigned int i = 0; i < zones.size(); i++)
{
UpdateZoneLEDs(i);
DeviceUpdateZoneLEDs(i);
}
}
void RGBController_SteelSeriesArctis5::UpdateZoneLEDs(int zone)
void RGBController_SteelSeriesArctis5::DeviceUpdateZoneLEDs(int zone)
{
controller->SetColor(zone, colors[zone]);
}
void RGBController_SteelSeriesArctis5::UpdateSingleLED(int led)
void RGBController_SteelSeriesArctis5::DeviceUpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
DeviceUpdateZoneLEDs(led);
}
void RGBController_SteelSeriesArctis5::DeviceUpdateMode()

View File

@@ -21,11 +21,10 @@ public:
~RGBController_SteelSeriesArctis5();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();

View File

@@ -62,7 +62,6 @@ void RGBController_SteelSeriesOldApex::SetupZones()
qwerty_zone.leds_min = 1;
qwerty_zone.leds_max = 1;
qwerty_zone.leds_count = 1;
qwerty_zone.matrix_map = NULL;
zones.push_back(qwerty_zone);
led qwerty_led;
@@ -75,7 +74,6 @@ void RGBController_SteelSeriesOldApex::SetupZones()
tenkey_zone.leds_min = 1;
tenkey_zone.leds_max = 1;
tenkey_zone.leds_count = 1;
tenkey_zone.matrix_map = NULL;
zones.push_back(tenkey_zone);
led tenkey_led;
@@ -88,7 +86,6 @@ void RGBController_SteelSeriesOldApex::SetupZones()
function_zone.leds_min = 1;
function_zone.leds_max = 1;
function_zone.leds_count = 1;
function_zone.matrix_map = NULL;
zones.push_back(function_zone);
led function_led;
@@ -101,7 +98,6 @@ void RGBController_SteelSeriesOldApex::SetupZones()
mx_zone.leds_min = 1;
mx_zone.leds_max = 1;
mx_zone.leds_count = 1;
mx_zone.matrix_map = NULL;
zones.push_back(mx_zone);
led mx_led;
@@ -114,7 +110,6 @@ void RGBController_SteelSeriesOldApex::SetupZones()
logo_zone.leds_min = 1;
logo_zone.leds_max = 1;
logo_zone.leds_count = 1;
logo_zone.matrix_map = NULL;
zones.push_back(logo_zone);
led logo_led;
@@ -124,13 +119,6 @@ void RGBController_SteelSeriesOldApex::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesOldApex::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesOldApex::DeviceUpdateLEDs()
{
// Due to the inefficient packet design of the OG Apex
@@ -168,7 +156,7 @@ void RGBController_SteelSeriesOldApex::DeviceUpdateLEDs()
controller->SetColorDetailed(qwerty, tenkey, functionkey, mxkey, logo);
}
void RGBController_SteelSeriesOldApex::UpdateZoneLEDs(int /*zone*/)
void RGBController_SteelSeriesOldApex::DeviceUpdateZoneLEDs(int /*zone*/)
{
// updating for one zone is pointless,
// all zones have to be blasted anyway
@@ -177,7 +165,7 @@ void RGBController_SteelSeriesOldApex::UpdateZoneLEDs(int /*zone*/)
}
void RGBController_SteelSeriesOldApex::UpdateSingleLED(int /*led*/)
void RGBController_SteelSeriesOldApex::DeviceUpdateSingleLED(int /*led*/)
{
// Each zone is one LED, however
// updating for one zone is pointless,

View File

@@ -27,11 +27,10 @@ public:
~RGBController_SteelSeriesOldApex();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();

View File

@@ -58,7 +58,6 @@ void RGBController_SteelSeriesQCKMat::SetupZones()
mousemat_zone.leds_min = 2;
mousemat_zone.leds_max = 2;
mousemat_zone.leds_count = 2;
mousemat_zone.matrix_map = NULL;
zones.push_back(mousemat_zone);
led bot_led;
@@ -72,19 +71,12 @@ void RGBController_SteelSeriesQCKMat::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesQCKMat::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesQCKMat::DeviceUpdateLEDs()
{
controller->SetColors(colors);
}
void RGBController_SteelSeriesQCKMat::UpdateZoneLEDs(int /*zone*/)
void RGBController_SteelSeriesQCKMat::DeviceUpdateZoneLEDs(int /*zone*/)
{
/*---------------------------------------------------------*\
| Packet expects both LEDs |
@@ -92,7 +84,7 @@ void RGBController_SteelSeriesQCKMat::UpdateZoneLEDs(int /*zone*/)
DeviceUpdateLEDs();
}
void RGBController_SteelSeriesQCKMat::UpdateSingleLED(int /*led*/)
void RGBController_SteelSeriesQCKMat::DeviceUpdateSingleLED(int /*led*/)
{
/*---------------------------------------------------------*\
| Packet expects both LEDs |

View File

@@ -21,11 +21,10 @@ public:
~RGBController_SteelSeriesQCKMat();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();

View File

@@ -128,7 +128,6 @@ void RGBController_SteelSeriesRival3::SetupZones()
zone.leds_min = 1;
zone.leds_max = 1;
zone.leds_count = 1;
zone.matrix_map = NULL;
zones.push_back(zone);
led mouse_led;
@@ -139,28 +138,21 @@ void RGBController_SteelSeriesRival3::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesRival3::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesRival3::DeviceUpdateLEDs()
{
for(unsigned int i = 0; i < zones.size(); i++)
{
UpdateZoneLEDs(i);
DeviceUpdateZoneLEDs(i);
}
DeviceUpdateMode();
}
void RGBController_SteelSeriesRival3::UpdateZoneLEDs(int zone)
void RGBController_SteelSeriesRival3::DeviceUpdateZoneLEDs(int zone)
{
UpdateSingleLED(zone);
DeviceUpdateSingleLED(zone);
}
void RGBController_SteelSeriesRival3::UpdateSingleLED(int led)
void RGBController_SteelSeriesRival3::DeviceUpdateSingleLED(int led)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);

View File

@@ -22,11 +22,10 @@ public:
~RGBController_SteelSeriesRival3();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceSaveMode();

View File

@@ -94,7 +94,6 @@ void RGBController_SteelSeriesRival::SetupZones()
logo_zone.leds_min = 1;
logo_zone.leds_max = 1;
logo_zone.leds_count = 1;
logo_zone.matrix_map = NULL;
zones.push_back(logo_zone);
led logo_led;
@@ -112,7 +111,6 @@ void RGBController_SteelSeriesRival::SetupZones()
wheel_zone.leds_min = 1;
wheel_zone.leds_max = 1;
wheel_zone.leds_count = 1;
wheel_zone.matrix_map = NULL;
zones.push_back(wheel_zone);
led wheel_led;
@@ -131,7 +129,6 @@ void RGBController_SteelSeriesRival::SetupZones()
wheel_zone.leds_min = 1;
wheel_zone.leds_max = 1;
wheel_zone.leds_count = 1;
wheel_zone.matrix_map = NULL;
zones.push_back(wheel_zone);
led wheel_led;
@@ -145,7 +142,6 @@ void RGBController_SteelSeriesRival::SetupZones()
mouse_zone.leds_min = 6;
mouse_zone.leds_max = 6;
mouse_zone.leds_count = 6;
mouse_zone.matrix_map = NULL;
zones.push_back(mouse_zone);
for(const steelseries_rival_led_info led_info: rival_650_leds)
@@ -167,7 +163,6 @@ void RGBController_SteelSeriesRival::SetupZones()
wheel_zone.leds_min = 1;
wheel_zone.leds_max = 1;
wheel_zone.leds_count = 1;
wheel_zone.matrix_map = NULL;
zones.push_back(wheel_zone);
led wheel_led;
@@ -181,7 +176,6 @@ void RGBController_SteelSeriesRival::SetupZones()
mouse_zone.leds_min = 6;
mouse_zone.leds_max = 6;
mouse_zone.leds_count = 6;
mouse_zone.matrix_map = NULL;
zones.push_back(mouse_zone);
for(const steelseries_rival_led_info led_info: rival_600_leds)
@@ -196,13 +190,6 @@ void RGBController_SteelSeriesRival::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesRival::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesRival::DeviceUpdateLEDs()
{
for(unsigned int i = 0; i < leds.size(); i++)
@@ -214,7 +201,7 @@ void RGBController_SteelSeriesRival::DeviceUpdateLEDs()
}
}
void RGBController_SteelSeriesRival::UpdateZoneLEDs(int zone)
void RGBController_SteelSeriesRival::DeviceUpdateZoneLEDs(int zone)
{
for(unsigned int i = 0; i < zones[zone].leds_count; i++)
{
@@ -225,7 +212,7 @@ void RGBController_SteelSeriesRival::UpdateZoneLEDs(int zone)
}
}
void RGBController_SteelSeriesRival::UpdateSingleLED(int led)
void RGBController_SteelSeriesRival::DeviceUpdateSingleLED(int led)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);

View File

@@ -21,11 +21,10 @@ public:
~RGBController_SteelSeriesRival();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceSaveMode();

View File

@@ -77,7 +77,6 @@ void RGBController_SteelSeriesSensei::SetupZones()
logo_zone.leds_min = 1;
logo_zone.leds_max = 1;
logo_zone.leds_count = 1;
logo_zone.matrix_map = NULL;
zones.push_back(logo_zone);
led logo_led;
@@ -90,7 +89,6 @@ void RGBController_SteelSeriesSensei::SetupZones()
wheel_zone.leds_min = 1;
wheel_zone.leds_max = 1;
wheel_zone.leds_count = 1;
wheel_zone.matrix_map = NULL;
zones.push_back(wheel_zone);
led wheel_led;
@@ -100,20 +98,13 @@ void RGBController_SteelSeriesSensei::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesSensei::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesSensei::DeviceUpdateLEDs()
{
UpdateZoneLEDs(0);
UpdateZoneLEDs(1);
DeviceUpdateZoneLEDs(0);
DeviceUpdateZoneLEDs(1);
}
void RGBController_SteelSeriesSensei::UpdateZoneLEDs(int zone)
void RGBController_SteelSeriesSensei::DeviceUpdateZoneLEDs(int zone)
{
RGBColor color = colors[zone];
unsigned char red = RGBGetRValue(color);
@@ -133,13 +124,13 @@ void RGBController_SteelSeriesSensei::UpdateZoneLEDs(int zone)
}
}
void RGBController_SteelSeriesSensei::UpdateSingleLED(int led)
void RGBController_SteelSeriesSensei::DeviceUpdateSingleLED(int led)
{
/*---------------------------------------------------------*\
| Each zone only has a single LED, so we can use the LED ID |
| to reference the existing zone code. |
\*---------------------------------------------------------*/
UpdateZoneLEDs(led);
DeviceUpdateZoneLEDs(led);
}
void RGBController_SteelSeriesSensei::DeviceUpdateMode()

View File

@@ -22,11 +22,10 @@ public:
~RGBController_SteelSeriesSensei();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();

View File

@@ -56,7 +56,6 @@ void RGBController_SteelSeriesSiberia::SetupZones()
earpiece_zone.leds_min = 1;
earpiece_zone.leds_max = 1;
earpiece_zone.leds_count = 1;
earpiece_zone.matrix_map = NULL;
zones.push_back(earpiece_zone);
led earpiece_led;
@@ -66,13 +65,6 @@ void RGBController_SteelSeriesSiberia::SetupZones()
SetupColors();
}
void RGBController_SteelSeriesSiberia::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesSiberia::DeviceUpdateLEDs()
{
unsigned char red = RGBGetRValue(colors[0]);
@@ -81,7 +73,7 @@ void RGBController_SteelSeriesSiberia::DeviceUpdateLEDs()
controller->SetColor(red, grn, blu);
}
void RGBController_SteelSeriesSiberia::UpdateZoneLEDs(int zone)
void RGBController_SteelSeriesSiberia::DeviceUpdateZoneLEDs(int zone)
{
RGBColor color = colors[zone];
unsigned char red = RGBGetRValue(color);
@@ -90,11 +82,11 @@ void RGBController_SteelSeriesSiberia::UpdateZoneLEDs(int zone)
controller->SetColor(red, grn, blu);
}
void RGBController_SteelSeriesSiberia::UpdateSingleLED(int led)
void RGBController_SteelSeriesSiberia::DeviceUpdateSingleLED(int led)
{
/* Each zone only has a single LED, so we can use the LED ID to reference
* the existing zone code. */
UpdateZoneLEDs(led);
DeviceUpdateZoneLEDs(led);
}
void RGBController_SteelSeriesSiberia::DeviceUpdateMode()

View File

@@ -21,11 +21,10 @@ public:
~RGBController_SteelSeriesSiberia();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();