Use RegisterRGBController for standard detectors

This commit is contained in:
Adam Honse 2023-01-26 18:46:32 -06:00
parent 29d34f7768
commit 060567548f
24 changed files with 111 additions and 100 deletions

View file

@ -29,7 +29,7 @@ void DetectBlinkyTapeControllers(std::vector<RGBController*> &rgb_controllers)
controller->Initialize(*device_locations[device_idx]);
RGBController_BlinkyTape* rgb_controller = new RGBController_BlinkyTape(controller);
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -35,12 +35,11 @@ void DetectCorsairHydro2Controllers(std::vector<RGBController*>& rgb_controllers
libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0);
CorsairHydro2Controller* controller = new CorsairHydro2Controller(dev);
CorsairHydro2Controller* controller = new CorsairHydro2Controller(dev);
RGBController_CorsairHydro2* rgb_controller = new RGBController_CorsairHydro2(controller);
rgb_controller->name = "Corsair H100i v2";
rgb_controller->name = "Corsair H100i v2";
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -69,10 +69,9 @@ void DetectCorsairHydroControllers(std::vector<RGBController*>& rgb_controllers)
CorsairHydroController* controller = new CorsairHydroController(dev);
RGBController_CorsairHydro* rgb_controller = new RGBController_CorsairHydro(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
} /* DetectCorsairHydroControllers() */

View file

@ -298,7 +298,7 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
/*---------------------------------------------------------*\
| Push the dummy motherboard onto the controller list |
\*---------------------------------------------------------*/
rgb_controllers.push_back(dummy_motherboard);
ResourceManager::get()->RegisterRGBController(dummy_motherboard);
}
else if(type == "dram")
{
@ -374,7 +374,7 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
/*---------------------------------------------------------*\
| Push the dummy DRAM onto the controller list |
\*---------------------------------------------------------*/
rgb_controllers.push_back(dummy_dram);
ResourceManager::get()->RegisterRGBController(dummy_dram);
}
else if(type == "gpu")
{
@ -450,7 +450,7 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
/*---------------------------------------------------------*\
| Push the dummy GPU onto the controller list |
\*---------------------------------------------------------*/
rgb_controllers.push_back(dummy_gpu);
ResourceManager::get()->RegisterRGBController(dummy_gpu);
}
else if(type == "keyboard")
{
@ -538,7 +538,7 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
/*---------------------------------------------------------*\
| Push the dummy Keyboard onto the controller list |
\*---------------------------------------------------------*/
rgb_controllers.push_back(dummy_keyboard);
ResourceManager::get()->RegisterRGBController(dummy_keyboard);
}
else if(type == "argb")
{
@ -586,7 +586,7 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
/*---------------------------------------------------------*\
| Push the dummy ARGB onto the controller list |
\*---------------------------------------------------------*/
rgb_controllers.push_back(dummy_argb);
ResourceManager::get()->RegisterRGBController(dummy_argb);
}
}
}
@ -800,7 +800,7 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
dummy_custom->SetupColors();
rgb_controllers.push_back(dummy_custom);
ResourceManager::get()->RegisterRGBController(dummy_custom);
}
}

View file

@ -31,7 +31,7 @@ void DetectDygmaRaiseControllers(std::vector<RGBController*> &rgb_controllers)
controller->Initialize((char *)ports[i]->c_str());
RGBController_DygmaRaise* rgb_controller = new RGBController_DygmaRaise(controller);
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}

View file

