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 3ce0d57cca
commit 6813e1a01a
657 changed files with 9060 additions and 8807 deletions

View File

@@ -312,21 +312,19 @@ void RGBController_RedSquareKeyrox::SetupZones()
unsigned int zone_size = 0;
zone z;
z.name = ZONE_EN_KEYBOARD;
z.type = ZONE_TYPE_MATRIX;
z.name = ZONE_EN_KEYBOARD;
z.type = ZONE_TYPE_MATRIX;
z.matrix_map = new matrix_map_type;
z.matrix_map->height = keyboard->height;
z.matrix_map->width = keyboard->width;
z.matrix_map->map = new unsigned int[keyboard->height * keyboard->width];
z.matrix_map.height = keyboard->height;
z.matrix_map.width = keyboard->width;
z.matrix_map.map.resize(keyboard->height * keyboard->width);
for(unsigned int h = 0; h < keyboard->height; h++)
{
for(unsigned int w = 0; w < keyboard->width; w++)
{
unsigned int key = keyboard->matrix_map[h][w];
z.matrix_map->map[h * keyboard->width + w] = key;
z.matrix_map.map[h * keyboard->width + w] = key;
if(key != NA)
{
@@ -347,24 +345,17 @@ void RGBController_RedSquareKeyrox::SetupZones()
SetupColors();
}
void RGBController_RedSquareKeyrox::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_RedSquareKeyrox::DeviceUpdateLEDs()
{
controller->SetLEDsData(modes, active_mode, colors);
}
void RGBController_RedSquareKeyrox::UpdateZoneLEDs(int /*zone*/)
void RGBController_RedSquareKeyrox::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_RedSquareKeyrox::UpdateSingleLED(int /*led*/)
void RGBController_RedSquareKeyrox::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -21,11 +21,10 @@ public:
~RGBController_RedSquareKeyrox();
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

@@ -201,30 +201,18 @@ RGBController_RedSquareKeyroxTKLClassic::~RGBController_RedSquareKeyroxTKLClassi
void RGBController_RedSquareKeyroxTKLClassic::SetupZones()
{
KeyboardLayoutManager new_kb(KEYBOARD_LAYOUT_ANSI_QWERTY, KEYBOARD_SIZE_TKL, keyrox_tkl_offset_values);
/*---------------------------------------------------------*\
| Create the keyboard zone usiung Keyboard Layout Manager |
\*---------------------------------------------------------*/
zone new_zone;
new_zone.name = ZONE_EN_KEYBOARD;
new_zone.type = ZONE_TYPE_MATRIX;
KeyboardLayoutManager new_kb(KEYBOARD_LAYOUT_ANSI_QWERTY, KEYBOARD_SIZE_TKL, keyrox_tkl_offset_values);
matrix_map_type * new_map = new matrix_map_type;
new_zone.matrix_map = new_map;
new_zone.matrix_map->height = KEYROX_TKL_CLASSIC_HEIGHT;
new_zone.matrix_map->width = KEYROX_TKL_CLASSIC_WIDTH;
new_zone.matrix_map->map = new unsigned int[new_map->height * new_map->width];
new_zone.leds_count = new_kb.GetKeyCount();
new_zone.leds_min = new_zone.leds_count;
new_zone.leds_max = new_zone.leds_count;
/*---------------------------------------------------------*\
| Matrix map still uses declared zone rows and columns |
| as the packet structure depends on the matrix map |
\*---------------------------------------------------------*/
new_kb.GetKeyMap(new_map->map, KEYBOARD_MAP_FILL_TYPE_COUNT, new_map->height, new_map->width);
new_zone.name = ZONE_EN_KEYBOARD;
new_zone.type = ZONE_TYPE_MATRIX;
new_zone.leds_count = new_kb.GetKeyCount();
new_zone.leds_min = new_zone.leds_count;
new_zone.leds_max = new_zone.leds_count;
new_zone.matrix_map = new_kb.GetKeyMap(KEYBOARD_MAP_FILL_TYPE_COUNT, KEYROX_TKL_CLASSIC_HEIGHT, KEYROX_TKL_CLASSIC_WIDTH);
/*---------------------------------------------------------*\
| Create LEDs for the Matrix zone |
@@ -244,24 +232,17 @@ void RGBController_RedSquareKeyroxTKLClassic::SetupZones()
SetupColors();
}
void RGBController_RedSquareKeyroxTKLClassic::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_RedSquareKeyroxTKLClassic::DeviceUpdateLEDs()
{
controller->SetLEDsData(colors, leds);
}
void RGBController_RedSquareKeyroxTKLClassic::UpdateZoneLEDs(int /*zone*/)
void RGBController_RedSquareKeyroxTKLClassic::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_RedSquareKeyroxTKLClassic::UpdateSingleLED(int /*led*/)
void RGBController_RedSquareKeyroxTKLClassic::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -26,11 +26,10 @@ public:
~RGBController_RedSquareKeyroxTKLClassic();
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();