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

@@ -206,12 +206,6 @@ void RGBController_Razer::SetupZones()
KeyboardLayoutManager new_kb(new_layout, device_list[device_index]->layout->base_size,
device_list[device_index]->layout->key_values);
matrix_map_type * new_map = new matrix_map_type;
new_zone.matrix_map = new_map;
new_map->height = device_list[device_index]->zones[zone_id]->rows;
new_map->width = device_list[device_index]->zones[zone_id]->cols;
new_map->map = new unsigned int[new_map->height * new_map->width];
if(device_list[device_index]->layout->base_size != KEYBOARD_SIZE::KEYBOARD_SIZE_EMPTY)
{
/*---------------------------------------------------------*\
@@ -220,11 +214,7 @@ void RGBController_Razer::SetupZones()
keyboard_keymap_overlay_values* temp = device_list[device_index]->layout;
new_kb.ChangeKeys(*temp);
/*---------------------------------------------------------*\
| 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_INDEX, new_map->height, new_map->width);
new_zone.matrix_map = new_kb.GetKeyMap(KEYBOARD_MAP_FILL_TYPE_INDEX, device_list[device_index]->zones[zone_id]->rows, device_list[device_index]->zones[zone_id]->cols);
}
zones.push_back(new_zone);
@@ -234,9 +224,9 @@ void RGBController_Razer::SetupZones()
\*---------------------------------------------------------*/
if(new_kb.GetKeyCount() > 0)
{
for(std::size_t row = 0; row < zones[zone_id].matrix_map->height; row++)
for(std::size_t row = 0; row < zones[zone_id].matrix_map.height; row++)
{
for(std::size_t col = 0; col < zones[zone_id].matrix_map->width; col++)
for(std::size_t col = 0; col < zones[zone_id].matrix_map.width; col++)
{
led new_led;
@@ -255,25 +245,19 @@ void RGBController_Razer::SetupZones()
| Handle all other matrix type zones by filling in all |
| entries |
\*---------------------------------------------------------*/
matrix_map_type * new_map = new matrix_map_type;
new_zone.matrix_map = new_map;
new_map->height = device_list[device_index]->zones[zone_id]->rows;
new_map->width = device_list[device_index]->zones[zone_id]->cols;
new_map->map = new unsigned int[new_map->height * new_map->width];
new_zone.matrix_map.height = device_list[device_index]->zones[zone_id]->rows;
new_zone.matrix_map.width = device_list[device_index]->zones[zone_id]->cols;
new_zone.matrix_map.map.resize(new_zone.matrix_map.height * new_zone.matrix_map.width);
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < new_zone.matrix_map.height; y++)
{
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < new_zone.matrix_map.width; x++)
{
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
new_zone.matrix_map.map[(y * new_zone.matrix_map.width) + x] = (y * new_zone.matrix_map.width) + x;
}
}
}
}
else
{
new_zone.matrix_map = NULL;
}
zones.push_back(new_zone);
@@ -300,24 +284,17 @@ void RGBController_Razer::SetupZones()
SetupColors();
}
void RGBController_Razer::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_Razer::DeviceUpdateLEDs()
{
controller->SetLEDs(&colors[0]);
}
void RGBController_Razer::UpdateZoneLEDs(int /*zone*/)
void RGBController_Razer::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_Razer::UpdateSingleLED(int /*led*/)
void RGBController_Razer::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -35,11 +35,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