@ -176,12 +176,12 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
{
dev.matrix_height = e131_settings["devices"][device_idx]["matrix_height"];
}
if(e131_settings["devices"][device_idx].contains("universe_size"))
{
dev.universe_size = e131_settings["devices"][device_idx]["universe_size"];
}
if(e131_settings["devices"][device_idx].contains("type"))
{
if(e131_settings["devices"][device_idx]["type"].is_string())
@ -275,7 +275,7 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
{
RGBController_E131* rgb_controller;
rgb_controller = new RGBController_E131(device_lists[list_idx]);
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -56,7 +56,7 @@ void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers)
{
LOG_DEBUG("[XPG Spectrix S40G] Probing %d, model: %s", nvme_idx, nvme_dev_buf);
}
close(nvme_model_fd);
/*-------------------------------------------------*\
@ -70,15 +70,15 @@ void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers)
if(nvme_fd > 0)
{
ENESMBusInterface_SpectrixS40G* interface = new ENESMBusInterface_SpectrixS40G(nvme_fd, nvme_dev_buf);
ENESMBusInterface_SpectrixS40G* interface = new ENESMBusInterface_SpectrixS40G(nvme_fd, nvme_dev_buf);
ENESMBusController* controller = new ENESMBusController(interface, 0x67);
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
rgb_controller->name = "XPG Spectrix S40G";
rgb_controller->type = DEVICE_TYPE_STORAGE;
rgb_controller->vendor = "XPG";
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = "XPG Spectrix S40G";
rgb_controller->type = DEVICE_TYPE_STORAGE;
rgb_controller->vendor = "XPG";
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -86,4 +86,4 @@ void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers)
}
} /* DetectSpectrixS40GControllers() */
REGISTER_DETECTOR( "XPG Spectrix S40G", DetectSpectrixS40GControllers);
REGISTER_DETECTOR( "XPG Spectrix S40G", DetectSpectrixS40GControllers);

View file

@ -98,7 +98,7 @@ void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers)
| https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-scsi-devices |
\*-------------------------------------------------------------------------------------------------*/
wchar_t dev_name[MAX_PATH];
if(Search(dev_name))
{
HANDLE nvme_fd = OpenDevice(dev_name);
@ -108,12 +108,12 @@ void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers)
ENESMBusInterface_SpectrixS40G* interface = new ENESMBusInterface_SpectrixS40G(nvme_fd, dev_name);
ENESMBusController* controller = new ENESMBusController(interface, 0x67);
RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller);
rgb_controller->name = "XPG Spectrix S40G";
rgb_controller->type = DEVICE_TYPE_STORAGE;
rgb_controller->vendor = "XPG";
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = "XPG Spectrix S40G";
rgb_controller->type = DEVICE_TYPE_STORAGE;
rgb_controller->vendor = "XPG";
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
} /* DetectSpectrixS40GControllers() */

View file

@ -38,7 +38,7 @@ void DetectElgatoKeyLightControllers(std::vector<RGBController*> &rgb_controller
ElgatoKeyLightController* controller = new ElgatoKeyLightController(elgato_keylight_ip);
RGBController_ElgatoKeyLight* rgb_controller = new RGBController_ElgatoKeyLight(controller);
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}

View file

@ -64,7 +64,7 @@ void DetectEspurnaControllers(std::vector<RGBController*> &rgb_controllers)
RGBController_Espurna* rgb_controller = new RGBController_Espurna(controller);
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -29,10 +29,10 @@ void DetectFanBusControllers(std::vector<RGBController*> &rgb_controllers)
for(unsigned int controller_idx = 0; controller_idx < detected_controllers.size(); controller_idx++)
{
FanBusController* controller = new FanBusController(new_interface, detected_controllers[controller_idx]);
RGBController_FanBus* rgb_controller = new RGBController_FanBus(controller);
FanBusController* controller = new FanBusController(new_interface, detected_controllers[controller_idx]);
RGBController_FanBus* rgb_controller = new RGBController_FanBus(controller);
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}

View file

@ -157,10 +157,20 @@ void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers)
{
const char* base_path = "/sys/devices/platform/faustus/kbbl";
DIR* dir = opendir(base_path);
if(!dir) return;
if(!dir)
{
return;
}
// Directory is present - we pretty much have a driver confirmation already, but double check for all files required just in case
struct dirent* dent = readdir(dir);
if(!dent) return;
if(!dent)
{
return;
}
int found = 0;
while(dent)
{
@ -171,9 +181,15 @@ void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers)
}
dent = readdir(dir);
}
closedir(dir);
if(found != 6) return;
rgb_controllers.push_back(new RGBController_Faustus(base_path));
if(found != 6)
{
return;
}
ResourceManager::get()->RegisterRGBController(new RGBController_Faustus(base_path));
} /* DetectFaustusControllers() */
REGISTER_DETECTOR("Faustus", DetectFaustusControllers);

View file

