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 1fe8f2cacf
commit 93f462389f
657 changed files with 9060 additions and 8807 deletions

View File

@@ -148,19 +148,14 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
continue;
}
custom_zone.matrix_map = new matrix_map_type;
unsigned int H = ZoneJson["matrix_width"];
unsigned int W = ZoneJson["matrix_height"];
custom_zone.matrix_map->width = ZoneJson["matrix_width"];
custom_zone.matrix_map->height = ZoneJson["matrix_height"];
int H = custom_zone.matrix_map->height;
int W = custom_zone.matrix_map->width;
BadVal = (ZoneJson["matrix_map"].size() != custom_zone.matrix_map->height);
BadVal = ((unsigned int)ZoneJson["matrix_map"].size() != H);
unsigned int* MatrixARR = new unsigned int[H * W];
for(int MatrixMapRow = 0; MatrixMapRow < H; MatrixMapRow++)
for(unsigned int MatrixMapRow = 0; MatrixMapRow < H; MatrixMapRow++)
{
/*-------------------------------------*\
| If something went wrong then make no |
@@ -169,15 +164,15 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
| bad row can corrupt the map so skip |
| the zone entirely |
\*-------------------------------------*/
if((custom_zone.matrix_map->width != ZoneJson["matrix_map"][MatrixMapRow].size()) || BadVal)
if((W != (unsigned int)ZoneJson["matrix_map"][MatrixMapRow].size()) || BadVal)
{
BadVal = true;
break;
}
for(int MatrixMapCol = 0; MatrixMapCol < W; MatrixMapCol++)
for(unsigned int MatrixMapCol = 0; MatrixMapCol < W; MatrixMapCol++)
{
int Val = ZoneJson["matrix_map"][MatrixMapRow][MatrixMapCol];
unsigned int Val = ZoneJson["matrix_map"][MatrixMapRow][MatrixMapCol];
if((signed)Val == -1)
{
@@ -185,12 +180,12 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
}
else
{
MatrixARR[MatrixMapRow * W + MatrixMapCol] = (unsigned)Val;
MatrixARR[MatrixMapRow * W + MatrixMapCol] = Val;
}
}
}
custom_zone.matrix_map->map = MatrixARR;
custom_zone.matrix_map.Set(H, W, MatrixARR);
}
/*---------------------------------------------*\
@@ -359,7 +354,6 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
single_zone.leds_min = 1;
single_zone.leds_max = 1;
single_zone.leds_count = 1;
single_zone.matrix_map = NULL;
zones.push_back(single_zone);
@@ -384,7 +378,6 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
linear_zone.leds_min = 10;
linear_zone.leds_max = 10;
linear_zone.leds_count = 10;
linear_zone.matrix_map = NULL;
zones.push_back(linear_zone);
@@ -491,12 +484,7 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
keyboard_zone.leds_min = new_kb.GetKeyCount();
keyboard_zone.leds_max = new_kb.GetKeyCount();
keyboard_zone.leds_count = new_kb.GetKeyCount();
keyboard_zone.matrix_map = new matrix_map_type;
keyboard_zone.matrix_map->height = new_kb.GetRowCount();
keyboard_zone.matrix_map->width = new_kb.GetColumnCount();
keyboard_zone.matrix_map->map = new unsigned int[keyboard_zone.matrix_map->height * keyboard_zone.matrix_map->width];
new_kb.GetKeyMap(keyboard_zone.matrix_map->map, KEYBOARD_MAP_FILL_TYPE_COUNT);
keyboard_zone.matrix_map = new_kb.GetKeyMap(KEYBOARD_MAP_FILL_TYPE_COUNT);
zones.push_back(keyboard_zone);
@@ -523,10 +511,7 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
underglow_zone.leds_min = 30;
underglow_zone.leds_max = 30;
underglow_zone.leds_count = 30;
underglow_zone.matrix_map = new matrix_map_type;
underglow_zone.matrix_map->height = 3;
underglow_zone.matrix_map->width = 10;
underglow_zone.matrix_map->map = (unsigned int*)&debug_keyboard_underglow_map;
underglow_zone.matrix_map.Set(3, 10, (unsigned int*)&debug_keyboard_underglow_map);
zones.push_back(underglow_zone);
@@ -553,7 +538,6 @@ RGBController_Debug::RGBController_Debug(bool custom_controller, json debug_sett
resizable_zone.leds_min = 0;
resizable_zone.leds_max = 100;
resizable_zone.leds_count = 0;
resizable_zone.matrix_map = NULL;
zones.push_back(resizable_zone);
}
@@ -567,12 +551,7 @@ RGBController_Debug::~RGBController_Debug()
}
void RGBController_Debug::SetupZones()
{
}
void RGBController_Debug::ResizeZone(int index, int new_size)
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))
@@ -617,12 +596,12 @@ void RGBController_Debug::DeviceUpdateLEDs()
}
void RGBController_Debug::UpdateZoneLEDs(int /*zone*/)
void RGBController_Debug::DeviceUpdateZoneLEDs(int /*zone*/)
{
}
void RGBController_Debug::UpdateSingleLED(int /*led*/)
void RGBController_Debug::DeviceUpdateSingleLED(int /*led*/)
{
}