@@ -182,26 +182,18 @@ void RGBController_RazerAddressable::SetupZones()
if(zones[zone_count].type == ZONE_TYPE_MATRIX)
{
matrix_map_type * new_map = new matrix_map_type;
zones[zone_count].matrix_map = new_map;
zones[zone_count].matrix_map.height = device_list[device_index]->zones[zone_id]->rows;
zones[zone_count].matrix_map.width = device_list[device_index]->zones[zone_id]->cols;
zones[zone_count].matrix_map.map.resize(zones[zone_count].matrix_map.height * zones[zone_count].matrix_map.width);
new_map->height = device_list[device_index]->zones[zone_id]->rows;
new_map->width = device_list[device_index]->zones[zone_id]->cols;
new_map->map = new unsigned int[new_map->height * new_map->width];
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < zones[zone_count].matrix_map.height; y++)
{
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < zones[zone_count].matrix_map.width; x++)
{
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
zones[zone_count].matrix_map.map[(y * zones[zone_count].matrix_map.width) + x] = (y * zones[zone_count].matrix_map.width) + x;
}
}
}
else
{
zones[zone_count].matrix_map = NULL;
}
zone_count++;
}
@@ -221,7 +213,7 @@ void RGBController_RazerAddressable::SetupZones()
SetupColors();
}
void RGBController_RazerAddressable::ResizeZone(int zone, int new_size)
void RGBController_RazerAddressable::DeviceResizeZone(int zone, int new_size)
{
/*---------------------------------------------------------*\
| Only the Razer Chroma Addressable RGB Controller supports |
@@ -263,12 +255,12 @@ void RGBController_RazerAddressable::DeviceUpdateLEDs()
controller->SetLEDs(&colors_buf[0]);
}
void RGBController_RazerAddressable::UpdateZoneLEDs(int /*zone*/)
void RGBController_RazerAddressable::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_RazerAddressable::UpdateSingleLED(int /*led*/)
void RGBController_RazerAddressable::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -33,11 +33,11 @@ public:
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceResizeZone(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

@@ -89,25 +89,18 @@ void RGBController_RazerHanbo::SetupZones()
if(new_zone.type == ZONE_TYPE_MATRIX)
{
matrix_map_type * new_map = new matrix_map_type;
new_zone.matrix_map.height = device_list[device_index]->zones[zone_id]->rows;
new_zone.matrix_map.width = device_list[device_index]->zones[zone_id]->cols;
new_zone.matrix_map.map.resize(new_zone.matrix_map.height * new_zone.matrix_map.width);
new_zone.matrix_map = new_map;
new_map->height = device_list[device_index]->zones[zone_id]->rows;
new_map->width = device_list[device_index]->zones[zone_id]->cols;
new_map->map = new unsigned int[new_map->height * new_map->width];
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < new_zone.matrix_map.height; y++)
{
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < new_zone.matrix_map.width; x++)
{
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
new_zone.matrix_map.map[(y * new_zone.matrix_map.width) + x] = (y * new_zone.matrix_map.width) + x;
}
}
}
else
{
new_zone.matrix_map = NULL;
}
zones.push_back(new_zone);
}
@@ -137,19 +130,12 @@ void RGBController_RazerHanbo::SetupZones()
SetupColors();
}
void RGBController_RazerHanbo::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_RazerHanbo::DeviceUpdateLEDs()
{
UpdateZoneLEDs(PUMP);
UpdateZoneLEDs(FAN1);
UpdateZoneLEDs(FAN2);
UpdateZoneLEDs(FAN3);
DeviceUpdateZoneLEDs(PUMP);
DeviceUpdateZoneLEDs(FAN1);
DeviceUpdateZoneLEDs(FAN2);
DeviceUpdateZoneLEDs(FAN3);
}
/*---------------------------------------------------------*\
@@ -157,12 +143,12 @@ void RGBController_RazerHanbo::DeviceUpdateLEDs()
| Transactions are straight forward when grouped this way. |
\*---------------------------------------------------------*/
void RGBController_RazerHanbo::UpdateZoneLEDs(int zoneid)
void RGBController_RazerHanbo::DeviceUpdateZoneLEDs(int zoneid)
{
controller->SetZoneLeds(zoneid, this->zones[zoneid]);
}
void RGBController_RazerHanbo::UpdateSingleLED(int /*led*/)
void RGBController_RazerHanbo::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -29,11 +29,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

