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 6deaf2f4fd
commit fdaf2eee6c
657 changed files with 9060 additions and 8801 deletions

View File

@@ -242,17 +242,6 @@ RGBController_HyperXAlloyElite2::~RGBController_HyperXAlloyElite2()
keepalive_thread->join();
delete keepalive_thread;
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != nullptr)
{
delete zones[zone_index].matrix_map;
}
}
delete controller;
}
@@ -273,14 +262,7 @@ void RGBController_HyperXAlloyElite2::SetupZones()
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 8;
new_zone.matrix_map->width = 22;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
}
else
{
new_zone.matrix_map = nullptr;
new_zone.matrix_map.Set(8, 22, (unsigned int *)&matrix_map);
}
zones.push_back(new_zone);
@@ -298,13 +280,6 @@ void RGBController_HyperXAlloyElite2::SetupZones()
SetupColors();
}
void RGBController_HyperXAlloyElite2::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXAlloyElite2::DeviceUpdateLEDs()
{
last_update_time = std::chrono::steady_clock::now();
@@ -315,12 +290,12 @@ void RGBController_HyperXAlloyElite2::DeviceUpdateLEDs()
}
}
void RGBController_HyperXAlloyElite2::UpdateZoneLEDs(int /*zone*/)
void RGBController_HyperXAlloyElite2::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyElite2::UpdateSingleLED(int /*led*/)
void RGBController_HyperXAlloyElite2::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
@@ -338,7 +313,7 @@ void RGBController_HyperXAlloyElite2::KeepaliveThreadFunction()
{
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(1000))
{
UpdateLEDs();
UpdateLEDsInternal();
}
}
std::this_thread::sleep_for(50ms);

View File

@@ -25,11 +25,9 @@ public:
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

@@ -255,17 +255,6 @@ RGBController_HyperXAlloyElite::~RGBController_HyperXAlloyElite()
keepalive_thread->join();
delete keepalive_thread;
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
delete zones[zone_index].matrix_map;
}
}
delete controller;
}
@@ -286,14 +275,7 @@ void RGBController_HyperXAlloyElite::SetupZones()
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 23;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
}
else
{
new_zone.matrix_map = NULL;
new_zone.matrix_map.Set(6, 23, (unsigned int *)&matrix_map);
}
zones.push_back(new_zone);
@@ -311,13 +293,6 @@ void RGBController_HyperXAlloyElite::SetupZones()
SetupColors();
}
void RGBController_HyperXAlloyElite::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXAlloyElite::DeviceUpdateLEDs()
{
last_update_time = std::chrono::steady_clock::now();
@@ -332,12 +307,12 @@ void RGBController_HyperXAlloyElite::DeviceUpdateLEDs()
}
}
void RGBController_HyperXAlloyElite::UpdateZoneLEDs(int /*zone*/)
void RGBController_HyperXAlloyElite::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyElite::UpdateSingleLED(int /*led*/)
void RGBController_HyperXAlloyElite::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
@@ -363,7 +338,7 @@ void RGBController_HyperXAlloyElite::KeepaliveThreadFunction()
{
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(50))
{
UpdateLEDs();
UpdateLEDsInternal();
}
}
std::this_thread::sleep_for(10ms);;

View File

@@ -25,11 +25,9 @@ public:
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

@@ -196,17 +196,6 @@ RGBController_HyperXAlloyFPS::~RGBController_HyperXAlloyFPS()
keepalive_thread->join();
delete keepalive_thread;
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
delete zones[zone_index].matrix_map;
}
}
delete controller;
}
@@ -227,14 +216,7 @@ void RGBController_HyperXAlloyFPS::SetupZones()
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 23;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
}
else
{
new_zone.matrix_map = NULL;
new_zone.matrix_map.Set(6, 23, (unsigned int *)&matrix_map);
}
zones.push_back(new_zone);
@@ -252,13 +234,6 @@ void RGBController_HyperXAlloyFPS::SetupZones()
SetupColors();
}
void RGBController_HyperXAlloyFPS::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXAlloyFPS::DeviceUpdateLEDs()
{
last_update_time = std::chrono::steady_clock::now();
@@ -269,12 +244,12 @@ void RGBController_HyperXAlloyFPS::DeviceUpdateLEDs()
}
}
void RGBController_HyperXAlloyFPS::UpdateZoneLEDs(int /*zone*/)
void RGBController_HyperXAlloyFPS::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyFPS::UpdateSingleLED(int /*led*/)
void RGBController_HyperXAlloyFPS::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
@@ -292,7 +267,7 @@ void RGBController_HyperXAlloyFPS::KeepaliveThreadFunction()
{
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(50))
{
UpdateLEDs();
UpdateLEDsInternal();
}
}
std::this_thread::sleep_for(10ms);;

View File

@@ -25,11 +25,9 @@ public:
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

