mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-04 06:11:07 -04:00
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:
@@ -359,7 +359,6 @@ RGBController_CorsairK55RGBPROXT::~RGBController_CorsairK55RGBPROXT()
|
||||
keepalive_thread_run = false;
|
||||
keepalive_thread->join();
|
||||
delete keepalive_thread;
|
||||
delete[] zones[0].matrix_map;
|
||||
|
||||
delete controller;
|
||||
}
|
||||
@@ -370,10 +369,7 @@ void RGBController_CorsairK55RGBPROXT::SetupZones()
|
||||
keyboard_zone.name = "Keyboard";
|
||||
keyboard_zone.type = ZONE_TYPE_MATRIX;
|
||||
|
||||
keyboard_zone.matrix_map = new matrix_map_type;
|
||||
keyboard_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
keyboard_zone.matrix_map->height = HEIGHT;
|
||||
keyboard_zone.matrix_map->width = WIDTH;
|
||||
keyboard_zone.matrix_map.Set(HEIGHT, WIDTH, (unsigned int *)&matrix_map);
|
||||
|
||||
for(size_t led_index = 0; led_index < key_names.size(); ++led_index)
|
||||
{
|
||||
@@ -391,13 +387,6 @@ void RGBController_CorsairK55RGBPROXT::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairK55RGBPROXT::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairK55RGBPROXT::DeviceUpdateLEDs()
|
||||
{
|
||||
last_update_time = std::chrono::steady_clock::now();
|
||||
@@ -405,12 +394,12 @@ void RGBController_CorsairK55RGBPROXT::DeviceUpdateLEDs()
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairK55RGBPROXT::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_CorsairK55RGBPROXT::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairK55RGBPROXT::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_CorsairK55RGBPROXT::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,10 @@ public:
|
||||
~RGBController_CorsairK55RGBPROXT();
|
||||
|
||||
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 KeepaliveThread();
|
||||
|
||||
@@ -178,24 +178,19 @@ RGBController_CorsairK65Mini::~RGBController_CorsairK65Mini()
|
||||
|
||||
void RGBController_CorsairK65Mini::SetupZones()
|
||||
{
|
||||
unsigned int zone_size = 0;
|
||||
unsigned int zone_size = 0;
|
||||
|
||||
zone keyboard_zone;
|
||||
keyboard_zone.name = ZONE_EN_KEYBOARD;
|
||||
keyboard_zone.type = ZONE_TYPE_MATRIX;
|
||||
keyboard_zone.name = ZONE_EN_KEYBOARD;
|
||||
keyboard_zone.type = ZONE_TYPE_MATRIX;
|
||||
|
||||
keyboard_zone.matrix_map = new matrix_map_type;
|
||||
keyboard_zone.matrix_map->height = HEIGHT;
|
||||
keyboard_zone.matrix_map->width = WIDTH;
|
||||
|
||||
keyboard_zone.matrix_map->map = new unsigned int[HEIGHT * WIDTH];
|
||||
keyboard_zone.matrix_map.Set(HEIGHT, WIDTH, (unsigned int *)matrix_map);
|
||||
|
||||
for(unsigned int w = 0; w < WIDTH; w++)
|
||||
{
|
||||
for(unsigned int h = 0; h < HEIGHT; h++)
|
||||
{
|
||||
unsigned int key = matrix_map[h][w];
|
||||
keyboard_zone.matrix_map->map[h * WIDTH + w] = key;
|
||||
|
||||
if(key != NA)
|
||||
{
|
||||
@@ -217,25 +212,18 @@ void RGBController_CorsairK65Mini::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairK65Mini::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairK65Mini::DeviceUpdateLEDs()
|
||||
{
|
||||
last_update_time = std::chrono::steady_clock::now();
|
||||
controller->SetLEDs(colors, led_positions);
|
||||
}
|
||||
|
||||
void RGBController_CorsairK65Mini::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_CorsairK65Mini::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_CorsairK65Mini::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_CorsairK65Mini::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -19,11 +19,10 @@ public:
|
||||
~RGBController_CorsairK65Mini();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -929,17 +929,6 @@ RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripher
|
||||
|
||||
RGBController_CorsairPeripheral::~RGBController_CorsairPeripheral()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| 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;
|
||||
}
|
||||
|
||||
@@ -987,7 +976,7 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
switch(type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
if (logical_layout == CORSAIR_TYPE_K95_PLAT)
|
||||
if(logical_layout == CORSAIR_TYPE_K95_PLAT)
|
||||
{
|
||||
new_zone.name = zone_names_k95_platinum[zone_idx];
|
||||
new_zone.type = zone_types_k95_platinum[zone_idx];
|
||||
@@ -997,17 +986,10 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 24;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map_k95_platinum;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
new_zone.matrix_map.Set(7, 24, (unsigned int *)&matrix_map_k95_platinum);
|
||||
}
|
||||
}
|
||||
else if (logical_layout == CORSAIR_TYPE_K95)
|
||||
else if(logical_layout == CORSAIR_TYPE_K95)
|
||||
{
|
||||
new_zone.name = zone_names_k95[zone_idx];
|
||||
new_zone.type = zone_types_k95[zone_idx];
|
||||
@@ -1017,14 +999,7 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 26;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map_k95;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
new_zone.matrix_map.Set(7, 26, (unsigned int *)&matrix_map_k95);
|
||||
}
|
||||
}
|
||||
else if (logical_layout == CORSAIR_TYPE_K55)
|
||||
@@ -1034,7 +1009,6 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
new_zone.leds_min = zone_sizes_k55[zone_idx];
|
||||
new_zone.leds_max = zone_sizes_k55[zone_idx];
|
||||
new_zone.leds_count = zone_sizes_k55[zone_idx];
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
else if (logical_layout == CORSAIR_TYPE_K70_MK2)
|
||||
{
|
||||
@@ -1046,14 +1020,7 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 23;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map_k70_mk2;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
new_zone.matrix_map.Set(7, 23, (unsigned int *)&matrix_map_k70_mk2);
|
||||
}
|
||||
}
|
||||
else //default layout
|
||||
@@ -1066,14 +1033,7 @@ void RGBController_CorsairPeripheral::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);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1085,7 +1045,6 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
new_zone.leds_min = 15;
|
||||
new_zone.leds_max = 15;
|
||||
new_zone.leds_count = 15;
|
||||
new_zone.matrix_map = NULL;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSEMAT:
|
||||
@@ -1094,7 +1053,6 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
new_zone.leds_min = 15;
|
||||
new_zone.leds_max = 15;
|
||||
new_zone.leds_count = 15;
|
||||
new_zone.matrix_map = NULL;
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_HEADSET_STAND:
|
||||
@@ -1105,7 +1063,6 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
new_zone.leds_min = 8;
|
||||
new_zone.leds_max = 8;
|
||||
new_zone.leds_count = 8;
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1114,7 +1071,6 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
new_zone.leds_min = 1;
|
||||
new_zone.leds_max = 1;
|
||||
new_zone.leds_count = 1;
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1189,24 +1145,17 @@ void RGBController_CorsairPeripheral::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_CorsairPeripheral::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPeripheral::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_CorsairPeripheral::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user