@@ -116,26 +116,18 @@ void RGBController_RazerKraken::SetupZones()
if(new_zone.type == ZONE_TYPE_MATRIX)
{
matrix_map_type * new_map = new matrix_map_type;
new_zone.matrix_map = new_map;
new_zone.matrix_map.height = device_list[device_index]->zones[zone_id]->rows;
new_zone.matrix_map.width = device_list[device_index]->zones[zone_id]->cols;
new_zone.matrix_map.map.resize(new_zone.matrix_map.height * new_zone.matrix_map.width);
new_map->height = device_list[device_index]->zones[zone_id]->rows;
new_map->width = device_list[device_index]->zones[zone_id]->cols;
new_map->map = new unsigned int[new_map->height * new_map->width];
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < new_zone.matrix_map.height; y++)
{
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < new_zone.matrix_map.width; x++)
{
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
new_zone.matrix_map.map[(y * new_zone.matrix_map.width) + x] = (y * new_zone.matrix_map.width) + x;
}
}
}
else
{
new_zone.matrix_map = NULL;
}
zones.push_back(new_zone);
}
@@ -165,13 +157,6 @@ void RGBController_RazerKraken::SetupZones()
SetupColors();
}
void RGBController_RazerKraken::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_RazerKraken::DeviceUpdateLEDs()
{
unsigned char red = RGBGetRValue(colors[0]);
@@ -181,12 +166,12 @@ void RGBController_RazerKraken::DeviceUpdateLEDs()
controller->SetModeCustom(red, grn, blu);
}
void RGBController_RazerKraken::UpdateZoneLEDs(int /*zone*/)
void RGBController_RazerKraken::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_RazerKraken::UpdateSingleLED(int /*led*/)
void RGBController_RazerKraken::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -31,11 +31,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

@@ -95,26 +95,18 @@ void RGBController_RazerKrakenV3::SetupZones()
if(new_zone.type == ZONE_TYPE_MATRIX)
{
matrix_map_type * new_map = new matrix_map_type;
new_zone.matrix_map = new_map;
new_zone.matrix_map.height = device_list[device_index]->zones[zone_id]->rows;
new_zone.matrix_map.width = device_list[device_index]->zones[zone_id]->cols;
new_zone.matrix_map.map.resize(new_zone.matrix_map.height * new_zone.matrix_map.width);
new_map->height = device_list[device_index]->zones[zone_id]->rows;
new_map->width = device_list[device_index]->zones[zone_id]->cols;
new_map->map = new unsigned int[new_map->height * new_map->width];
for(unsigned int y = 0; y < new_map->height; y++)
for(unsigned int y = 0; y < new_zone.matrix_map.height; y++)
{
for(unsigned int x = 0; x < new_map->width; x++)
for(unsigned int x = 0; x < new_zone.matrix_map.width; x++)
{
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
new_zone.matrix_map.map[(y * new_zone.matrix_map.width) + x] = (y * new_zone.matrix_map.width) + x;
}
}
}
else
{
new_zone.matrix_map = NULL;
}
zones.push_back(new_zone);
}
@@ -144,11 +136,6 @@ void RGBController_RazerKrakenV3::SetupZones()
SetupColors();
}
void RGBController_RazerKrakenV3::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_RazerKrakenV3::DeviceUpdateLEDs()
{
if(modes[active_mode].value == RAZER_KRAKEN_V3_MODE_DIRECT)
@@ -157,12 +144,12 @@ void RGBController_RazerKrakenV3::DeviceUpdateLEDs()
}
}
void RGBController_RazerKrakenV3::UpdateZoneLEDs(int /*zone*/)
void RGBController_RazerKrakenV3::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_RazerKrakenV3::UpdateSingleLED(int /*led*/)
void RGBController_RazerKrakenV3::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -29,11 +29,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

@@ -71,7 +71,6 @@ void RGBController_RazerKrakenV4::SetupZones()
new_zone.leds_count = device_list[device_index]->zones[zone_id]->cols;
new_zone.leds_min = new_zone.leds_count;
new_zone.leds_max = new_zone.leds_count;
new_zone.matrix_map = NULL;
zones.push_back(new_zone);
@@ -95,11 +94,6 @@ void RGBController_RazerKrakenV4::SetupZones()
SetupColors();
}
void RGBController_RazerKrakenV4::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_RazerKrakenV4::DeviceUpdateLEDs()
{
if(modes[active_mode].value == RAZER_KRAKEN_V4_MODE_DIRECT)
@@ -108,12 +102,12 @@ void RGBController_RazerKrakenV4::DeviceUpdateLEDs()
}
}
void RGBController_RazerKrakenV4::UpdateZoneLEDs(int /*zone*/)
void RGBController_RazerKrakenV4::DeviceUpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_RazerKrakenV4::UpdateSingleLED(int /*led*/)
void RGBController_RazerKrakenV4::DeviceUpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}

View File

@@ -28,11 +28,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();