@@ -249,17 +249,6 @@ RGBController_HyperXAlloyOrigins60and65::~RGBController_HyperXAlloyOrigins60and6
keepalive_thread->join();
delete keepalive_thread;
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
delete zones[zone_index].matrix_map;
}
}
delete controller;
}
@@ -277,11 +266,11 @@ void RGBController_HyperXAlloyOrigins60and65::SetupZones()
case ALLOY_ORIGINS_60_LAYOUT:
default:
led_names = led_names_60;
led_zones.push_back({ZONE_EN_KEYBOARD, ZONE_TYPE_MATRIX, 71, new matrix_map_type{5, 14, (unsigned int *)&matrix_map_60}});
led_zones.push_back({ZONE_EN_KEYBOARD, ZONE_TYPE_MATRIX, 71, new matrix_map_type(5, 14, (unsigned int *)&matrix_map_60)});
break;
case ALLOY_ORIGINS_65_LAYOUT:
led_names = led_names_65;
led_zones.push_back({ZONE_EN_KEYBOARD, ZONE_TYPE_MATRIX, 77, new matrix_map_type{5, 15, (unsigned int *)&matrix_map_65}});
led_zones.push_back({ZONE_EN_KEYBOARD, ZONE_TYPE_MATRIX, 77, new matrix_map_type(5, 15, (unsigned int *)&matrix_map_65)});
break;
}
@@ -295,13 +284,9 @@ void RGBController_HyperXAlloyOrigins60and65::SetupZones()
new_zone.leds_max = led_zones[zone_idx].size;
new_zone.leds_count = led_zones[zone_idx].size;
if(led_zones[zone_idx].type == ZONE_TYPE_MATRIX)
if(led_zones[zone_idx].type == ZONE_TYPE_MATRIX && led_zones[zone_idx].matrix != NULL)
{
new_zone.matrix_map = led_zones[zone_idx].matrix;
}
else
{
new_zone.matrix_map = NULL;
new_zone.matrix_map = *led_zones[zone_idx].matrix;
}
zones.push_back(new_zone);
@@ -319,24 +304,17 @@ void RGBController_HyperXAlloyOrigins60and65::SetupZones()
SetupColors();
}
void RGBController_HyperXAlloyOrigins60and65::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXAlloyOrigins60and65::DeviceUpdateLEDs()
{
controller->SetLEDsDirect(colors);
}
void RGBController_HyperXAlloyOrigins60and65::UpdateZoneLEDs(int /*zone*/)
void RGBController_HyperXAlloyOrigins60and65::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyOrigins60and65::UpdateSingleLED(int /*led*/)
void RGBController_HyperXAlloyOrigins60and65::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
@@ -354,7 +332,7 @@ void RGBController_HyperXAlloyOrigins60and65::KeepaliveThread()
{
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(50))
{
UpdateLEDs();
UpdateLEDsInternal();
}
}
std::this_thread::sleep_for(10ms);;

View File

@@ -38,11 +38,9 @@ public:
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

@@ -217,17 +217,6 @@ RGBController_HyperXAlloyOrigins::~RGBController_HyperXAlloyOrigins()
keepalive_thread->join();
delete keepalive_thread;
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
delete zones[zone_index].matrix_map;
}
}
delete controller;
}
@@ -248,14 +237,7 @@ void RGBController_HyperXAlloyOrigins::SetupZones()
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
new_zone.matrix_map->width = 23;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
}
else
{
new_zone.matrix_map = NULL;
new_zone.matrix_map.Set(6, 23, (unsigned int *)&matrix_map);
}
zones.push_back(new_zone);
@@ -273,24 +255,17 @@ void RGBController_HyperXAlloyOrigins::SetupZones()
SetupColors();
}
void RGBController_HyperXAlloyOrigins::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXAlloyOrigins::DeviceUpdateLEDs()
{
controller->SetLEDsDirect(colors);
}
void RGBController_HyperXAlloyOrigins::UpdateZoneLEDs(int /*zone*/)
void RGBController_HyperXAlloyOrigins::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyOrigins::UpdateSingleLED(int /*led*/)
void RGBController_HyperXAlloyOrigins::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
@@ -308,7 +283,7 @@ void RGBController_HyperXAlloyOrigins::KeepaliveThread()
{
if((std::chrono::steady_clock::now() - last_update_time) > std::chrono::milliseconds(50))
{
UpdateLEDs();
UpdateLEDsInternal();
}
}
std::this_thread::sleep_for(10ms);;

View File

@@ -23,11 +23,9 @@ public:
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

@@ -132,17 +132,6 @@ RGBController_HyperXAlloyOriginsCore::~RGBController_HyperXAlloyOriginsCore()
keepalive_thread->join();
delete keepalive_thread;
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
delete zones[zone_index].matrix_map;
}
}
delete controller;
}
@@ -177,24 +166,15 @@ void RGBController_HyperXAlloyOriginsCore::SetupZones()
total_leds = new_kb.GetKeyCount();
matrix_map_type * keyboard_map = new matrix_map_type;
new_zone.leds_count = total_leds;
new_zone.leds_min = new_zone.leds_count;
new_zone.leds_max = new_zone.leds_count;
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
{
new_zone.matrix_map = keyboard_map;
keyboard_map->height = new_kb.GetRowCount();
keyboard_map->width = new_kb.GetColumnCount();
keyboard_map->map = new unsigned int[keyboard_map->height * keyboard_map->width];
new_kb.GetKeyMap(keyboard_map->map, KEYBOARD_MAP_FILL_TYPE_COUNT);
}
else
{
new_zone.matrix_map = NULL;
new_zone.matrix_map = new_kb.GetKeyMap(KEYBOARD_MAP_FILL_TYPE_COUNT);
}
zones.push_back(new_zone);
for(unsigned int led_idx = 0; led_idx < total_leds; led_idx++)
@@ -210,24 +190,17 @@ void RGBController_HyperXAlloyOriginsCore::SetupZones()
SetupColors();
}
void RGBController_HyperXAlloyOriginsCore::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXAlloyOriginsCore::DeviceUpdateLEDs()
{
controller->SetLEDsDirect(leds, colors);
}
void RGBController_HyperXAlloyOriginsCore::UpdateZoneLEDs(int /*zone*/)
void RGBController_HyperXAlloyOriginsCore::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXAlloyOriginsCore::UpdateSingleLED(int /*led*/)
void RGBController_HyperXAlloyOriginsCore::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

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