@ -49,21 +49,22 @@ void DetectGigabyteSuperIORGBControllers(std::vector<RGBController*> &rgb_contro
int val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) | superio_inb(sioaddr, SIO_REG_DEVID + 1);
switch (val & SIO_ID_MASK)
switch(val & SIO_ID_MASK)
{
case SIO_ITE688_ID:
for(unsigned int i = 0; i < NUM_COMPATIBLE_DEVICES; i++)
{
if (board_dmi.find(std::string(compatible_devices[i].name)) != std::string::npos)
case SIO_ITE688_ID:
for(unsigned int i = 0; i < NUM_COMPATIBLE_DEVICES; i++)
{
GigabyteSuperIORGBController* controller = new GigabyteSuperIORGBController(sioaddr);
RGBController_GigabyteSuperIORGB* rgb_controller = new RGBController_GigabyteSuperIORGB(controller);
rgb_controller->name = "Gigabyte " + board_dmi;
rgb_controllers.push_back(rgb_controller);
break;
if (board_dmi.find(std::string(compatible_devices[i].name)) != std::string::npos)
{
GigabyteSuperIORGBController* controller = new GigabyteSuperIORGBController(sioaddr);
RGBController_GigabyteSuperIORGB* rgb_controller = new RGBController_GigabyteSuperIORGB(controller);
rgb_controller->name = "Gigabyte " + board_dmi;
ResourceManager::get()->RegisterRGBController(rgb_controller);
break;
}
}
}
break;
break;
}
}
} /* DetectGigabyteSuperIORGBControllers() */

View file

@ -88,7 +88,7 @@ void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
RGBController_LEDStrip* rgb_controller = new RGBController_LEDStrip(controller);
rgb_controller->name = dev.name;
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -39,7 +39,7 @@ void DetectLIFXControllers(std::vector<RGBController*> &rgb_controllers)
LIFXController* controller = new LIFXController(lifx_ip, name);
RGBController_LIFX* rgb_controller = new RGBController_LIFX(controller);
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}

View file

@ -67,7 +67,7 @@ void DetectLinuxLEDControllers(std::vector<RGBController*> &rgb_controllers)
RGBController_LinuxLED* rgb_controller = new RGBController_LinuxLED(controller);
rgb_controller->name = name;
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -106,10 +106,11 @@ void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers)
{
if (board_dmi.find(std::string(compatible_devices[i].name)) != std::string::npos)
{
MSIRGBController* new_msi = new MSIRGBController(sioaddr, compatible_devices[i].invert);
RGBController_MSIRGB* new_rgb = new RGBController_MSIRGB(new_msi);
new_rgb->name = "MSI " + board_dmi;
rgb_controllers.push_back(new_rgb);
MSIRGBController* controller = new MSIRGBController(sioaddr, compatible_devices[i].invert);
RGBController_MSIRGB* rgb_controller = new RGBController_MSIRGB(controller);
rgb_controller->name = "MSI " + board_dmi;
ResourceManager::get()->RegisterRGBController(rgb_controller);
break;
}
}

View file

