Ready To Merge™
This commit is contained in:
parent
75a14f2250
commit
78ea2ee8f0
1 changed files with 213 additions and 2 deletions
|
|
@ -203,7 +203,7 @@ static const char *led_names[] =
|
|||
void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
json debug_settings;
|
||||
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get Debug Device settings from settings manager |
|
||||
\*-------------------------------------------------*/
|
||||
|
|
@ -564,7 +564,7 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
dummy_argb_direct_mode.color_mode = MODE_COLORS_PER_LED;
|
||||
|
||||
dummy_argb->modes.push_back(dummy_argb_direct_mode);
|
||||
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Create a linear zone for the dummy ARGB |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -590,6 +590,217 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
|
|||
}
|
||||
}
|
||||
|
||||
if (debug_settings.contains("CustomDevices"))
|
||||
{
|
||||
for (int CustomDevice = 0; CustomDevice < (int)debug_settings["CustomDevices"].size(); CustomDevice++)
|
||||
{
|
||||
json CustomDev = debug_settings["CustomDevices"][CustomDevice];
|
||||
/*---------------------------*\
|
||||
| Create a custom controller |
|
||||
\*---------------------------*/
|
||||
RGBController_Debug* dummy_custom = new RGBController_Debug();
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| if ANY of the attributes are missing then go ahead and skip the entry |
|
||||
\*----------------------------------------------------------------------*/
|
||||
if (
|
||||
!CustomDev.contains("DeviceName") ||
|
||||
!CustomDev.contains("DeviceType") ||
|
||||
!CustomDev.contains("DeviceDescription") ||
|
||||
!CustomDev.contains("DeviceLocation") ||
|
||||
!CustomDev.contains("DeviceVersion") ||
|
||||
!CustomDev.contains("DeviceSerial") ||
|
||||
!CustomDev.contains("DeviceZones")
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/*-------------*\
|
||||
| Set the name |
|
||||
\*-------------*/
|
||||
dummy_custom->name = CustomDev["DeviceName"];
|
||||
|
||||
/*---------------------*\
|
||||
| Find the device type |
|
||||
\*---------------------*/
|
||||
if (CustomDev["DeviceType"] == "motherboard") dummy_custom->type = DEVICE_TYPE_MOTHERBOARD;
|
||||
else if (CustomDev["DeviceType"] == "dram") dummy_custom->type = DEVICE_TYPE_DRAM;
|
||||
else if (CustomDev["DeviceType"] == "gpu") dummy_custom->type = DEVICE_TYPE_GPU;
|
||||
else if (CustomDev["DeviceType"] == "cooler") dummy_custom->type = DEVICE_TYPE_COOLER;
|
||||
else if (CustomDev["DeviceType"] == "led_strip") dummy_custom->type = DEVICE_TYPE_LEDSTRIP;
|
||||
else if (CustomDev["DeviceType"] == "keyboard") dummy_custom->type = DEVICE_TYPE_KEYBOARD;
|
||||
else if (CustomDev["DeviceType"] == "mouse") dummy_custom->type = DEVICE_TYPE_MOUSE;
|
||||
else if (CustomDev["DeviceType"] == "mousemat") dummy_custom->type = DEVICE_TYPE_MOUSEMAT;
|
||||
else if (CustomDev["DeviceType"] == "headset") dummy_custom->type = DEVICE_TYPE_HEADSET;
|
||||
else if (CustomDev["DeviceType"] == "headset_stand") dummy_custom->type = DEVICE_TYPE_HEADSET_STAND;
|
||||
else if (CustomDev["DeviceType"] == "gamepad") dummy_custom->type = DEVICE_TYPE_GAMEPAD;
|
||||
else if (CustomDev["DeviceType"] == "light") dummy_custom->type = DEVICE_TYPE_LIGHT;
|
||||
else if (CustomDev["DeviceType"] == "speaker") dummy_custom->type = DEVICE_TYPE_SPEAKER;
|
||||
else if (CustomDev["DeviceType"] == "unknown") dummy_custom->type = DEVICE_TYPE_UNKNOWN;
|
||||
|
||||
/*-----------------------------------------------*\
|
||||
| Set description, location, version, and serial |
|
||||
\*-----------------------------------------------*/
|
||||
dummy_custom->description = CustomDev["DeviceDescription"];
|
||||
dummy_custom->location = CustomDev["DeviceLocation"];
|
||||
dummy_custom->version = CustomDev["DeviceVersion"];
|
||||
dummy_custom->serial = CustomDev["DeviceSerial"];
|
||||
|
||||
/*----------------*\
|
||||
| Create the mode |
|
||||
\*----------------*/
|
||||
mode dummy_custom_direct;
|
||||
dummy_custom_direct.name = "Direct";
|
||||
dummy_custom_direct.value = 0;
|
||||
dummy_custom_direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
dummy_custom_direct.color_mode = MODE_COLORS_PER_LED;
|
||||
dummy_custom->modes.push_back(dummy_custom_direct);
|
||||
|
||||
/*--------------*\
|
||||
| Fill in zones |
|
||||
\*--------------*/
|
||||
for (int ZoneID = 0; ZoneID < (int)CustomDev["DeviceZones"].size(); ZoneID++)
|
||||
{
|
||||
json ZoneJson = CustomDev["DeviceZones"][ZoneID];
|
||||
if
|
||||
(
|
||||
!ZoneJson.contains("name") ||
|
||||
!ZoneJson.contains("type") ||
|
||||
!ZoneJson.contains("leds_min") ||
|
||||
!ZoneJson.contains("leds_max") ||
|
||||
!ZoneJson.contains("leds_count")
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
zone custom_zone;
|
||||
|
||||
custom_zone.name = ZoneJson["name"];
|
||||
|
||||
if (ZoneJson["type"] == "linear") custom_zone.type = ZONE_TYPE_LINEAR;
|
||||
else if (ZoneJson["type"] == "matrix") custom_zone.type = ZONE_TYPE_MATRIX;
|
||||
else if (ZoneJson["type"] == "single") custom_zone.type = ZONE_TYPE_SINGLE;
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
custom_zone.leds_min = ZoneJson["leds_min"];
|
||||
custom_zone.leds_max = ZoneJson["leds_max"];
|
||||
custom_zone.leds_count = ZoneJson["leds_count"];
|
||||
|
||||
/*-----------------------*\
|
||||
| Fill in the matrix map |
|
||||
\*-----------------------*/
|
||||
bool BadVal = false;
|
||||
if (custom_zone.type == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
if
|
||||
(
|
||||
!ZoneJson.contains("matrix_height") ||
|
||||
!ZoneJson.contains("matrix_width") ||
|
||||
!ZoneJson.contains("matrix_map")
|
||||
)
|
||||
{
|
||||
/*--------------------------------------------------------------*\
|
||||
| If there is no map then the zone can't be valid. Don't add it |
|
||||
\*--------------------------------------------------------------*/
|
||||
continue;
|
||||
}
|
||||
|
||||
custom_zone.matrix_map = new matrix_map_type;
|
||||
|
||||
custom_zone.matrix_map->width = ZoneJson["matrix_width"];
|
||||
custom_zone.matrix_map->height = ZoneJson["matrix_height"];
|
||||
|
||||
|
||||
BadVal = (ZoneJson["matrix_map"].size() != custom_zone.matrix_map->height);
|
||||
|
||||
unsigned int* HeightMap = new unsigned int[custom_zone.matrix_map->height];
|
||||
for (int MatrixMapRow = 0; MatrixMapRow < (int)custom_zone.matrix_map->height; MatrixMapRow++)
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| If something went wrong then make no attempt to recover and just move on in a way that doesn't crash |
|
||||
| Even 1 bad row can corrupt the map so skip the zone entirely |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
if ((custom_zone.matrix_map->width != ZoneJson["matrix_map"][MatrixMapRow].size()) || BadVal)
|
||||
{
|
||||
BadVal = true;
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned int* WidthMap = new unsigned int[custom_zone.matrix_map->width];
|
||||
for (int MatrixMapCol = 0; MatrixMapCol < (int)ZoneJson["matrix_map"][MatrixMapRow].size(); MatrixMapCol++)
|
||||
{
|
||||
int Val = ZoneJson["matrix_map"][MatrixMapRow][MatrixMapCol];
|
||||
if (Val == -1)
|
||||
{
|
||||
WidthMap[MatrixMapCol] = NA;
|
||||
}
|
||||
else
|
||||
{
|
||||
WidthMap[MatrixMapCol] = ZoneJson["matrix_map"][MatrixMapRow][MatrixMapCol];
|
||||
}
|
||||
}
|
||||
HeightMap[MatrixMapRow] = *WidthMap;
|
||||
}
|
||||
custom_zone.matrix_map->map = HeightMap;
|
||||
}
|
||||
|
||||
/*------------------------------------*\
|
||||
| Don't add the zone if it is invalid |
|
||||
\*------------------------------------*/
|
||||
if (BadVal)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool UseCustomLabels = false;
|
||||
if (ZoneJson.contains("custom_labels"))
|
||||
{
|
||||
/*-------------------------------------------------------*\
|
||||
| If the count is correct and the zone is non-resizeable |
|
||||
\*-------------------------------------------------------*/
|
||||
if ((ZoneJson["custom_labels"].size() == custom_zone.leds_count) && (custom_zone.leds_min == custom_zone.leds_max))
|
||||
{
|
||||
UseCustomLabels = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*------------------*\
|
||||
| Set the LED names |
|
||||
\*------------------*/
|
||||
for (int LED_ID = 0; LED_ID < (int)custom_zone.leds_count; LED_ID++)
|
||||
{
|
||||
led custom_led;
|
||||
if (UseCustomLabels)
|
||||
{
|
||||
/*----------------------------------------*\
|
||||
| Set the label to the user defined label |
|
||||
\*----------------------------------------*/
|
||||
custom_led.name = ZoneJson["custom_labels"][LED_ID];
|
||||
}
|
||||
else
|
||||
{
|
||||
/*------------------------------------------------*\
|
||||
| Set default labels because something went wrong |
|
||||
\*------------------------------------------------*/
|
||||
custom_led.name = ("Custom LED. Zone " + std::to_string(ZoneID) + ", LED " + std::to_string(LED_ID));
|
||||
}
|
||||
dummy_custom->leds.push_back(custom_led);
|
||||
}
|
||||
|
||||
dummy_custom->zones.push_back(custom_zone);
|
||||
}
|
||||
|
||||
dummy_custom->SetupColors();
|
||||
|
||||
rgb_controllers.push_back(dummy_custom);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectDebugControllers() */
|
||||
|
||||
REGISTER_DETECTOR("Debug Controllers", DetectDebugControllers);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue