mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-04 14:14:17 -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:
@@ -129,17 +129,12 @@ void RGBController_GenesisXenon200::SetupZones()
|
||||
|
||||
}
|
||||
|
||||
void RGBController_GenesisXenon200::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
void RGBController_GenesisXenon200::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_GenesisXenon200::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_GenesisXenon200::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_GenesisXenon200::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
void DeviceSaveMode();
|
||||
|
||||
@@ -191,7 +191,6 @@ void RGBController_Sinowealth1007::SetupZones()
|
||||
new_zone.leds_min = controller->GetLEDCount();
|
||||
new_zone.leds_max = controller->GetLEDCount();
|
||||
new_zone.leds_count = controller->GetLEDCount();
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -207,24 +206,17 @@ void RGBController_Sinowealth1007::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_Sinowealth1007::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_Sinowealth1007::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLEDColors(colors);
|
||||
}
|
||||
|
||||
void RGBController_Sinowealth1007::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_Sinowealth1007::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Sinowealth1007::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_Sinowealth1007::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -21,11 +21,10 @@ public:
|
||||
~RGBController_Sinowealth1007();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -165,7 +165,6 @@ void RGBController_Sinowealth::SetupZones()
|
||||
new_zone.leds_min = controller->GetLEDCount();
|
||||
new_zone.leds_max = controller->GetLEDCount();
|
||||
new_zone.leds_count = controller->GetLEDCount();
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
@@ -181,24 +180,17 @@ void RGBController_Sinowealth::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_Sinowealth::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_Sinowealth::DeviceUpdateLEDs()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_Sinowealth::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_Sinowealth::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Sinowealth::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_Sinowealth::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -21,11 +21,10 @@ public:
|
||||
~RGBController_Sinowealth();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -166,22 +166,17 @@ void RGBController_GMOW::SetupZones()
|
||||
|
||||
}
|
||||
|
||||
void RGBController_GMOW::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_GMOW::DeviceUpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_GMOW::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_GMOW::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_GMOW::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_GMOW::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -21,11 +21,10 @@ public:
|
||||
~RGBController_GMOW();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -92,15 +92,9 @@ void RGBController_SinowealthKeyboard10c::SetupZones()
|
||||
device.keyboard_layout.key_values);
|
||||
new_kb.ChangeKeys(device.keyboard_layout.edit_keys);
|
||||
|
||||
matrix_map_type* new_map = new matrix_map_type;
|
||||
new_zone.matrix_map = new_map;
|
||||
new_zone.matrix_map->height = new_kb.GetRowCount();
|
||||
new_zone.matrix_map->width = new_kb.GetColumnCount();
|
||||
|
||||
new_zone.matrix_map->map = new unsigned int[new_map->height * new_map->width];
|
||||
new_zone.leds_count = new_kb.GetRowCount() * new_kb.GetColumnCount();
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
new_zone.leds_count = new_kb.GetRowCount() * new_kb.GetColumnCount();
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| These keyboards use sparse LED indexes — for example, a |
|
||||
@@ -112,13 +106,13 @@ void RGBController_SinowealthKeyboard10c::SetupZones()
|
||||
| LED exists. |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
new_kb.GetKeyMap(new_map->map, KEYBOARD_MAP_FILL_TYPE_VALUE, new_map->height, new_map->width);
|
||||
new_zone.matrix_map = new_kb.GetKeyMap(KEYBOARD_MAP_FILL_TYPE_VALUE);
|
||||
|
||||
leds.resize(new_zone.leds_count);
|
||||
|
||||
for(unsigned int i = 0, j = 0; i < new_zone.leds_count; i++)
|
||||
{
|
||||
if(new_map->map[i] == 0xFFFFFFFF)
|
||||
if(new_zone.matrix_map.map[i] == 0xFFFFFFFF)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -128,7 +122,7 @@ void RGBController_SinowealthKeyboard10c::SetupZones()
|
||||
new_led.name = new_kb.GetKeyNameAt(j);
|
||||
new_led.value = new_kb.GetKeyValueAt(j);
|
||||
|
||||
leds[new_map->map[i]] = new_led;
|
||||
leds[new_zone.matrix_map.map[i]] = new_led;
|
||||
|
||||
j++;
|
||||
}
|
||||
@@ -138,25 +132,18 @@ void RGBController_SinowealthKeyboard10c::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard10c::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard10c::DeviceUpdateLEDs()
|
||||
{
|
||||
last_update_time = std::chrono::steady_clock::now();
|
||||
controller->SetLEDsDirect(colors);
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard10c::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_SinowealthKeyboard10c::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard10c::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_SinowealthKeyboard10c::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -171,7 +158,7 @@ void RGBController_SinowealthKeyboard10c::KeepaliveThreadFunction()
|
||||
{
|
||||
if(active_mode == MODE_DIRECT && (std::chrono::steady_clock::now() - last_update_time) > 1s)
|
||||
{
|
||||
UpdateLEDs();
|
||||
UpdateLEDsInternal();
|
||||
}
|
||||
std::this_thread::sleep_for(500ms);
|
||||
}
|
||||
|
||||
@@ -21,11 +21,10 @@ public:
|
||||
~RGBController_SinowealthKeyboard10c();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -377,10 +377,7 @@ void RGBController_SinowealthKeyboard16::SetupZones()
|
||||
new_zone.leds_count = controller->GetLEDCount();
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 6;
|
||||
new_zone.matrix_map->width = 22;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
new_zone.matrix_map.Set(6, 22, (unsigned int *)&matrix_map);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
@@ -397,24 +394,17 @@ void RGBController_SinowealthKeyboard16::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLEDsDirect(colors);
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_SinowealthKeyboard16::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard16::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_SinowealthKeyboard16::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -458,6 +448,4 @@ void RGBController_SinowealthKeyboard16::DeviceUpdateMode()
|
||||
std::fill(colors.begin(), colors.end(), ActiveMode.colors[0]);
|
||||
}
|
||||
}
|
||||
|
||||
SignalUpdate();
|
||||
}
|
||||
|
||||
@@ -23,11 +23,10 @@ public:
|
||||
~RGBController_SinowealthKeyboard16();
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -79,17 +79,6 @@ RGBController_SinowealthKeyboard90::RGBController_SinowealthKeyboard90(Sinowealt
|
||||
|
||||
RGBController_SinowealthKeyboard90::~RGBController_SinowealthKeyboard90()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| 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;
|
||||
}
|
||||
|
||||
@@ -105,10 +94,7 @@ void RGBController_SinowealthKeyboard90::SetupZones()
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
|
||||
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;
|
||||
new_zone.matrix_map.Set(6, 23, (unsigned int *)&matrix_map);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
@@ -123,13 +109,6 @@ void RGBController_SinowealthKeyboard90::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard90::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard90::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SendMode(modes[active_mode].value, modes[active_mode].brightness);
|
||||
@@ -146,12 +125,12 @@ void RGBController_SinowealthKeyboard90::DeviceUpdateLEDs()
|
||||
controller->SendCommit();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard90::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_SinowealthKeyboard90::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard90::UpdateSingleLED(int /*key*/)
|
||||
void RGBController_SinowealthKeyboard90::DeviceUpdateSingleLED(int /*key*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -20,11 +20,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();
|
||||
|
||||
|
||||
@@ -421,10 +421,7 @@ void RGBController_SinowealthKeyboard::SetupZones()
|
||||
new_zone.leds_min = 86;
|
||||
new_zone.leds_max = 86;
|
||||
new_zone.leds_count = 86;
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 6;
|
||||
new_zone.matrix_map->width = 17;
|
||||
new_zone.matrix_map->map = (unsigned int *)&tkl_matrix_map;
|
||||
new_zone.matrix_map.Set(6, 17, (unsigned int *)&tkl_matrix_map);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
@@ -441,24 +438,17 @@ void RGBController_SinowealthKeyboard::SetupZones()
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLEDsDirect(colors);
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard::UpdateZoneLEDs(int /*zone*/)
|
||||
void RGBController_SinowealthKeyboard::DeviceUpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SinowealthKeyboard::UpdateSingleLED(int /*led*/)
|
||||
void RGBController_SinowealthKeyboard::DeviceUpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -20,11 +20,10 @@ public:
|
||||
~RGBController_SinowealthKeyboard();
|
||||
|
||||
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