@ -96,13 +96,12 @@ void DetectNVIDIAIllumGPUs(std::vector<RGBController*> &rgb_controllers)
{
case NVIDIA_ILLUMINATION_V1:
{
NVIDIAIlluminationV1Controller* new_controller;
RGBController_NVIDIAIlluminationV1* new_rgbcontroller;
nvapi_accessor* new_nvapi = new nvapi_accessor(gpu_handles[gpu_idx]);
new_controller = new NVIDIAIlluminationV1Controller(new_nvapi, device_list[dev_idx].treats_rgbw_as_rgb);
new_rgbcontroller = new RGBController_NVIDIAIlluminationV1(new_controller);
new_rgbcontroller->name = device_list[dev_idx].name;
rgb_controllers.push_back(new_rgbcontroller);
nvapi_accessor* new_nvapi = new nvapi_accessor(gpu_handles[gpu_idx]);
NVIDIAIlluminationV1Controller* controller = new NVIDIAIlluminationV1Controller(new_nvapi, device_list[dev_idx].treats_rgbw_as_rgb);
RGBController_NVIDIAIlluminationV1* rgb_controller = new RGBController_NVIDIAIlluminationV1(controller);
rgb_controller->name = device_list[dev_idx].name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
break;
}

View file

@ -26,7 +26,7 @@ void DetectNanoleafControllers(std::vector<RGBController*> &rgb_controllers)
try
{
RGBController_Nanoleaf* rgb_controller = new RGBController_Nanoleaf(device["ip"], device["port"], device["auth_token"]);
rgb_controllers.push_back(rgb_controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
catch(...)
{

View file

@ -54,11 +54,11 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
case 5:
strcpy(driver_path, "/sys/bus/hid/drivers/razerkraken/");
break;
case 6:
strcpy(driver_path, "/sys/bus/hid/drivers/razermousemat/");
break;
case 7:
strcpy(driver_path, "/sys/bus/hid/drivers/razeraccessory/");
break;
@ -69,7 +69,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
dir = opendir(driver_path);
LOG_DEBUG("[OpenRazer] Folder %s is %s", driver_path, (dir == NULL)?"not found":"found look for driver..." );
if(dir == NULL)
{
driver_to_read++;
@ -106,14 +106,14 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
LOG_DEBUG("[OpenRazer] Device index is not -1 delete controller");
delete razer_rgb;
}
}
}

View file

@ -115,7 +115,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
static HMODULE module = LoadLibrary(OPENRAZERDLL);
LOG_DEBUG("[OpenRazerWindows] The %s is %s", OPENRAZERDLL, (module == nullptr)?"not found":"found" );
if(module == nullptr)
{
return;
@ -125,7 +125,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
| Map DLL functions |
\*---------------------------------------------------------*/
typedef unsigned int(*INITRAZERDRIVER)(struct hid_device** hdev);
INITRAZERDRIVER init_razer_kbd_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kbd_driver"));
INITRAZERDRIVER init_razer_mousemat_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mousemat_driver"));
INITRAZERDRIVER init_razer_mouse_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mouse_driver"));
@ -154,7 +154,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
@ -178,7 +178,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
@ -203,7 +203,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
@ -228,7 +228,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
@ -253,7 +253,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
@ -278,7 +278,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{

View file

@ -93,7 +93,7 @@ void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
{
finder.addUsername(bridges[0].mac, hue_settings["bridges"][0]["username"]);
}
/*-------------------------------------------------*\
| Add the client key if it exists |
\*-------------------------------------------------*/
@ -196,9 +196,10 @@ void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
{
if(groups[group_idx].getType() == "Entertainment")
{
PhilipsHueEntertainmentController* new_controller = new PhilipsHueEntertainmentController(bridge, groups[group_idx]);
RGBController_PhilipsHueEntertainment* new_rgbcontroller = new RGBController_PhilipsHueEntertainment(new_controller);
rgb_controllers.push_back(new_rgbcontroller);
PhilipsHueEntertainmentController* controller = new PhilipsHueEntertainmentController(bridge, groups[group_idx]);
RGBController_PhilipsHueEntertainment* rgb_controller = new RGBController_PhilipsHueEntertainment(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -238,9 +239,10 @@ void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
{
if(lights[light_idx].hasColorControl())
{
PhilipsHueController* new_controller = new PhilipsHueController(lights[light_idx], bridge.getBridgeIP());
RGBController_PhilipsHue* new_rgbcontroller = new RGBController_PhilipsHue(new_controller);
rgb_controllers.push_back(new_rgbcontroller);
PhilipsHueController* controller = new PhilipsHueController(lights[light_idx], bridge.getBridgeIP());
RGBController_PhilipsHue* rgb_controller = new RGBController_PhilipsHue(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}

View file

@ -17,9 +17,6 @@
void DetectPhilipsWizControllers(std::vector<RGBController*> &rgb_controllers)
{
PhilipsWizController* new_controller;
RGBController_PhilipsWiz* new_rgbcontroller;
json wiz_settings;
/*-------------------------------------------------*\
@ -38,10 +35,10 @@ void DetectPhilipsWizControllers(std::vector<RGBController*> &rgb_controllers)
{
std::string wiz_ip = wiz_settings["devices"][device_idx]["ip"];
new_controller = new PhilipsWizController(wiz_ip);
new_rgbcontroller = new RGBController_PhilipsWiz(new_controller);
PhilipsWizController* controller = new PhilipsWizController(wiz_ip);
RGBController_PhilipsWiz* rgb_controller = new RGBController_PhilipsWiz(controller);
rgb_controllers.push_back(new_rgbcontroller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}

View file

@ -17,9 +17,6 @@
void DetectYeelightControllers(std::vector<RGBController*> &rgb_controllers)
{
YeelightController* new_controller;
RGBController_Yeelight* new_rgbcontroller;
json yeelight_settings;
/*-------------------------------------------------*\
@ -51,10 +48,10 @@ void DetectYeelightControllers(std::vector<RGBController*> &rgb_controllers)
music_mode = yeelight_settings["devices"][device_idx]["music_mode"];
}
new_controller = new YeelightController(yeelight_ip, yeelight_host_ip, music_mode);
new_rgbcontroller = new RGBController_Yeelight(new_controller);
YeelightController* controller = new YeelightController(yeelight_ip, yeelight_host_ip, music_mode);
RGBController_Yeelight* rgb_controller = new RGBController_Yeelight(controller);
rgb_controllers.push_back(new_rgbcontroller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
}