diff --git a/Controllers/A4TechController/A4Tech_Detector.cpp b/Controllers/A4TechController/A4Tech_Detector.cpp index 190410443..f2c6f6385 100644 --- a/Controllers/A4TechController/A4Tech_Detector.cpp +++ b/Controllers/A4TechController/A4Tech_Detector.cpp @@ -14,7 +14,7 @@ | OpenRGB includes | \*-----------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" /*-----------------------------------------------------*\ | A4 Tech specific includes | @@ -36,7 +36,7 @@ void DetectA4TechMouseControllers(hid_device_info* info, const std::string& name BloodyMouseController* controller = new BloodyMouseController(dev, info->path, info->product_id, name); RGBController_BloodyMouse* rgb_controller = new RGBController_BloodyMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -49,7 +49,7 @@ void DetectBloodyB820R(hid_device_info* info, const std::string& name) BloodyB820RController* controller = new BloodyB820RController(dev, info->path, name); RGBController_BloodyB820R* rgb_controller = new RGBController_BloodyB820R(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AMBXController/AMBXControllerDetect.cpp b/Controllers/AMBXController/AMBXControllerDetect.cpp index afbf9185f..7a398cdd3 100644 --- a/Controllers/AMBXController/AMBXControllerDetect.cpp +++ b/Controllers/AMBXController/AMBXControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AMBXController.h" #include "RGBController.h" #include "RGBController_AMBX.h" @@ -67,7 +67,7 @@ void DetectAMBXControllers() if(controller->IsInitialized()) { RGBController_AMBX* rgb_controller = new RGBController_AMBX(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp b/Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp index 253237026..a182104ee 100644 --- a/Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp +++ b/Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "AMDWraithPrismController.h" #include "RGBController_AMDWraithPrism.h" @@ -41,7 +41,7 @@ void DetectAMDWraithPrismControllers(hid_device_info* info, const std::string&) AMDWraithPrismController* controller = new AMDWraithPrismController(dev, info->path); RGBController_AMDWraithPrism* rgb_controller = new RGBController_AMDWraithPrism(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AOCKeyboardController/AOCKeyboardControllerDetect.cpp b/Controllers/AOCKeyboardController/AOCKeyboardControllerDetect.cpp index 84e961dfa..fa4abd43a 100644 --- a/Controllers/AOCKeyboardController/AOCKeyboardControllerDetect.cpp +++ b/Controllers/AOCKeyboardController/AOCKeyboardControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AOCKeyboardController.h" #include "RGBController_AOCKeyboard.h" @@ -37,7 +37,7 @@ void DetectAOCKeyboardControllers(hid_device_info* info, const std::string& name AOCKeyboardController* controller = new AOCKeyboardController(dev, info->path, name); RGBController_AOCKeyboard* rgb_controller = new RGBController_AOCKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AOCMouseController/AOCMouseControllerDetect.cpp b/Controllers/AOCMouseController/AOCMouseControllerDetect.cpp index 47b138417..df66c2090 100644 --- a/Controllers/AOCMouseController/AOCMouseControllerDetect.cpp +++ b/Controllers/AOCMouseController/AOCMouseControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AOCMouseController.h" #include "RGBController_AOCMouse.h" @@ -36,7 +36,7 @@ void DetectAOCMouseControllers(hid_device_info* info, const std::string& name) AOCMouseController* controller = new AOCMouseController(dev, info->path, name); RGBController_AOCMouse* rgb_controller = new RGBController_AOCMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AOCMousematController/AOCMousematControllerDetect.cpp b/Controllers/AOCMousematController/AOCMousematControllerDetect.cpp index 949282806..e250798e1 100644 --- a/Controllers/AOCMousematController/AOCMousematControllerDetect.cpp +++ b/Controllers/AOCMousematController/AOCMousematControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AOCMousematController.h" #include "RGBController_AOCMousemat.h" @@ -36,7 +36,7 @@ void DetectAOCMousematControllers(hid_device_info* info, const std::string& name AOCMousematController* controller = new AOCMousematController(dev, info->path, name); RGBController_AOCMousemat* rgb_controller = new RGBController_AOCMousemat(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp b/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp index 8cb2d0f7d..8b6e57abe 100755 --- a/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp +++ b/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBController.cpp @@ -11,12 +11,12 @@ \*---------------------------------------------------------*/ #include -#include "RGBController.h" -#include "ResourceManager.h" -#include "SettingsManager.h" -#include "StringUtils.h" #include "ASRockPolychromeUSBController.h" #include "dmiinfo.h" +#include "ResourceManager.h" +#include "RGBController.h" +#include "SettingsManager.h" +#include "StringUtils.h" #define POLYCHROME_USB_READ_ZONE_CONFIG 0x11 #define POLYCHROME_USB_READ_HEADER 0x14 diff --git a/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBControllerDetect.cpp b/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBControllerDetect.cpp index d0ad7c102..cb46010d6 100644 --- a/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBControllerDetect.cpp +++ b/Controllers/ASRockPolychromeUSBController/ASRockPolychromeUSBControllerDetect.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ASRockPolychromeUSBController.h" #include "RGBController_ASRockPolychromeUSB.h" @@ -34,7 +34,7 @@ void DetectPolychromeUSBControllers(hid_device_info* info, const std::string& /* { PolychromeUSBController* controller = new PolychromeUSBController(dev, info->path); RGBController_PolychromeUSB* rgb_controller = new RGBController_PolychromeUSB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ASRockSMBusController/ASRockSMBusControllerDetect.cpp b/Controllers/ASRockSMBusController/ASRockSMBusControllerDetect.cpp index 592d86069..dc9d1de7d 100644 --- a/Controllers/ASRockSMBusController/ASRockSMBusControllerDetect.cpp +++ b/Controllers/ASRockSMBusController/ASRockSMBusControllerDetect.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ASRockASRRGBSMBusController.h" #include "ASRockPolychromeV1SMBusController.h" #include "ASRockPolychromeV2SMBusController.h" @@ -131,7 +131,7 @@ void DetectASRockSMBusControllers(std::vector& busses) ASRockASRRGBSMBusController* controller = new ASRockASRRGBSMBusController(busses[bus], SMBUS_ADDRESS); controller-> fw_version = version.u16; RGBController_ASRockASRRGBSMBus* rgb_controller = new RGBController_ASRockASRRGBSMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; @@ -141,7 +141,7 @@ void DetectASRockSMBusControllers(std::vector& busses) ASRockPolychromeV1SMBusController* controller = new ASRockPolychromeV1SMBusController(busses[bus], SMBUS_ADDRESS); controller-> fw_version = version.u16; RGBController_ASRockPolychromeV1SMBus* rgb_controller = new RGBController_ASRockPolychromeV1SMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; @@ -151,7 +151,7 @@ void DetectASRockSMBusControllers(std::vector& busses) ASRockPolychromeV2SMBusController* controller = new ASRockPolychromeV2SMBusController(busses[bus], SMBUS_ADDRESS); controller-> fw_version = version.u16; RGBController_ASRockPolychromeV2SMBus* rgb_controller = new RGBController_ASRockPolychromeV2SMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; diff --git a/Controllers/AlienwareController/AlienwareControllerDetect.cpp b/Controllers/AlienwareController/AlienwareControllerDetect.cpp index 9ae7a5613..03eb36d5a 100644 --- a/Controllers/AlienwareController/AlienwareControllerDetect.cpp +++ b/Controllers/AlienwareController/AlienwareControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AlienwareController.h" #include "RGBController_Alienware.h" @@ -31,7 +31,7 @@ void DetectAlienwareControllers(hid_device_info* info, const std::string& name) AlienwareController* controller = new AlienwareController(dev, *info, name); RGBController_Alienware* rgb_controller = new RGBController_Alienware(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AlienwareKeyboardController/AlienwareKeyboardControllerDetect.cpp b/Controllers/AlienwareKeyboardController/AlienwareKeyboardControllerDetect.cpp index 75ff795c5..d452b248d 100644 --- a/Controllers/AlienwareKeyboardController/AlienwareKeyboardControllerDetect.cpp +++ b/Controllers/AlienwareKeyboardController/AlienwareKeyboardControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "AlienwareAW510KController.h" #include "AlienwareAW410KController.h" #include "RGBController_AlienwareAW510K.h" @@ -41,7 +41,7 @@ void DetectAlienwareAW510KControllers(hid_device_info* info, const std::string& AlienwareAW510KController* controller = new AlienwareAW510KController(dev, info->path, name); RGBController_AlienwareAW510K* rgb_controller = new RGBController_AlienwareAW510K(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -53,7 +53,7 @@ void DetectAlienwareAW410KControllers(hid_device_info* info, const std::string& AlienwareAW410KController* controller = new AlienwareAW410KController(dev, info->path, name); RGBController_AlienwareAW410K* rgb_controller = new RGBController_AlienwareAW410K(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } }/* DetectAlienwareKeyboardControllers() */ diff --git a/Controllers/AlienwareMonitorController/AlienwareMonitorControllerDetect.cpp b/Controllers/AlienwareMonitorController/AlienwareMonitorControllerDetect.cpp index ef2123609..98fa72f6c 100644 --- a/Controllers/AlienwareMonitorController/AlienwareMonitorControllerDetect.cpp +++ b/Controllers/AlienwareMonitorController/AlienwareMonitorControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AlienwareAW3423DWFController.h" #include "AlienwareMonitorController.h" #include "RGBController_AlienwareAW3423DWF.h" @@ -45,7 +45,7 @@ void DetectAlienwareAW3423DWFControllers(hid_device_info* info, const std::strin AlienwareAW3423DWFController* controller = new AlienwareAW3423DWFController(dev, info->path); RGBController_AlienwareAW3423DWF* rgb_controller = new RGBController_AlienwareAW3423DWF(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -58,7 +58,7 @@ void DetectAlienwareMonitorControllers(hid_device_info* info, const std::string& AlienwareMonitorController* controller = new AlienwareMonitorController(dev, info->path, name); RGBController_AlienwareMonitor* rgb_controller = new RGBController_AlienwareMonitor(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AnnePro2Controller/AnnePro2ControllerDetect.cpp b/Controllers/AnnePro2Controller/AnnePro2ControllerDetect.cpp index 4011417fe..e5df30f30 100644 --- a/Controllers/AnnePro2Controller/AnnePro2ControllerDetect.cpp +++ b/Controllers/AnnePro2Controller/AnnePro2ControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AnnePro2Controller.h" #include "RGBController_AnnePro2.h" #include @@ -46,7 +46,7 @@ void DetectAnnePro2Controllers(hid_device_info* info, const std::string&) AnnePro2Controller* controller = new AnnePro2Controller(dev, info->path); RGBController_AnnePro2* rgb_controller = new RGBController_AnnePro2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ArcticController/ArcticControllerDetect.cpp b/Controllers/ArcticController/ArcticControllerDetect.cpp index f4da117b1..6fa57e256 100644 --- a/Controllers/ArcticController/ArcticControllerDetect.cpp +++ b/Controllers/ArcticController/ArcticControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ArcticController.h" #include "RGBController_Arctic.h" #include "find_usb_serial_port.h" @@ -29,7 +29,7 @@ void DetectArcticControllers() if(controller->IsPresent()) { RGBController_Arctic *rgb_controller = new RGBController_Arctic(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/AresonController/AresonControllerDetect.cpp b/Controllers/AresonController/AresonControllerDetect.cpp index c18bea329..25e3cf779 100644 --- a/Controllers/AresonController/AresonControllerDetect.cpp +++ b/Controllers/AresonController/AresonControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AresonController.h" #include "RGBController_Areson.h" @@ -37,7 +37,7 @@ void DetectAresonControllers(hid_device_info* info, const std::string& name) AresonController* controller = new AresonController(dev, *info, name); RGBController_Areson* rgb_controller = new RGBController_Areson(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AsusAuraCoreController/AsusAuraCoreControllerDetect.cpp b/Controllers/AsusAuraCoreController/AsusAuraCoreControllerDetect.cpp index a1791e66a..2ab0034c5 100644 --- a/Controllers/AsusAuraCoreController/AsusAuraCoreControllerDetect.cpp +++ b/Controllers/AsusAuraCoreController/AsusAuraCoreControllerDetect.cpp @@ -10,7 +10,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AsusAuraCoreController.h" #include "RGBController.h" #include "RGBController_AsusAuraCore.h" @@ -38,7 +38,7 @@ void DetectAsusAuraCoreControllers(hid_device_info* info, const std::string& /*n if(rgb_controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN) { - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -56,7 +56,7 @@ void DetectAsusAuraCoreLaptopControllers(hid_device_info* info, const std::strin AsusAuraCoreLaptopController* controller = new AsusAuraCoreLaptopController(dev, info->path); RGBController_AsusAuraCoreLaptop* rgb_controller = new RGBController_AsusAuraCoreLaptop(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AsusAuraCoreController/AsusAuraCoreLaptopController/AsusAuraCoreLaptopController.cpp b/Controllers/AsusAuraCoreController/AsusAuraCoreLaptopController/AsusAuraCoreLaptopController.cpp index 8b751cdc1..69b182ed8 100644 --- a/Controllers/AsusAuraCoreController/AsusAuraCoreLaptopController/AsusAuraCoreLaptopController.cpp +++ b/Controllers/AsusAuraCoreController/AsusAuraCoreLaptopController/AsusAuraCoreLaptopController.cpp @@ -11,6 +11,7 @@ #include "AsusAuraCoreLaptopController.h" #include "dmiinfo.h" +#include "ResourceManager.h" #include "SettingsManager.h" #include "StringUtils.h" diff --git a/Controllers/AsusAuraCoreController/AsusAuraCoreLaptopController/AsusAuraCoreLaptopController.h b/Controllers/AsusAuraCoreController/AsusAuraCoreLaptopController/AsusAuraCoreLaptopController.h index 3d57a9fcf..d7e8c3de4 100644 --- a/Controllers/AsusAuraCoreController/AsusAuraCoreLaptopController/AsusAuraCoreLaptopController.h +++ b/Controllers/AsusAuraCoreController/AsusAuraCoreLaptopController/AsusAuraCoreLaptopController.h @@ -15,8 +15,8 @@ #include #include #include "LogManager.h" -#include "RGBController.h" #include "ResourceManager.h" +#include "RGBController.h" #include "RGBControllerKeyNames.h" #include "AsusAuraCoreLaptopDevices.h" diff --git a/Controllers/AsusAuraGPUController/AsusAuraGPUControllerDetect.cpp b/Controllers/AsusAuraGPUController/AsusAuraGPUControllerDetect.cpp index ec008c1df..f108f0048 100644 --- a/Controllers/AsusAuraGPUController/AsusAuraGPUControllerDetect.cpp +++ b/Controllers/AsusAuraGPUController/AsusAuraGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AsusAuraGPUController.h" #include "LogManager.h" #include "RGBController_AsusAuraGPU.h" @@ -65,7 +65,7 @@ void DetectAsusAuraGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, co AuraGPUController* controller = new AuraGPUController(bus, i2c_addr, name); RGBController_AuraGPU* rgb_controller = new RGBController_AuraGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectAsusAuraGPUControllers() */ diff --git a/Controllers/AsusAuraUSBController/AsusAuraUSBControllerDetect.cpp b/Controllers/AsusAuraUSBController/AsusAuraUSBControllerDetect.cpp index 42a1222fc..9ebfe4c04 100644 --- a/Controllers/AsusAuraUSBController/AsusAuraUSBControllerDetect.cpp +++ b/Controllers/AsusAuraUSBController/AsusAuraUSBControllerDetect.cpp @@ -9,7 +9,7 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "AsusAuraAddressableController.h" #include "AsusAuraHeadsetStandController.h" #include "AsusAuraKeyboardController.h" @@ -152,7 +152,7 @@ void DetectAsusAuraUSBTerminal(hid_device_info* info, const std::string& name) AuraAddressableController* controller = new AuraAddressableController(dev, info->path, name); RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -166,7 +166,7 @@ void DetectAsusAuraUSBAddressable(hid_device_info* info, const std::string& /*na AuraAddressableController* controller = new AuraAddressableController(dev, info->path, "ASUS " + dmi.getMainboard() + " Addressable"); RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -182,7 +182,7 @@ void DetectAsusAuraUSBMotherboards(hid_device_info* info, const std::string& /*n AuraMainboardController* controller = new AuraMainboardController(dev, info->path, "ASUS " + dmi.getMainboard()); RGBController_AuraMainboard* rgb_controller = new RGBController_AuraMainboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } catch(const std::runtime_error& ex) { @@ -202,7 +202,7 @@ void DetectAsusAuraUSBKeyboards(hid_device_info* info, const std::string& name) AuraKeyboardMappingLayoutType layout = GetKeyboardMappingLayoutType(info->product_id); RGBController_AuraKeyboard* rgb_controller = new RGBController_AuraKeyboard(controller, layout); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -216,7 +216,7 @@ void DetectAsusAuraUSBMice(hid_device_info* info, const std::string& name) AuraMouseController* controller = new AuraMouseController(dev, info->path, pid, name); RGBController_AuraMouse* rgb_controller = new RGBController_AuraMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -229,7 +229,7 @@ void DetectAsusAuraUSBMousemats(hid_device_info* info, const std::string& name) AuraMousematController* controller = new AuraMousematController(dev, info->path, name); RGBController_AuraMousemat* rgb_controller = new RGBController_AuraMousemat(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -242,7 +242,7 @@ void DetectAsusAuraUSBROGStrixLC(hid_device_info* info, const std::string& name) AsusROGStrixLCController* controller = new AsusROGStrixLCController(dev, info->path, name); RGBController_AsusROGStrixLC* rgb_controller = new RGBController_AsusROGStrixLC(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -255,7 +255,7 @@ void DetectAsusAuraUSBRyuoAIO(hid_device_info* info, const std::string& name) AsusAuraRyuoAIOController* controller = new AsusAuraRyuoAIOController(dev, info->path, name); RGBController_AsusAuraRyuoAIO* rgb_controller = new RGBController_AsusAuraRyuoAIO(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -268,7 +268,7 @@ void DetectAsusAuraUSBStrixEvolve(hid_device_info* info, const std::string& name AsusAuraMouseGen1Controller* controller = new AsusAuraMouseGen1Controller(dev, info->path, info->product_id, name); RGBController_AsusROGStrixEvolve* rgb_controller = new RGBController_AsusROGStrixEvolve(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -281,7 +281,7 @@ void DetectAsusAuraUSBSpatha(hid_device_info* info, const std::string& name) AsusAuraMouseGen1Controller* controller = new AsusAuraMouseGen1Controller(dev, info->path, info->product_id, name); RGBController_AsusROGSpatha* rgb_controller = new RGBController_AsusROGSpatha(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -294,7 +294,7 @@ void DetectAsusAuraUSBHeadsetStand(hid_device_info* info, const std::string& nam AuraHeadsetStandController* controller = new AuraHeadsetStandController(dev, info->path, name); RGBController_AuraHeadsetStand* rgb_controller = new RGBController_AuraHeadsetStand(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -307,7 +307,7 @@ void DetectAsusAuraTUFUSBKeyboard(hid_device_info* info, const std::string& name AuraTUFKeyboardController* controller = new AuraTUFKeyboardController(dev, info->path, info->product_id, info->release_number, name); RGBController_AuraTUFKeyboard* rgb_controller = new RGBController_AuraTUFKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -320,7 +320,7 @@ void DetectAsusAuraUSBMonitor(hid_device_info* info, const std::string& name) AuraMonitorController* controller = new AuraMonitorController(dev, info->path, info->product_id, name); RGBController_AuraMonitor* rgb_controller = new RGBController_AuraMonitor(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -333,7 +333,7 @@ void DetectAsusROGAlly(hid_device_info* info, const std::string& name) ROGAllyController* controller = new ROGAllyController(dev, info->path, name); RGBController_AsusROGAlly* rgb_controller = new RGBController_AsusROGAlly(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AsusLegacyUSBController/AsusLegacyUSBControllerDetect.cpp b/Controllers/AsusLegacyUSBController/AsusLegacyUSBControllerDetect.cpp index e63a1b96b..11904cbef 100644 --- a/Controllers/AsusLegacyUSBController/AsusLegacyUSBControllerDetect.cpp +++ b/Controllers/AsusLegacyUSBController/AsusLegacyUSBControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "AsusCerberusKeyboardController.h" #include "AsusSagarisKeyboardController.h" #include "AsusStrixClawController.h" @@ -32,7 +32,7 @@ void DetectAsusCerberusMech(hid_device_info* info, const std::string& name) AsusCerberusKeyboardController* controller = new AsusCerberusKeyboardController(dev, info->path, info->release_number, name); RGBController_AsusCerberusKeyboard* rgb_controller = new RGBController_AsusCerberusKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -45,7 +45,7 @@ void DetectAsusSagarisKeyboard(hid_device_info* info, const std::string& name) AsusSagarisKeyboardController* controller = new AsusSagarisKeyboardController(dev, info->path, info->release_number, name); RGBController_AsusSagarisKeyboard* rgb_controller = new RGBController_AsusSagarisKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -58,7 +58,7 @@ void DetectAsusStrixClaw(hid_device_info* info, const std::string& name) StrixClawController* controller = new StrixClawController(dev, info->path, name); RGBController_StrixClaw* rgb_controller = new RGBController_StrixClaw(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AsusMonitorController/AsusMonitorControllerDetect.cpp b/Controllers/AsusMonitorController/AsusMonitorControllerDetect.cpp index c9fe3b45c..f69ffd2be 100644 --- a/Controllers/AsusMonitorController/AsusMonitorControllerDetect.cpp +++ b/Controllers/AsusMonitorController/AsusMonitorControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "AsusMonitorController.h" #include "RGBController_AsusMonitor.h" @@ -34,7 +34,7 @@ void DetectAsusMonitorControllers(hid_device_info* info, const std::string& name AsusMonitorController* controller = new AsusMonitorController(dev, *info, name); RGBController_AsusMonitor* rgb_controller = new RGBController_AsusMonitor(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Linux.cpp b/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Linux.cpp index 96bb545c9..751413299 100644 --- a/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Linux.cpp +++ b/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Linux.cpp @@ -9,7 +9,7 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_AsusTUFLaptop_Linux.h" static void DetectAsusTUFLaptopLinuxControllers() @@ -27,7 +27,7 @@ static void DetectAsusTUFLaptopLinuxControllers() { AsusTUFLaptopLinuxController* controller = new AsusTUFLaptopLinuxController(); RGBController_AsusTUFLaptopLinux* rgb_controller = new RGBController_AsusTUFLaptopLinux(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } return; } diff --git a/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Windows.cpp b/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Windows.cpp index ddf200d6d..8ef85fd95 100644 --- a/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Windows.cpp +++ b/Controllers/AsusTUFLaptopController/AsusTUFLaptopDetect_Windows.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_AsusTUFLaptop_Windows.h" #include "wmi.h" @@ -45,7 +45,7 @@ static void DetectAsusTUFLaptopWMIControllers() { RGBController* new_controller = new RGBController_AsusTUFLaptopWMI(controller); - ResourceManager::get()->RegisterRGBController(new_controller); + DetectionManager::get()->RegisterRGBController(new_controller); } } /* DetectAsusTUFLaptopWMIControllers() */ diff --git a/Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp b/Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp index ab2a920a7..9ac1e660c 100644 --- a/Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp +++ b/Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "BlinkyTapeController.h" #include "RGBController_BlinkyTape.h" #include "find_usb_serial_port.h" @@ -39,7 +39,7 @@ void DetectBlinkyTapeControllers() controller->Initialize(*device_locations[device_idx]); RGBController_BlinkyTape* rgb_controller = new RGBController_BlinkyTape(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CherryKeyboardController/CherryKeyboardControllerDetect.cpp b/Controllers/CherryKeyboardController/CherryKeyboardControllerDetect.cpp index ce2c06c64..1eafe2e2a 100644 --- a/Controllers/CherryKeyboardController/CherryKeyboardControllerDetect.cpp +++ b/Controllers/CherryKeyboardController/CherryKeyboardControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CherryKeyboardController.h" #include "RGBController_CherryKeyboard.h" @@ -36,7 +36,7 @@ void DetectCherryKeyboards(hid_device_info* info, const std::string& name) CherryKeyboardController* controller = new CherryKeyboardController(dev, info->path, name); RGBController_CherryKeyboard* rgb_controller = new RGBController_CherryKeyboard(controller, info->product_id); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp b/Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp index bb988cc8c..d80c03767 100644 --- a/Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp +++ b/Controllers/ColorfulGPUController/ColorfulGPUControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "ColorfulGPUController.h" #include "RGBController_ColorfulGPU.h" @@ -40,7 +40,7 @@ void DetectColorfulGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, co ColorfulGPUController* controller = new ColorfulGPUController(bus, i2c_addr, name); RGBController_ColorfulGPU* rgb_controller = new RGBController_ColorfulGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ColorfulTuringGPUController/ColorfulTuringGPUControllerDetect.cpp b/Controllers/ColorfulTuringGPUController/ColorfulTuringGPUControllerDetect.cpp index 8349e772f..e11fe61a2 100644 --- a/Controllers/ColorfulTuringGPUController/ColorfulTuringGPUControllerDetect.cpp +++ b/Controllers/ColorfulTuringGPUController/ColorfulTuringGPUControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "ColorfulTuringGPUController.h" #include "RGBController_ColorfulTuringGPU.h" #include "i2c_smbus.h" @@ -20,7 +20,7 @@ void DetectColorfulTuringGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_ad ColorfulTuringGPUController* controller = new ColorfulTuringGPUController(bus, i2c_addr, name); RGBController_ColorfulTuringGPU* rgb_controller = new RGBController_ColorfulTuringGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp b/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp index c4e14c937..28431ae3d 100644 --- a/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp +++ b/Controllers/CoolerMasterController/CoolerMasterControllerDetect.cpp @@ -11,7 +11,7 @@ | OpenRGB includes | \*-----------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" /*-----------------------------------------------------*\ @@ -107,7 +107,7 @@ void DetectCoolerMasterARGB(hid_device_info* info, const std::string&) CMARGBController* controller = new CMARGBController(dev, info->path, i, cm_mutex); RGBController_CMARGBController* rgb_controller = new RGBController_CMARGBController(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } @@ -121,7 +121,7 @@ void DetectCoolerMasterARGBGen2A1(hid_device_info* info, const std::string& name CMARGBGen2A1controller* controller = new CMARGBGen2A1controller(dev, *info, name); RGBController_CMARGBGen2A1Controller* rgb_controller = new RGBController_CMARGBGen2A1Controller(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -134,7 +134,7 @@ void DetectCoolerMasterGPU(hid_device_info* info, const std::string&) CMR6000Controller* controller = new CMR6000Controller(dev, info->path, info->product_id); RGBController_CMR6000Controller* rgb_controller = new RGBController_CMR6000Controller(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -153,7 +153,7 @@ void DetectCoolerMasterV1Keyboards(hid_device_info* info, const std::string& nam CMKeyboardV1Controller* controller = new CMKeyboardV1Controller(dev, info, name); RGBController_CMKeyboardController* rgb_controller = new RGBController_CMKeyboardController(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; @@ -179,7 +179,7 @@ void DetectCoolerMasterV2Keyboards(hid_device_info* info, const std::string& nam CMKeyboardV1Controller* controller = new CMKeyboardV1Controller(dev, info, name); RGBController_CMKeyboardController* rgb_controller = new RGBController_CMKeyboardController(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; @@ -199,7 +199,7 @@ void DetectCoolerMasterV2Keyboards(hid_device_info* info, const std::string& nam CMKeyboardV2Controller* controller = new CMKeyboardV2Controller(dev, info, name); RGBController_CMKeyboardController* rgb_controller = new RGBController_CMKeyboardController(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; @@ -219,7 +219,7 @@ void DetectCoolerMasterMouse(hid_device_info* info, const std::string& name) CMMMController* controller = new CMMMController(dev, info->path, info->product_id, name); RGBController_CMMMController* rgb_controller = new RGBController_CMMMController(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -232,7 +232,7 @@ void DetectCoolerMasterMouse711(hid_device_info* info, const std::string& /*name CMMM711Controller* controller = new CMMM711Controller(dev, info->path); RGBController_CMMM711Controller* rgb_controller = new RGBController_CMMM711Controller(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -245,7 +245,7 @@ void DetectCoolerMasterMouse712(hid_device_info* info, const std::string& /*name CMMM712Controller* controller = new CMMM712Controller(dev, info->path); RGBController_CMMM712Controller* rgb_controller = new RGBController_CMMM712Controller(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -258,7 +258,7 @@ void DetectCoolerMasterMousemats(hid_device_info* info, const std::string& /*nam CMMP750Controller* controller = new CMMP750Controller(dev, info->path); RGBController_CMMP750Controller* rgb_controller = new RGBController_CMMP750Controller(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -271,7 +271,7 @@ void DetectCoolerMasterRGB(hid_device_info* info, const std::string& /*name*/) CMRGBController* controller = new CMRGBController(dev, info->path); RGBController_CMRGBController* rgb_controller = new RGBController_CMRGBController(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -284,7 +284,7 @@ void DetectCoolerMasterSmallARGB(hid_device_info* info, const std::string& /*nam CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path, 0); RGBController_CMSmallARGBController* rgb_controller = new RGBController_CMSmallARGBController(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -297,7 +297,7 @@ void DetectCoolerMasterMonitor(hid_device_info* info, const std::string& name) CMMonitorController* controller = new CMMonitorController(dev, *info, name); RGBController_CMMonitorController* rgb_controller = new RGBController_CMMonitorController(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -310,7 +310,7 @@ void DetectCoolerMasterGD160(hid_device_info* info, const std::string& name) CMGD160Controller* controller = new CMGD160Controller(dev, *info, name); RGBController_CMGD160Controller* rgb_controller = new RGBController_CMGD160Controller(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CorsairCommanderCoreController/CorsairCommanderCoreControllerDetect.cpp b/Controllers/CorsairCommanderCoreController/CorsairCommanderCoreControllerDetect.cpp index e58525fd7..2ef22912a 100644 --- a/Controllers/CorsairCommanderCoreController/CorsairCommanderCoreControllerDetect.cpp +++ b/Controllers/CorsairCommanderCoreController/CorsairCommanderCoreControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CorsairCommanderCoreController.h" #include "RGBController_CorsairCommanderCore.h" @@ -36,7 +36,7 @@ void DetectCorsairCommanderCoreControllers(hid_device_info* info, const std::str CorsairCommanderCoreController* controller = new CorsairCommanderCoreController(dev, info->path, info->product_id, name); RGBController_CorsairCommanderCore* rgb_controller = new RGBController_CorsairCommanderCore(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumControllerDetect.cpp b/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumControllerDetect.cpp index 48d0fddb6..c640d6260 100644 --- a/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumControllerDetect.cpp +++ b/Controllers/CorsairDominatorPlatinumController/CorsairDominatorPlatinumControllerDetect.cpp @@ -10,13 +10,14 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" #include "CorsairDominatorPlatinumController.h" +#include "DetectionManager.h" +#include "i2c_smbus.h" +#include "LogManager.h" +#include "pci_ids.h" +#include "ResourceManager.h" #include "RGBController_CorsairDominatorPlatinum.h" #include "SettingsManager.h" -#include "LogManager.h" -#include "i2c_smbus.h" -#include "pci_ids.h" using namespace std::chrono_literals; @@ -160,7 +161,7 @@ void DetectCorsairDominatorPlatinumControllers(std::vectorRegisterRGBController(rgbcontroller); + DetectionManager::get()->RegisterRGBController(rgbcontroller); } std::this_thread::sleep_for(10ms); diff --git a/Controllers/CorsairHydro2Controller/CorsairHydro2ControllerDetect.cpp b/Controllers/CorsairHydro2Controller/CorsairHydro2ControllerDetect.cpp index 8d8c487ac..6cf5e39ef 100644 --- a/Controllers/CorsairHydro2Controller/CorsairHydro2ControllerDetect.cpp +++ b/Controllers/CorsairHydro2Controller/CorsairHydro2ControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CorsairHydro2Controller.h" #include "RGBController_CorsairHydro2.h" @@ -35,7 +35,7 @@ void DetectCorsairHydro2Controllers() CorsairHydro2Controller* controller = new CorsairHydro2Controller(dev); RGBController_CorsairHydro2* rgb_controller = new RGBController_CorsairHydro2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp b/Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp index 031685db2..9d87ce7dc 100644 --- a/Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp +++ b/Controllers/CorsairHydroController/CorsairHydroControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CorsairHydroController.h" #include "RGBController_CorsairHydro.h" @@ -75,7 +75,7 @@ void DetectCorsairHydroControllers() CorsairHydroController* controller = new CorsairHydroController(dev, device_list[device_idx].name); RGBController_CorsairHydro* rgb_controller = new RGBController_CorsairHydro(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectCorsairHydroControllers() */ diff --git a/Controllers/CorsairHydroPlatinumController/CorsairHydroPlatinumControllerDetect.cpp b/Controllers/CorsairHydroPlatinumController/CorsairHydroPlatinumControllerDetect.cpp index 77abda3b4..4e28d6336 100644 --- a/Controllers/CorsairHydroPlatinumController/CorsairHydroPlatinumControllerDetect.cpp +++ b/Controllers/CorsairHydroPlatinumController/CorsairHydroPlatinumControllerDetect.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CorsairHydroPlatinumController.h" #include "RGBController_CorsairHydroPlatinum.h" @@ -65,7 +65,7 @@ void DetectCorsairHydroPlatinumControllers(hid_device_info* info, const std::str CorsairHydroPlatinumController* controller = new CorsairHydroPlatinumController(dev, info->path, dev_rgb_fan, name); RGBController_CorsairHydroPlatinum* rgb_controller = new RGBController_CorsairHydroPlatinum(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CorsairICueLinkController/CorsairICueLinkControllerDetect.cpp b/Controllers/CorsairICueLinkController/CorsairICueLinkControllerDetect.cpp index 0c9d0436d..f7f1d2179 100644 --- a/Controllers/CorsairICueLinkController/CorsairICueLinkControllerDetect.cpp +++ b/Controllers/CorsairICueLinkController/CorsairICueLinkControllerDetect.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "CorsairICueLinkController.h" #include "RGBController_CorsairICueLink.h" @@ -28,7 +28,7 @@ void DetectCorsairICueLinkControllers(hid_device_info* info, const std::string& CorsairICueLinkController* controller = new CorsairICueLinkController(dev, info->path, name); RGBController_CorsairICueLink* rgb_controller = new RGBController_CorsairICueLink(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CorsairLightingNodeController/CorsairLightingNodeControllerDetect.cpp b/Controllers/CorsairLightingNodeController/CorsairLightingNodeControllerDetect.cpp index e094a84bc..4508999a0 100644 --- a/Controllers/CorsairLightingNodeController/CorsairLightingNodeControllerDetect.cpp +++ b/Controllers/CorsairLightingNodeController/CorsairLightingNodeControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CorsairLightingNodeController.h" #include "RGBController_CorsairLightingNode.h" @@ -40,7 +40,7 @@ void DetectCorsairLightingNodeControllers(hid_device_info* info, const std::stri CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev, info->path, name); RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectCorsairLightingNodeControllers() */ diff --git a/Controllers/CorsairPeripheralController/CorsairPeripheralControllerDetect.cpp b/Controllers/CorsairPeripheralController/CorsairPeripheralControllerDetect.cpp index 7d19052b4..d4083668b 100644 --- a/Controllers/CorsairPeripheralController/CorsairPeripheralControllerDetect.cpp +++ b/Controllers/CorsairPeripheralController/CorsairPeripheralControllerDetect.cpp @@ -11,7 +11,7 @@ | OpenRGB includes | \*-----------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "RGBController.h" @@ -115,7 +115,7 @@ void DetectCorsairK55RGBPROXTControllers(hid_device_info* info, const std::strin CorsairK55RGBPROXTController* controller = new CorsairK55RGBPROXTController(dev, info->path, name); RGBController_CorsairK55RGBPROXT* rgb_controller = new RGBController_CorsairK55RGBPROXT(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectCorsairK55RGBPROXTControllers() */ @@ -128,7 +128,7 @@ void DetectCorsairK65MiniControllers(hid_device_info* info, const std::string& n CorsairK65MiniController* controller = new CorsairK65MiniController(dev, info->path, name); RGBController_CorsairK65Mini* rgb_controller = new RGBController_CorsairK65Mini(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectCorsairK65MiniControllers() */ @@ -156,7 +156,7 @@ void DetectCorsairPeripheralControllers(hid_device_info* info, const std::string (info->product_id == CORSAIR_K70_RGB_MK2_LP_PID); RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller, supports_hardware_modes); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp index 2fe530c4c..2e0475f19 100644 --- a/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp +++ b/Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp @@ -11,7 +11,7 @@ | OpenRGB includes | \*-----------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" /*-----------------------------------------------------*\ | Corsair Peripheral specific includes | @@ -36,7 +36,7 @@ void DetectCorsairV2HardwareControllers(hid_device_info* info, const std::string CorsairPeripheralV2HWController* controller = new CorsairPeripheralV2HWController(dev, info->path, name); RGBController_CorsairV2HW* rgb_controller = new RGBController_CorsairV2HW(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectCorsairV2HardwareControllers() */ @@ -49,7 +49,7 @@ void DetectCorsairV2SoftwareControllers(hid_device_info* info, const std::string CorsairPeripheralV2SWController* controller = new CorsairPeripheralV2SWController(dev, info->path, name); RGBController_CorsairV2SW* rgb_controller = new RGBController_CorsairV2SW(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectCorsairV2SoftwareControllers() */ diff --git a/Controllers/CorsairVengeanceController/CorsairVengeanceControllerDetect.cpp b/Controllers/CorsairVengeanceController/CorsairVengeanceControllerDetect.cpp index 7e3b3d10e..1bff67f05 100644 --- a/Controllers/CorsairVengeanceController/CorsairVengeanceControllerDetect.cpp +++ b/Controllers/CorsairVengeanceController/CorsairVengeanceControllerDetect.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CorsairVengeanceController.h" #include "RGBController_CorsairVengeance.h" #include "i2c_smbus.h" @@ -75,7 +75,7 @@ void DetectCorsairVengeanceControllers(i2c_smbus_interface* bus, std::vectorRegisterRGBController(new_rgbcontroller); + DetectionManager::get()->RegisterRGBController(new_rgbcontroller); } /*-------------------------------------------------*\ @@ -88,9 +88,9 @@ void DetectCorsairVengeanceControllers(i2c_smbus_interface* bus, std::vectorRegisterRGBController(new_rgbcontroller); + DetectionManager::get()->RegisterRGBController(new_rgbcontroller); } } } /* DetectCorsairVengeanceControllers() */ -REGISTER_I2C_DIMM_DETECTOR("Corsair Vengeance RGB DRAM", DetectCorsairVengeanceControllers, JEDEC_CORSAIR, SPD_DDR4_SDRAM); +REGISTER_I2C_DRAM_DETECTOR("Corsair Vengeance RGB DRAM", DetectCorsairVengeanceControllers, JEDEC_CORSAIR, SPD_DDR4_SDRAM); diff --git a/Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp b/Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp index bced901d3..2ef5baf6a 100644 --- a/Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp +++ b/Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CorsairVengeanceProController.h" #include "RGBController_CorsairVengeancePro.h" #include "i2c_smbus.h" @@ -92,7 +92,7 @@ void DetectCorsairVengeanceProControllers(std::vector &bus CorsairVengeanceProController* new_controller = new CorsairVengeanceProController(busses[bus], addr); RGBController_CorsairVengeancePro* new_rgbcontroller = new RGBController_CorsairVengeancePro(new_controller); - ResourceManager::get()->RegisterRGBController(new_rgbcontroller); + DetectionManager::get()->RegisterRGBController(new_rgbcontroller); } } } diff --git a/Controllers/CorsairWirelessController/CorsairWirelessControllerDetect.cpp b/Controllers/CorsairWirelessController/CorsairWirelessControllerDetect.cpp index dfc98fde6..6959efa20 100644 --- a/Controllers/CorsairWirelessController/CorsairWirelessControllerDetect.cpp +++ b/Controllers/CorsairWirelessController/CorsairWirelessControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CorsairWirelessController.h" #include "RGBController.h" #include "RGBController_CorsairWireless.h" @@ -46,7 +46,7 @@ void DetectCorsairWirelessControllers(hid_device_info* info, const std::string& if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN) { RGBController_CorsairWireless* rgb_controller = new RGBController_CorsairWireless(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/CougarController/CougarControllerDetect.cpp b/Controllers/CougarController/CougarControllerDetect.cpp index e2da26ef3..d9776d4dd 100644 --- a/Controllers/CougarController/CougarControllerDetect.cpp +++ b/Controllers/CougarController/CougarControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_CougarKeyboard.h" #include "RGBController_CougarRevengerST.h" @@ -32,7 +32,7 @@ void DetectCougarRevengerSTControllers(hid_device_info* info, const std::string& CougarRevengerSTController* controller = new CougarRevengerSTController(dev, *info, name); RGBController_CougarRevengerST* rgb_controller = new RGBController_CougarRevengerST(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -45,7 +45,7 @@ void DetectCougar700kEvo(hid_device_info* info, const std::string& name) CougarKeyboardController* controller = new CougarKeyboardController(dev, info->path, name); RGBController_CougarKeyboard* rgb_controller = new RGBController_CougarKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CreativeController/CreativeControllerDetect.cpp b/Controllers/CreativeController/CreativeControllerDetect.cpp index 5f508e16a..dfb6cd7ca 100644 --- a/Controllers/CreativeController/CreativeControllerDetect.cpp +++ b/Controllers/CreativeController/CreativeControllerDetect.cpp @@ -10,7 +10,7 @@ #include #include "CreativeSoundBlasterXG6Controller.h" #include "RGBController_CreativeSoundBlasterXG6.h" -#include "Detector.h" +#include "DetectionManager.h" /*-----------------------------------------------------*\ | Creative vendor ID | @@ -30,7 +30,7 @@ void DetectCreativeDevice(hid_device_info* info, const std::string& name) CreativeSoundBlasterXG6Controller* controller = new CreativeSoundBlasterXG6Controller(dev, info->path, name); RGBController_CreativeSoundBlasterXG6* rgb_controller = new RGBController_CreativeSoundBlasterXG6(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CreativeController/CreativeSoundBlasterAE5ControllerDetect_Windows.cpp b/Controllers/CreativeController/CreativeSoundBlasterAE5ControllerDetect_Windows.cpp index 637d673d5..eacfcd17e 100644 --- a/Controllers/CreativeController/CreativeSoundBlasterAE5ControllerDetect_Windows.cpp +++ b/Controllers/CreativeController/CreativeSoundBlasterAE5ControllerDetect_Windows.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "CreativeSoundBlasterAE5Controller_Windows.h" #include "RGBController_CreativeSoundBlasterAE5_Windows.h" #include "LogManager.h" @@ -22,7 +22,7 @@ void DetectCreativeAE5Device() { LOG_INFO("[Creative SoundBlaster AE-5] Device initialized successfully, registering controller"); RGBController_CreativeSoundBlasterAE5* rgb_controller = new RGBController_CreativeSoundBlasterAE5(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -31,4 +31,4 @@ void DetectCreativeAE5Device() } } -REGISTER_DETECTOR("Creative SoundBlaster AE-5", DetectCreativeAE5Device); \ No newline at end of file +REGISTER_DETECTOR("Creative SoundBlaster AE-5", DetectCreativeAE5Device); diff --git a/Controllers/CrucialController/CrucialControllerDetect.cpp b/Controllers/CrucialController/CrucialControllerDetect.cpp index d91b93203..c982943df 100644 --- a/Controllers/CrucialController/CrucialControllerDetect.cpp +++ b/Controllers/CrucialController/CrucialControllerDetect.cpp @@ -11,7 +11,7 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "CrucialController.h" #include "LogManager.h" #include "RGBController_Crucial.h" @@ -223,7 +223,7 @@ void DetectCrucialControllers(std::vector &busses) CrucialController* controller = new CrucialController(busses[bus], crucial_addresses[address_list_idx]); RGBController_Crucial* rgb_controller = new RGBController_Crucial(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } std::this_thread::sleep_for(1ms); diff --git a/Controllers/CryorigH7QuadLumiController/CryorigH7QuadLumiControllerDetect.cpp b/Controllers/CryorigH7QuadLumiController/CryorigH7QuadLumiControllerDetect.cpp index e3b315f8b..d07975175 100644 --- a/Controllers/CryorigH7QuadLumiController/CryorigH7QuadLumiControllerDetect.cpp +++ b/Controllers/CryorigH7QuadLumiController/CryorigH7QuadLumiControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "CryorigH7QuadLumiController.h" #include "RGBController_CryorigH7QuadLumi.h" @@ -29,7 +29,7 @@ static void DetectCryorigH7QuadLumi(hid_device_info* info, const std::string& na CryorigH7QuadLumiController* controller = new CryorigH7QuadLumiController(dev, info->path, name); RGBController_CryorigH7QuadLumi* rgb_controller = new RGBController_CryorigH7QuadLumi(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/DDPController/DDPControllerDetect.cpp b/Controllers/DDPController/DDPControllerDetect.cpp index cbf0db0ae..27451add8 100644 --- a/Controllers/DDPController/DDPControllerDetect.cpp +++ b/Controllers/DDPController/DDPControllerDetect.cpp @@ -9,12 +9,13 @@ #include #include -#include "Detector.h" +#include "nlohmann/json.hpp" +#include "DetectionManager.h" +#include "LogManager.h" +#include "ResourceManager.h" #include "RGBController.h" #include "RGBController_DDP.h" #include "SettingsManager.h" -#include "LogManager.h" -#include "nlohmann/json.hpp" using json = nlohmann::json; @@ -84,7 +85,7 @@ void DetectDDPControllers() for(unsigned int list_idx = 0; list_idx < device_lists.size(); list_idx++) { RGBController_DDP* rgb_controller = new RGBController_DDP(device_lists[list_idx]); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/DMXController/DMXControllerDetect.cpp b/Controllers/DMXController/DMXControllerDetect.cpp index 367cddedb..91d38d6aa 100644 --- a/Controllers/DMXController/DMXControllerDetect.cpp +++ b/Controllers/DMXController/DMXControllerDetect.cpp @@ -10,7 +10,8 @@ #include #include #include -#include "Detector.h" +#include "DetectionManager.h" +#include "ResourceManager.h" #include "RGBController_DMX.h" #include "SettingsManager.h" @@ -135,7 +136,7 @@ void DetectDMXControllers() { RGBController_DMX* rgb_controller; rgb_controller = new RGBController_DMX(device_lists[list_idx]); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/DRGBController/DRGBControllerDetect.cpp b/Controllers/DRGBController/DRGBControllerDetect.cpp index 23c13527b..3ecee0595 100644 --- a/Controllers/DRGBController/DRGBControllerDetect.cpp +++ b/Controllers/DRGBController/DRGBControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "DRGBController.h" #include "RGBController_DRGB.h" @@ -27,7 +27,7 @@ void DetectDRGBControllers(hid_device_info* info, const std::string& name) DRGBController* controller = new DRGBController(dev, info->path, info->product_id, name); RGBController_DRGB* rgb_controller = new RGBController_DRGB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/DarkProject/DarkProjectControllerDetect.cpp b/Controllers/DarkProject/DarkProjectControllerDetect.cpp index 0117c3edd..763b94f90 100644 --- a/Controllers/DarkProject/DarkProjectControllerDetect.cpp +++ b/Controllers/DarkProject/DarkProjectControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_DarkProjectKeyboard.h" /*---------------------------------------------------------*\ @@ -31,7 +31,7 @@ void DetectDarkProjectKeyboardControllers(hid_device_info* info, const std::stri DarkProjectKeyboardController* controller = new DarkProjectKeyboardController(dev, info->path, name); RGBController_DarkProjectKeyboard* rgb_controller = new RGBController_DarkProjectKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/DasKeyboardController/DasKeyboardControllerDetect.cpp b/Controllers/DasKeyboardController/DasKeyboardControllerDetect.cpp index a7c2abea9..927062239 100644 --- a/Controllers/DasKeyboardController/DasKeyboardControllerDetect.cpp +++ b/Controllers/DasKeyboardController/DasKeyboardControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "DasKeyboardController.h" #include "RGBController_DasKeyboard.h" #include @@ -51,7 +51,7 @@ void DetectDasKeyboardControllers(hid_device_info *info, const std::string &name { RGBController_DasKeyboard *rgb_controller = new RGBController_DasKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectDasKeyboardControllers() */ diff --git a/Controllers/DebugController/DebugControllerDetect.cpp b/Controllers/DebugController/DebugControllerDetect.cpp index 0152ed264..7dc4f547a 100644 --- a/Controllers/DebugController/DebugControllerDetect.cpp +++ b/Controllers/DebugController/DebugControllerDetect.cpp @@ -9,7 +9,8 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" +#include "ResourceManager.h" #include "RGBController.h" #include "RGBController_Debug.h" #include "SettingsManager.h" @@ -39,7 +40,7 @@ void DetectDebugControllers() for(unsigned int device_idx = 0; device_idx < debug_settings["devices"].size(); device_idx++) { RGBController_Debug * debug_controller = new RGBController_Debug(false, debug_settings["devices"][device_idx]); - ResourceManager::get()->RegisterRGBController(debug_controller); + DetectionManager::get()->RegisterRGBController(debug_controller); } } @@ -68,7 +69,7 @@ void DetectDebugControllers() else { RGBController_Debug * debug_controller = new RGBController_Debug(true, custom_device_settings); - ResourceManager::get()->RegisterRGBController(debug_controller); + DetectionManager::get()->RegisterRGBController(debug_controller); } } } diff --git a/Controllers/DreamCheekyController/DreamCheekyControllerDetect.cpp b/Controllers/DreamCheekyController/DreamCheekyControllerDetect.cpp index dfb72db52..f54ab00bc 100644 --- a/Controllers/DreamCheekyController/DreamCheekyControllerDetect.cpp +++ b/Controllers/DreamCheekyController/DreamCheekyControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "DreamCheekyController.h" #include "RGBController_DreamCheeky.h" @@ -32,7 +32,7 @@ void DetectDreamCheekyControllers(hid_device_info* info, const std::string& name DreamCheekyController* controller = new DreamCheekyController(dev, info->path, name); RGBController_DreamCheeky* rgb_controller = new RGBController_DreamCheeky(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/DuckyKeyboardController/DuckyKeyboardControllerDetect.cpp b/Controllers/DuckyKeyboardController/DuckyKeyboardControllerDetect.cpp index 572292c0e..722cdfd46 100644 --- a/Controllers/DuckyKeyboardController/DuckyKeyboardControllerDetect.cpp +++ b/Controllers/DuckyKeyboardController/DuckyKeyboardControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "DuckyKeyboardController.h" #include "RGBController_DuckyKeyboard.h" #include @@ -31,7 +31,7 @@ void DetectDuckyKeyboardControllers(hid_device_info* info, const std::string& na DuckyKeyboardController* controller = new DuckyKeyboardController(dev, info->path, info->product_id, name); RGBController_DuckyKeyboard* rgb_controller = new RGBController_DuckyKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectDuckyKeyboardControllers() */ diff --git a/Controllers/DygmaRaiseController/DygmaRaiseControllerDetect.cpp b/Controllers/DygmaRaiseController/DygmaRaiseControllerDetect.cpp index e04fec279..b62bd82d9 100644 --- a/Controllers/DygmaRaiseController/DygmaRaiseControllerDetect.cpp +++ b/Controllers/DygmaRaiseController/DygmaRaiseControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "DygmaRaiseController.h" #include "RGBController_DygmaRaise.h" #include "find_usb_serial_port.h" @@ -39,7 +39,7 @@ void DetectDygmaRaiseControllers() controller->Initialize((char *)ports[i]->c_str()); RGBController_DygmaRaise* rgb_controller = new RGBController_DygmaRaise(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/E131Controller/E131ControllerDetect.cpp b/Controllers/E131Controller/E131ControllerDetect.cpp index e042d4be5..bf0249ce1 100644 --- a/Controllers/E131Controller/E131ControllerDetect.cpp +++ b/Controllers/E131Controller/E131ControllerDetect.cpp @@ -10,7 +10,8 @@ #include #include #include -#include "Detector.h" +#include "DetectionManager.h" +#include "ResourceManager.h" #include "RGBController.h" #include "RGBController_E131.h" #include "SettingsManager.h" @@ -278,7 +279,7 @@ void DetectE131Controllers() { RGBController_E131* rgb_controller; rgb_controller = new RGBController_E131(device_lists[list_idx]); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/EKController/EKControllerDetect.cpp b/Controllers/EKController/EKControllerDetect.cpp index 1cbf81aed..5679c35e5 100644 --- a/Controllers/EKController/EKControllerDetect.cpp +++ b/Controllers/EKController/EKControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "EKController.h" #include "RGBController_EKController.h" @@ -34,7 +34,7 @@ void DetectEKControllers(hid_device_info* info, const std::string&) EKController* controller = new EKController(dev, info->path); RGBController_EKController* rgb_controller = new RGBController_EKController(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectEKControllers() */ diff --git a/Controllers/ENESMBusController/ENESMBusControllerDetect.cpp b/Controllers/ENESMBusController/ENESMBusControllerDetect.cpp index 3f81b1873..f2e23a482 100644 --- a/Controllers/ENESMBusController/ENESMBusControllerDetect.cpp +++ b/Controllers/ENESMBusController/ENESMBusControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ENESMBusController.h" #include "ENESMBusInterface_i2c_smbus.h" #include "LogManager.h" @@ -250,7 +250,7 @@ void DetectENESMBusDRAMControllers(std::vector &busses) ENESMBusController* controller = new ENESMBusController(interface, ene_ram_addresses[address_list_idx], "ENE DRAM", DEVICE_TYPE_DRAM); RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } std::this_thread::sleep_for(1ms); @@ -291,7 +291,7 @@ void DetectENESMBusMotherboardControllers(std::vector &bus ENESMBusController* controller = new ENESMBusController(interface, aura_mobo_addresses[address_list_idx], "ASUS " + dmi.getMainboard(), DEVICE_TYPE_MOTHERBOARD); RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } std::this_thread::sleep_for(1ms); @@ -323,7 +323,7 @@ void DetectENESMBusGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, co ENESMBusController* controller = new ENESMBusController(interface, i2c_addr, name, DEVICE_TYPE_GPU); RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/ENESMBusController/RGBController_ENESMBus.cpp b/Controllers/ENESMBusController/RGBController_ENESMBus.cpp index e34663899..4a0415f60 100644 --- a/Controllers/ENESMBusController/RGBController_ENESMBus.cpp +++ b/Controllers/ENESMBusController/RGBController_ENESMBus.cpp @@ -11,8 +11,8 @@ #include "RGBController_ENESMBus.h" #include "LogManager.h" -#include "SettingsManager.h" #include "ResourceManager.h" +#include "SettingsManager.h" /**------------------------------------------------------------------*\ @name ENE SMBus Device diff --git a/Controllers/ENESMBusController/ROGArionDetect.cpp b/Controllers/ENESMBusController/ROGArionDetect.cpp index f68945911..85ec4428c 100644 --- a/Controllers/ENESMBusController/ROGArionDetect.cpp +++ b/Controllers/ENESMBusController/ROGArionDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "ENESMBusController.h" #include "ENESMBusInterface_ROGArion.h" #include "RGBController_ENESMBus.h" @@ -37,7 +37,7 @@ void DetectROGArionControllers() ENESMBusController* controller = new ENESMBusController(interface, 0x67, "Asus ROG Strix Arion", DEVICE_TYPE_STORAGE); RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } info = info->next; diff --git a/Controllers/ENESMBusController/XPGSpectrixS40GDetect_Linux.cpp b/Controllers/ENESMBusController/XPGSpectrixS40GDetect_Linux.cpp index 8e1661695..bec9816ad 100644 --- a/Controllers/ENESMBusController/XPGSpectrixS40GDetect_Linux.cpp +++ b/Controllers/ENESMBusController/XPGSpectrixS40GDetect_Linux.cpp @@ -13,7 +13,7 @@ #include #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "ENESMBusController.h" #include "ENESMBusInterface_SpectrixS40G_Linux.h" #include "LogManager.h" @@ -82,7 +82,7 @@ void DetectSpectrixS40GControllers() ENESMBusController* controller = new ENESMBusController(interface, 0x67, "XPG Spectrix S40G", DEVICE_TYPE_STORAGE); RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ENESMBusController/XPGSpectrixS40GDetect_Windows.cpp b/Controllers/ENESMBusController/XPGSpectrixS40GDetect_Windows.cpp index 4a9ef7be3..859a48868 100644 --- a/Controllers/ENESMBusController/XPGSpectrixS40GDetect_Windows.cpp +++ b/Controllers/ENESMBusController/XPGSpectrixS40GDetect_Windows.cpp @@ -11,7 +11,7 @@ #include #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "ENESMBusController.h" #include "ENESMBusInterface_SpectrixS40G_Windows.h" #include "RGBController.h" @@ -116,7 +116,7 @@ void DetectSpectrixS40GControllers() ENESMBusController* controller = new ENESMBusController(interface, 0x67, "XPG Spectrix S40G", DEVICE_TYPE_STORAGE); RGBController_ENESMBus* rgb_controller = new RGBController_ENESMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectSpectrixS40GControllers() */ diff --git a/Controllers/EVGAAmpereGPUController/EVGAAmpereGPUControllerDetect.cpp b/Controllers/EVGAAmpereGPUController/EVGAAmpereGPUControllerDetect.cpp index 40f7c1b08..68108d071 100644 --- a/Controllers/EVGAAmpereGPUController/EVGAAmpereGPUControllerDetect.cpp +++ b/Controllers/EVGAAmpereGPUController/EVGAAmpereGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "EVGAGPUv3Controller.h" #include "LogManager.h" #include "RGBController_EVGAGPUv3.h" @@ -40,7 +40,7 @@ void DetectEVGAAmpereGPUControllers(i2c_smbus_interface* bus, uint8_t address, c { rgb_controller = new RGBController_EVGAGPUv3(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/EVGAGP102GPUController/EVGAGP102GPUControllerDetect.cpp b/Controllers/EVGAGP102GPUController/EVGAGP102GPUControllerDetect.cpp index e0f5da8a2..ff1a6bd79 100644 --- a/Controllers/EVGAGP102GPUController/EVGAGP102GPUControllerDetect.cpp +++ b/Controllers/EVGAGP102GPUController/EVGAGP102GPUControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "EVGAGP102Controller.h" #include "LogManager.h" #include "RGBController_EVGAGP102.h" @@ -54,7 +54,7 @@ void DetectEVGAGP102GPUControllers(i2c_smbus_interface* bus, uint8_t /*address*/ { new_rgbcontroller = new RGBController_EVGAGP102(controllers); - ResourceManager::get()->RegisterRGBController(new_rgbcontroller); + DetectionManager::get()->RegisterRGBController(new_rgbcontroller); } } } /* DetectEVGAGP102GPUControllers() */ diff --git a/Controllers/EVGAPascalGPUController/EVGAPascalGPUControllerDetect.cpp b/Controllers/EVGAPascalGPUController/EVGAPascalGPUControllerDetect.cpp index c5a325f9a..1962b0230 100644 --- a/Controllers/EVGAPascalGPUController/EVGAPascalGPUControllerDetect.cpp +++ b/Controllers/EVGAPascalGPUController/EVGAPascalGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "EVGAGPUv1Controller.h" #include "LogManager.h" #include "RGBController_EVGAGPUv1.h" @@ -34,7 +34,7 @@ void DetectEVGAPascalGPUControllers(i2c_smbus_interface* bus, uint8_t address, c EVGAGPUv1Controller* controller = new EVGAGPUv1Controller(bus, address, name); RGBController_EVGAGPUv1* rgb_controller = new RGBController_EVGAGPUv1(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectEVGAPascalGPUControllers() */ diff --git a/Controllers/EVGASMBusController/EVGASMBusControllerDetect.cpp b/Controllers/EVGASMBusController/EVGASMBusControllerDetect.cpp index f7c29cd5f..119ac682a 100644 --- a/Controllers/EVGASMBusController/EVGASMBusControllerDetect.cpp +++ b/Controllers/EVGASMBusController/EVGASMBusControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "EVGAACX30SMBusController.h" #include "LogManager.h" #include "RGBController_EVGAACX30SMBus.h" @@ -73,7 +73,7 @@ void DetectAcx30SMBusControllers(std::vector &busses) EVGAACX30SMBusController *controller = new EVGAACX30SMBusController(busses[bus], SMBUS_ADDRESS); RGBController_EVGAACX30SMBus *rgb_controller = new RGBController_EVGAACX30SMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } else diff --git a/Controllers/EVGATuringGPUController/EVGATuringGPUControllerDetect.cpp b/Controllers/EVGATuringGPUController/EVGATuringGPUControllerDetect.cpp index aedcb82e1..46d6682b3 100644 --- a/Controllers/EVGATuringGPUController/EVGATuringGPUControllerDetect.cpp +++ b/Controllers/EVGATuringGPUController/EVGATuringGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "EVGAGPUv2Controller.h" #include "RGBController_EVGAGPUv2.h" #include "i2c_smbus.h" @@ -33,7 +33,7 @@ void DetectEVGATuringGPUControllers(i2c_smbus_interface* bus, uint8_t address, c EVGAGPUv2Controller* controller = new EVGAGPUv2Controller(bus, address, name); RGBController_EVGAGPUv2* rgb_controller = new RGBController_EVGAGPUv2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectEVGATuringGPUControllers() */ diff --git a/Controllers/EVGAUSBController/EVGAUSBControllerDetect.cpp b/Controllers/EVGAUSBController/EVGAUSBControllerDetect.cpp index 6281835ea..90bf6e92f 100644 --- a/Controllers/EVGAUSBController/EVGAUSBControllerDetect.cpp +++ b/Controllers/EVGAUSBController/EVGAUSBControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_EVGAKeyboard.h" #include "RGBController_EVGAMouse.h" @@ -40,7 +40,7 @@ void DetectEVGAKeyboardControllers(hid_device_info* info, const std::string& nam EVGAKeyboardController* controller = new EVGAKeyboardController(dev, info->path, info->product_id, name); RGBController_EVGAKeyboard* rgb_controller = new RGBController_EVGAKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -53,7 +53,7 @@ void DetectEVGAMouse(hid_device_info* info, const std::string &name, int connect EVGAMouseController* controller = new EVGAMouseController(dev, info->path, connection_type, name); RGBController_EVGAMouse* rgb_controller = new RGBController_EVGAMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/EVisionKeyboardController/EVisionKeyboardControllerDetect.cpp b/Controllers/EVisionKeyboardController/EVisionKeyboardControllerDetect.cpp index 45f6a93d5..f6428b15e 100644 --- a/Controllers/EVisionKeyboardController/EVisionKeyboardControllerDetect.cpp +++ b/Controllers/EVisionKeyboardController/EVisionKeyboardControllerDetect.cpp @@ -8,11 +8,12 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "EVisionKeyboardController.h" #include "EVisionV2KeyboardController.h" #include "RGBController_EVisionKeyboard.h" #include "RGBController_EVisionV2Keyboard.h" +#include "ResourceManager.h" #include "SettingsManager.h" /*-----------------------------------------------------*\ @@ -55,7 +56,7 @@ void DetectEVisionKeyboards(hid_device_info* info, const std::string& name) EVisionKeyboardController* controller = new EVisionKeyboardController(dev, info->path, name); RGBController_EVisionKeyboard* rgb_controller = new RGBController_EVisionKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -69,17 +70,17 @@ void DetectEVisionV2Keyboards(hid_device_info* info, const std::string& name) EVisionV2KeyboardController* controller = new EVisionV2KeyboardController(dev, info->path, EVISION_V2_KEYBOARD_LAYOUT, name); RGBController_EVisionV2Keyboard* rgb_controller = new RGBController_EVisionV2Keyboard(controller, EVISION_V2_KEYBOARD_PART_KEYBOARD); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); if(!settings.contains("AdditionalZones") || settings["AdditionalZones"] == true) { rgb_controller = new RGBController_EVisionV2Keyboard(controller, EVISION_V2_KEYBOARD_PART_LOGO); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); rgb_controller = new RGBController_EVisionV2Keyboard(controller, EVISION_V2_KEYBOARD_PART_EDGE); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } @@ -94,13 +95,13 @@ void DetectEndorfyKeyboards(hid_device_info* info, const std::string& name) EVisionV2KeyboardController* controller = new EVisionV2KeyboardController(dev, info->path, ENDORFY_KEYBOARD_LAYOUT, name); RGBController_EVisionV2Keyboard* rgb_controller = new RGBController_EVisionV2Keyboard(controller, EVISION_V2_KEYBOARD_PART_KEYBOARD); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); if(!settings.contains("AdditionalZones") || settings["AdditionalZones"] == true) { rgb_controller = new RGBController_EVisionV2Keyboard(controller, ENDORFY_KEYBOARD_PART_EDGE); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/ElgatoKeyLightController/ElgatoKeyLightControllerDetect.cpp b/Controllers/ElgatoKeyLightController/ElgatoKeyLightControllerDetect.cpp index d0d891783..f6394df94 100644 --- a/Controllers/ElgatoKeyLightController/ElgatoKeyLightControllerDetect.cpp +++ b/Controllers/ElgatoKeyLightController/ElgatoKeyLightControllerDetect.cpp @@ -7,8 +7,9 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "ElgatoKeyLightController.h" +#include "ResourceManager.h" #include "RGBController_ElgatoKeyLight.h" #include "SettingsManager.h" @@ -43,7 +44,7 @@ void DetectElgatoKeyLightControllers() ElgatoKeyLightController* controller = new ElgatoKeyLightController(elgato_keylight_ip); RGBController_ElgatoKeyLight* rgb_controller = new RGBController_ElgatoKeyLight(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/ElgatoLightStripController/ElgatoLightStripControllerDetect.cpp b/Controllers/ElgatoLightStripController/ElgatoLightStripControllerDetect.cpp index 2ee89f417..4c68c0386 100644 --- a/Controllers/ElgatoLightStripController/ElgatoLightStripControllerDetect.cpp +++ b/Controllers/ElgatoLightStripController/ElgatoLightStripControllerDetect.cpp @@ -7,8 +7,9 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "ElgatoLightStripController.h" +#include "ResourceManager.h" #include "RGBController_ElgatoLightStrip.h" #include "SettingsManager.h" @@ -41,7 +42,7 @@ void DetectElgatoLightStripControllers() ElgatoLightStripController* controller = new ElgatoLightStripController(elgato_lightstrip_ip); RGBController_ElgatoLightStrip* rgb_controller = new RGBController_ElgatoLightStrip(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/EpomakerController/EpomakerControllerDetect.cpp b/Controllers/EpomakerController/EpomakerControllerDetect.cpp index 4597eca0d..b6aa7a747 100644 --- a/Controllers/EpomakerController/EpomakerControllerDetect.cpp +++ b/Controllers/EpomakerController/EpomakerControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "EpomakerController.h" #include "RGBController_EpomakerController.h" @@ -38,7 +38,7 @@ void DetectEpomakerControllers(hid_device_info* info, const std::string&) EpomakerController* controller = new EpomakerController(dev, info->path); RGBController_EpomakerController* rgb_controller = new RGBController_EpomakerController(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectEpomakerControllers() */ diff --git a/Controllers/EspurnaController/EspurnaControllerDetect.cpp b/Controllers/EspurnaController/EspurnaControllerDetect.cpp index f93c70ba0..99ddb07e4 100644 --- a/Controllers/EspurnaController/EspurnaControllerDetect.cpp +++ b/Controllers/EspurnaController/EspurnaControllerDetect.cpp @@ -9,9 +9,11 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "EspurnaController.h" +#include "ResourceManager.h" #include "RGBController_Espurna.h" +#include "RGBController.h" #include "SettingsManager.h" /******************************************************************************************\ @@ -71,7 +73,7 @@ void DetectEspurnaControllers() RGBController_Espurna* rgb_controller = new RGBController_Espurna(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/FanBusController/FanBusControllerDetect.cpp b/Controllers/FanBusController/FanBusControllerDetect.cpp index bc4e8f775..11a3e8fe8 100644 --- a/Controllers/FanBusController/FanBusControllerDetect.cpp +++ b/Controllers/FanBusController/FanBusControllerDetect.cpp @@ -9,9 +9,10 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "FanBusController.h" #include "RGBController_FanBus.h" +#include "ResourceManager.h" #include "SettingsManager.h" void DetectFanBusControllers() @@ -44,7 +45,7 @@ void DetectFanBusControllers() FanBusController* controller = new FanBusController(new_interface, detected_controllers[controller_idx]); RGBController_FanBus* rgb_controller = new RGBController_FanBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/FaustusController/RGBController_Faustus_Linux.cpp b/Controllers/FaustusController/RGBController_Faustus_Linux.cpp index 3b2f74b05..57aead7d9 100644 --- a/Controllers/FaustusController/RGBController_Faustus_Linux.cpp +++ b/Controllers/FaustusController/RGBController_Faustus_Linux.cpp @@ -10,7 +10,7 @@ #include #include #include "RGBController_Faustus_Linux.h" -#include "Detector.h" +#include "DetectionManager.h" /**------------------------------------------------------------------*\ @name ASUS TUF Keyboard (Faustus) @@ -190,7 +190,7 @@ void DetectFaustusControllers() return; } - ResourceManager::get()->RegisterRGBController(new RGBController_Faustus(base_path)); + DetectionManager::get()->RegisterRGBController(new RGBController_Faustus(base_path)); } /* DetectFaustusControllers() */ REGISTER_DETECTOR("Faustus", DetectFaustusControllers); diff --git a/Controllers/FnaticStreakController/FnaticStreakControllerDetect.cpp b/Controllers/FnaticStreakController/FnaticStreakControllerDetect.cpp index 225bb2a35..586a034c2 100644 --- a/Controllers/FnaticStreakController/FnaticStreakControllerDetect.cpp +++ b/Controllers/FnaticStreakController/FnaticStreakControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "FnaticStreakController.h" #include "RGBController_FnaticStreak.h" @@ -47,7 +47,7 @@ void DetectFnaticStreakKeyboard(hid_device_info* info, const std::string& name) FnaticStreakController* controller = new FnaticStreakController(dev, info, name, kb_type); RGBController_FnaticStreak* rgb_controller = new RGBController_FnaticStreak(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/GaiZongGaiKeyboardController/GaiZhongGaiControllerDetect.cpp b/Controllers/GaiZongGaiKeyboardController/GaiZhongGaiControllerDetect.cpp index 118adae3e..ad7d9c99e 100644 --- a/Controllers/GaiZongGaiKeyboardController/GaiZhongGaiControllerDetect.cpp +++ b/Controllers/GaiZongGaiKeyboardController/GaiZhongGaiControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "GaiZhongGaiController.h" #include "RGBController_GaiZhongGai.h" @@ -31,7 +31,7 @@ void DetectGaiZhongGaiKeyboardControllers(hid_device_info* info, const std::stri GaiZhongGaiKeyboardController* controller = new GaiZhongGaiKeyboardController(dev, info, name); RGBController_GaiZhongGaiKeyboard* rgb_controller = new RGBController_GaiZhongGaiKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectGaiZhongGaiKeyboardControllers() */ diff --git a/Controllers/GainwardGPUController/GainwardGPUControllerDetect.cpp b/Controllers/GainwardGPUController/GainwardGPUControllerDetect.cpp index 59f5e4815..b632dcc85 100644 --- a/Controllers/GainwardGPUController/GainwardGPUControllerDetect.cpp +++ b/Controllers/GainwardGPUController/GainwardGPUControllerDetect.cpp @@ -10,7 +10,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "GainwardGPUv1Controller.h" #include "GainwardGPUv2Controller.h" #include "RGBController_GainwardGPUv1.h" @@ -80,7 +80,7 @@ void DetectGainwardGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, co GainwardGPUv1Controller* controller = new GainwardGPUv1Controller(bus, i2c_addr, name); RGBController_GainwardGPUv1* rgb_controller = new RGBController_GainwardGPUv1(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; @@ -92,7 +92,7 @@ void DetectGainwardGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, co GainwardGPUv2Controller* controller = new GainwardGPUv2Controller(bus, i2c_addr, name); RGBController_GainwardGPUv2* rgb_controller = new RGBController_GainwardGPUv2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; } diff --git a/Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp b/Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp index a78105f55..b10100c9c 100644 --- a/Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp +++ b/Controllers/GalaxGPUController/GalaxGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "GalaxGPUv1Controller.h" #include "GalaxGPUv2Controller.h" #include "RGBController_GalaxGPUv1.h" @@ -92,7 +92,7 @@ void DetectGalaxGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const GalaxGPUv1Controller* controller = new GalaxGPUv1Controller(bus, i2c_addr, name); RGBController_GalaxGPUv1* rgb_controller = new RGBController_GalaxGPUv1(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; @@ -104,7 +104,7 @@ void DetectGalaxGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const GalaxGPUv2Controller* controller = new GalaxGPUv2Controller(bus, i2c_addr, name); RGBController_GalaxGPUv2* rgb_controller = new RGBController_GalaxGPUv2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; } diff --git a/Controllers/GigabyteAorusCPUCoolerController/GigabyteAorusCPUCoolerControllerDetect.cpp b/Controllers/GigabyteAorusCPUCoolerController/GigabyteAorusCPUCoolerControllerDetect.cpp index 0ed7d2853..a610417ae 100644 --- a/Controllers/GigabyteAorusCPUCoolerController/GigabyteAorusCPUCoolerControllerDetect.cpp +++ b/Controllers/GigabyteAorusCPUCoolerController/GigabyteAorusCPUCoolerControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ATC800Controller.h" #include "RGBController_AorusATC800.h" @@ -39,7 +39,7 @@ void DetectGigabyteAorusCPUCoolerControllers(hid_device_info* info, const std::s ATC800Controller* controller = new ATC800Controller(dev, info->path, name); RGBController_AorusATC800* rgb_controller = new RGBController_AorusATC800(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/GigabyteAorusLaptopController/GigabyteAorusLaptopControllerDetect.cpp b/Controllers/GigabyteAorusLaptopController/GigabyteAorusLaptopControllerDetect.cpp index ba6331d9b..0fb74341f 100644 --- a/Controllers/GigabyteAorusLaptopController/GigabyteAorusLaptopControllerDetect.cpp +++ b/Controllers/GigabyteAorusLaptopController/GigabyteAorusLaptopControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "GigabyteAorusLaptopController.h" #include "RGBController_GigabyteAorusLaptop.h" @@ -36,7 +36,7 @@ void DetectGigabyteAorusLaptopControllers(hid_device_info* info, const std::stri GigabyteAorusLaptopController* controller = new GigabyteAorusLaptopController(dev, *info, name); RGBController_GigabyteAorusLaptop* rgb_controller = new RGBController_GigabyteAorusLaptop(controller, dev_type); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/GigabyteAorusMouseController/GigabyteAorusMouseControllerDetect.cpp b/Controllers/GigabyteAorusMouseController/GigabyteAorusMouseControllerDetect.cpp index 8ece0db59..0b5ea7276 100644 --- a/Controllers/GigabyteAorusMouseController/GigabyteAorusMouseControllerDetect.cpp +++ b/Controllers/GigabyteAorusMouseController/GigabyteAorusMouseControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "hidapi.h" #include "GigabyteAorusMouseController.h" #include "RGBController_GigabyteAorusMouse.h" @@ -33,7 +33,7 @@ void DetectGigabyteAorusMouseControllers(hid_device_info* info, const std::strin GigabyteAorusMouseController* controller = new GigabyteAorusMouseController(dev, *info, name); RGBController_GigabyteAorusMouse* rgb_controller = new RGBController_GigabyteAorusMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/GigabyteAorusPCCaseController/GigabyteAorusPCCaseControllerDetect.cpp b/Controllers/GigabyteAorusPCCaseController/GigabyteAorusPCCaseControllerDetect.cpp index ceb7756ee..a3da7dc5c 100644 --- a/Controllers/GigabyteAorusPCCaseController/GigabyteAorusPCCaseControllerDetect.cpp +++ b/Controllers/GigabyteAorusPCCaseController/GigabyteAorusPCCaseControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "GigabyteAorusPCCaseController.h" #include "RGBController_GigabyteAorusPCCase.h" @@ -40,7 +40,7 @@ void DetectGigabyteAorusPCCaseControllers(hid_device_info* info, const std::stri GigabyteAorusPCCaseController* controller = new GigabyteAorusPCCaseController(dev, info->path, name); RGBController_GigabyteAorusPCCase* rgb_controller = new RGBController_GigabyteAorusPCCase(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/GigabyteRGBFusion2BlackwellGPUController/GigabyteRGBFusion2BlackwellGPUControllerDetect.cpp b/Controllers/GigabyteRGBFusion2BlackwellGPUController/GigabyteRGBFusion2BlackwellGPUControllerDetect.cpp index 65b6826dc..62ec85d53 100644 --- a/Controllers/GigabyteRGBFusion2BlackwellGPUController/GigabyteRGBFusion2BlackwellGPUControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2BlackwellGPUController/GigabyteRGBFusion2BlackwellGPUControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "GigabyteRGBFusion2BlackwellGPUController.h" #include "LogManager.h" #include "RGBController_GigabyteRGBFusion2BlackwellGPU.h" @@ -92,7 +92,7 @@ void DetectGigabyteRGBFusion2BlackwellGPUControllers(i2c_smbus_interface* bus, u RGBFusion2BlackwellGPUController* controller = new RGBFusion2BlackwellGPUController(bus, i2c_addr, name); RGBController_RGBFusion2BlackwellGPU* rgb_controller = new RGBController_RGBFusion2BlackwellGPU(controller, led_zones); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectGigabyteRGBFusion2BlackwellGPUControllers() */ diff --git a/Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp b/Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp index aa58aedcc..e081b21e5 100644 --- a/Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2DRAMController/GigabyteRGBFusion2DRAMControllerDetect.cpp @@ -11,7 +11,7 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "GigabyteRGBFusion2DRAMController.h" #include "RGBController_GigabyteRGBFusion2DRAM.h" @@ -81,7 +81,7 @@ void DetectGigabyteRGBFusion2DRAMControllers(std::vector& RGBFusion2DRAMController* controller = new RGBFusion2DRAMController(busses[bus], 0x67); RGBController_RGBFusion2DRAM* rgb_controller = new RGBController_RGBFusion2DRAM(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp b/Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp index 3f5b8476f..aef39d1fd 100644 --- a/Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2GPUController/GigabyteRGBFusion2GPUControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "GigabyteRGBFusion2GPUController.h" #include "LogManager.h" #include "RGBController_GigabyteRGBFusion2GPU.h" @@ -100,7 +100,7 @@ void DetectGigabyteRGBFusion2GPUControllers(i2c_smbus_interface* bus, uint8_t i2 RGBFusion2GPUController* controller = new RGBFusion2GPUController(bus, i2c_addr, name); RGBController_RGBFusion2GPU* rgb_controller = new RGBController_RGBFusion2GPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectGigabyteRGBFusion2GPUControllers() */ diff --git a/Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusControllerDetect.cpp b/Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusControllerDetect.cpp index b66dee258..9011b9504 100644 --- a/Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2SMBusController/GigabyteRGBFusion2SMBusControllerDetect.cpp @@ -12,14 +12,15 @@ #include #include -#include "Detector.h" -#include "GigabyteRGBFusion2SMBusController.h" -#include "LogManager.h" -#include "RGBController_GigabyteRGBFusion2SMBus.h" -#include "SettingsManager.h" -#include "i2c_smbus.h" -#include "pci_ids.h" +#include "DetectionManager.h" #include "dmiinfo.h" +#include "GigabyteRGBFusion2SMBusController.h" +#include "i2c_smbus.h" +#include "LogManager.h" +#include "pci_ids.h" +#include "RGBController_GigabyteRGBFusion2SMBus.h" +#include "ResourceManager.h" +#include "SettingsManager.h" #define DETECTOR_NAME "Gigabyte RGB Fusion 2 SMBus" #define VENDOR_NAME "Gigabyte Technology Co., Ltd." @@ -148,7 +149,7 @@ void DetectGigabyteRGBFusion2SMBusControllers(std::vector& RGBFusion2SMBusController* controller = new RGBFusion2SMBusController(busses[bus], SMBUS_ADDRESS, dmi.getMainboard() ); RGBController_RGBFusion2SMBus* rgb_controller = new RGBController_RGBFusion2SMBus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp index 58eabc21d..ecbd3d645 100644 --- a/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusion2USBController/GigabyteRGBFusion2USBControllerDetect.cpp @@ -11,7 +11,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "GigabyteRGBFusion2USBController.h" #include "RGBController_GigabyteRGBFusion2USB.h" #include "dmiinfo.h" @@ -36,7 +36,7 @@ void DetectGigabyteRGBFusion2USBControllers(hid_device_info* info, const std::st RGBFusion2USBController* controller = new RGBFusion2USBController(dev, info->path, MB_info.getMainboard(), info->product_id); RGBController_RGBFusion2USB* rgb_controller = new RGBController_RGBFusion2USB(controller, DETECTOR_NAME); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/GigabyteRGBFusionController/GigabyteRGBFusionControllerDetect.cpp b/Controllers/GigabyteRGBFusionController/GigabyteRGBFusionControllerDetect.cpp index ac6d23a12..8dd9c9815 100644 --- a/Controllers/GigabyteRGBFusionController/GigabyteRGBFusionControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusionController/GigabyteRGBFusionControllerDetect.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "GigabyteRGBFusionController.h" #include "LogManager.h" #include "RGBController_GigabyteRGBFusion.h" @@ -80,7 +80,7 @@ void DetectGigabyteRGBFusionControllers(std::vector& busse RGBFusionController* controller = new RGBFusionController(busses[bus], SMBUS_ADDRESS); RGBController_RGBFusion* rgb_controller = new RGBController_RGBFusion(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } else diff --git a/Controllers/GigabyteRGBFusionGPUController/GigabyteRGBFusionGPUControllerDetect.cpp b/Controllers/GigabyteRGBFusionGPUController/GigabyteRGBFusionGPUControllerDetect.cpp index a1f09cd3e..e695405d6 100644 --- a/Controllers/GigabyteRGBFusionGPUController/GigabyteRGBFusionGPUControllerDetect.cpp +++ b/Controllers/GigabyteRGBFusionGPUController/GigabyteRGBFusionGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "GigabyteRGBFusionGPUController.h" #include "LogManager.h" #include "RGBController_GigabyteRGBFusionGPU.h" @@ -101,7 +101,7 @@ void DetectGigabyteRGBFusionGPUControllers(i2c_smbus_interface* bus, uint8_t i2c RGBFusionGPUController* controller = new RGBFusionGPUController(bus, i2c_addr, name); RGBController_RGBFusionGPU* rgb_controller = new RGBController_RGBFusionGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectGigabyteRGBFusionGPUControllers() */ diff --git a/Controllers/GigabyteSuperIORGBController/GigabyteSuperIORGBControllerDetect.cpp b/Controllers/GigabyteSuperIORGBController/GigabyteSuperIORGBControllerDetect.cpp index 0f37e989b..7111d2d90 100644 --- a/Controllers/GigabyteSuperIORGBController/GigabyteSuperIORGBControllerDetect.cpp +++ b/Controllers/GigabyteSuperIORGBController/GigabyteSuperIORGBControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "GigabyteSuperIORGBController.h" #include "RGBController_GigabyteSuperIORGB.h" #include "super_io.h" @@ -58,7 +58,7 @@ void DetectGigabyteSuperIORGBControllers() GigabyteSuperIORGBController* controller = new GigabyteSuperIORGBController(sioaddr, "Gigabyte " + board_dmi); RGBController_GigabyteSuperIORGB* rgb_controller = new RGBController_GigabyteSuperIORGB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); break; } } diff --git a/Controllers/GoveeController/GoveeControllerDetect.cpp b/Controllers/GoveeController/GoveeControllerDetect.cpp index 93c182cf4..af8d1e0d9 100644 --- a/Controllers/GoveeController/GoveeControllerDetect.cpp +++ b/Controllers/GoveeController/GoveeControllerDetect.cpp @@ -12,10 +12,11 @@ #include #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "GoveeController.h" #include "RGBController.h" #include "RGBController_Govee.h" +#include "ResourceManager.h" #include "SettingsManager.h" /******************************************************************************************\ @@ -69,7 +70,7 @@ void DetectGoveeControllers() GoveeController* controller = new GoveeController(govee_ip); RGBController_Govee* rgb_controller = new RGBController_Govee(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/HPOmen30LController/HPOmen30LControllerDetect.cpp b/Controllers/HPOmen30LController/HPOmen30LControllerDetect.cpp index f365a55c7..2e87d3b1b 100644 --- a/Controllers/HPOmen30LController/HPOmen30LControllerDetect.cpp +++ b/Controllers/HPOmen30LController/HPOmen30LControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "HPOmen30LController.h" #include "RGBController_HPOmen30L.h" @@ -32,7 +32,7 @@ void DetectHPOmen30LController(hid_device_info* info, const std::string&) HPOmen30LController* controller = new HPOmen30LController(dev, info->path); RGBController_HPOmen30L* rgb_controller = new RGBController_HPOmen30L(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/HYTEKeyboardController/HYTEKeyboardControllerDetect.cpp b/Controllers/HYTEKeyboardController/HYTEKeyboardControllerDetect.cpp index 5944f4eb6..3d053f205 100644 --- a/Controllers/HYTEKeyboardController/HYTEKeyboardControllerDetect.cpp +++ b/Controllers/HYTEKeyboardController/HYTEKeyboardControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "HYTEKeyboardController.h" #include "RGBController_HYTEKeyboard.h" @@ -33,7 +33,7 @@ void DetectHYTEKeyboard(hid_device_info* info, const std::string& name) HYTEKeyboardController* controller = new HYTEKeyboardController(dev, info->path, name); RGBController_HYTEKeyboard* rgb_controller = new RGBController_HYTEKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/HYTEMousematController/HYTEMousematController_FreeBSD_Linux/HYTEMousematControllerDetect_FreeBSD_Linux.cpp b/Controllers/HYTEMousematController/HYTEMousematController_FreeBSD_Linux/HYTEMousematControllerDetect_FreeBSD_Linux.cpp index 04d730168..79d135672 100644 --- a/Controllers/HYTEMousematController/HYTEMousematController_FreeBSD_Linux/HYTEMousematControllerDetect_FreeBSD_Linux.cpp +++ b/Controllers/HYTEMousematController/HYTEMousematController_FreeBSD_Linux/HYTEMousematControllerDetect_FreeBSD_Linux.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_HYTEMousemat.h" /*-----------------------------------------------------*\ @@ -73,7 +73,7 @@ void DetectHYTEMousematControllers() HYTEMousematController * controller = new HYTEMousematController(dev, device_list[device_idx].name); RGBController_HYTEMousemat * rgb_controller = new RGBController_HYTEMousemat(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/HYTEMousematController/HYTEMousematController_Windows_MacOS/HYTEMousematControllerDetect_Windows_MacOS.cpp b/Controllers/HYTEMousematController/HYTEMousematController_Windows_MacOS/HYTEMousematControllerDetect_Windows_MacOS.cpp index 8ab62e955..7c40525b1 100644 --- a/Controllers/HYTEMousematController/HYTEMousematController_Windows_MacOS/HYTEMousematControllerDetect_Windows_MacOS.cpp +++ b/Controllers/HYTEMousematController/HYTEMousematController_Windows_MacOS/HYTEMousematControllerDetect_Windows_MacOS.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "HYTEMousematController_Windows_MacOS.h" #include "RGBController_HYTEMousemat.h" #include "find_usb_serial_port.h" @@ -57,7 +57,7 @@ void DetectHYTEMousematControllers() HYTEMousematController * controller = new HYTEMousematController((char *)ports[i]->c_str(), hyte_mousemat_devices[device_id].name); RGBController_HYTEMousemat * rgb_controller = new RGBController_HYTEMousemat(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/HYTENexusController/HYTENexusControllerDetect.cpp b/Controllers/HYTENexusController/HYTENexusControllerDetect.cpp index 1f8f52187..b29c68699 100644 --- a/Controllers/HYTENexusController/HYTENexusControllerDetect.cpp +++ b/Controllers/HYTENexusController/HYTENexusControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "HYTENexusController.h" #include "RGBController_HYTENexus.h" #include "find_usb_serial_port.h" @@ -53,7 +53,7 @@ void DetectHYTENexusControllers() HYTENexusController * controller = new HYTENexusController((char *)ports[i]->c_str(), hyte_nexus_devices[device_id].pid, hyte_nexus_devices[device_id].name); RGBController_HYTENexus * rgb_controller = new RGBController_HYTENexus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/HoltekController/HoltekControllerDetect.cpp b/Controllers/HoltekController/HoltekControllerDetect.cpp index e8471ecd7..66b555835 100644 --- a/Controllers/HoltekController/HoltekControllerDetect.cpp +++ b/Controllers/HoltekController/HoltekControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "HoltekA070Controller.h" #include "RGBController_HoltekA070.h" #include "HoltekA1FAController.h" @@ -36,7 +36,7 @@ void DetectHoltekControllers(hid_device_info* info, const std::string& name) HoltekA070Controller* controller = new HoltekA070Controller(dev, info->path, name); RGBController_HoltekA070* rgb_controller = new RGBController_HoltekA070(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectHoltekControllers() */ @@ -49,7 +49,7 @@ void DetectHoltekMousemats(hid_device_info *info, const std::string &name) HoltekA1FAController* controller = new HoltekA1FAController(dev, info->path, name); RGBController_HoltekA1FA* rgb_controller = new RGBController_HoltekA1FA(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectHoltekMousemats() */ diff --git a/Controllers/HyperXDRAMController/HyperXDRAMControllerDetect.cpp b/Controllers/HyperXDRAMController/HyperXDRAMControllerDetect.cpp index 263914b62..3a2cc3771 100644 --- a/Controllers/HyperXDRAMController/HyperXDRAMControllerDetect.cpp +++ b/Controllers/HyperXDRAMController/HyperXDRAMControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "HyperXDRAMController.h" #include "LogManager.h" #include "RGBController_HyperXDRAM.h" @@ -115,9 +115,9 @@ void DetectHyperXDRAMControllers(i2c_smbus_interface* bus, std::vectorRegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectHyperXDRAMControllers() */ -REGISTER_I2C_DIMM_DETECTOR("HyperX DRAM", DetectHyperXDRAMControllers, JEDEC_KINGSTON, SPD_DDR4_SDRAM); +REGISTER_I2C_DRAM_DETECTOR("HyperX DRAM", DetectHyperXDRAMControllers, JEDEC_KINGSTON, SPD_DDR4_SDRAM); diff --git a/Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp b/Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp index c7fc8e743..34233a89b 100644 --- a/Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp +++ b/Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "HyperXAlloyEliteController.h" #include "HyperXAlloyElite2Controller.h" #include "HyperXAlloyFPSController.h" @@ -70,7 +70,7 @@ void DetectHyperXAlloyElite(hid_device_info* info, const std::string& name) HyperXAlloyEliteController* controller = new HyperXAlloyEliteController(dev, info->path, name); RGBController_HyperXAlloyElite* rgb_controller = new RGBController_HyperXAlloyElite(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -83,7 +83,7 @@ void DetectHyperXAlloyElite2(hid_device_info* info, const std::string& name) HyperXAlloyElite2Controller* controller = new HyperXAlloyElite2Controller(dev, info->path, name); RGBController_HyperXAlloyElite2* rgb_controller = new RGBController_HyperXAlloyElite2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -96,7 +96,7 @@ void DetectHyperXAlloyFPS(hid_device_info* info, const std::string& name) HyperXAlloyFPSController* controller = new HyperXAlloyFPSController(dev, info->path, name); RGBController_HyperXAlloyFPS* rgb_controller = new RGBController_HyperXAlloyFPS(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -109,7 +109,7 @@ void DetectHyperXAlloyOrigins(hid_device_info* info, const std::string& name) HyperXAlloyOriginsController* controller = new HyperXAlloyOriginsController(dev, info->path, name); RGBController_HyperXAlloyOrigins* rgb_controller = new RGBController_HyperXAlloyOrigins(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -122,7 +122,7 @@ void DetectHyperXAlloyOriginsCore(hid_device_info* info, const std::string& name HyperXAlloyOriginsCoreController* controller = new HyperXAlloyOriginsCoreController(dev, info, name); RGBController_HyperXAlloyOriginsCore* rgb_controller = new RGBController_HyperXAlloyOriginsCore(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -136,7 +136,7 @@ void DetectHyperXAlloyOrigins60and65(hid_device_info* info, const std::string& n AlloyOrigins60and65MappingLayoutType layout = GetAlloyOrigins60and65MappingLayoutType(info->product_id); RGBController_HyperXAlloyOrigins60and65* rgb_controller = new RGBController_HyperXAlloyOrigins60and65(controller, layout); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp b/Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp index b167bf36f..609fb5aac 100644 --- a/Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp +++ b/Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "HyperXMicrophoneController.h" #include "RGBController_HyperXMicrophone.h" #include "hidapi_wrapper.h" @@ -40,7 +40,7 @@ void DetectHyperXMicrophoneControllers(hidapi_wrapper wrapper, hid_device_info* HyperXMicrophoneController* controller = new HyperXMicrophoneController(wrapper, dev, info->path, name); RGBController_HyperXMicrophone *rgb_controller = new RGBController_HyperXMicrophone(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/HyperXMicrophoneV2Controller/HyperXMicrophoneV2ControllerDetect.cpp b/Controllers/HyperXMicrophoneV2Controller/HyperXMicrophoneV2ControllerDetect.cpp index fc775a934..b224ec26d 100644 --- a/Controllers/HyperXMicrophoneV2Controller/HyperXMicrophoneV2ControllerDetect.cpp +++ b/Controllers/HyperXMicrophoneV2Controller/HyperXMicrophoneV2ControllerDetect.cpp @@ -10,7 +10,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "HyperXMicrophoneV2Controller.h" #include "RGBController_HyperXMicrophoneV2.h" @@ -29,7 +29,7 @@ void DetectHyperXMicrophoneV2Controllers(hid_device_info* info, const std::strin HyperXMicrophoneV2Controller* controller = new HyperXMicrophoneV2Controller(dev, info->path, name); RGBController_HyperXMicrophoneV2 *rgb_controller = new RGBController_HyperXMicrophoneV2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp b/Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp index dce02398c..e1d51d030 100644 --- a/Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp +++ b/Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "HyperXPulsefireFPSProController.h" #include "HyperXPulsefireSurgeController.h" #include "HyperXPulsefireDartController.h" @@ -46,7 +46,7 @@ void DetectHyperXPulsefireSurgeControllers(hid_device_info* info, const std::str HyperXPulsefireSurgeController* controller = new HyperXPulsefireSurgeController(dev, info->path, name); RGBController_HyperXPulsefireSurge* rgb_controller = new RGBController_HyperXPulsefireSurge(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectHyperXPulsefireSurgeControllers() */ @@ -59,7 +59,7 @@ void DetectHyperXPulsefireFPSProControllers(hid_device_info* info, const std::st HyperXPulsefireFPSProController* controller = new HyperXPulsefireFPSProController(dev, info->path, name); RGBController_HyperXPulsefireFPSPro* rgb_controller = new RGBController_HyperXPulsefireFPSPro(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectHyperXPulsefireFPSProControllers() */ @@ -72,7 +72,7 @@ void DetectHyperXPulsefireHasteControllers(hid_device_info* info, const std::str HyperXPulsefireHasteController* controller = new HyperXPulsefireHasteController(dev, info->path, name); RGBController_HyperXPulsefireHaste* rgb_controller = new RGBController_HyperXPulsefireHaste(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectHyperXPulsefireFPSProControllers() */ @@ -85,7 +85,7 @@ void DetectHyperXPulsefireDartControllers(hid_device_info* info, const std::stri HyperXPulsefireDartController* controller = new HyperXPulsefireDartController(dev, info->path, name); RGBController_HyperXPulsefireDart* rgb_controller = new RGBController_HyperXPulsefireDart(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectHyperXPulsefireDartControllers() */ @@ -98,7 +98,7 @@ void DetectHyperXPulsefireRaidControllers(hid_device_info* info, const std::stri HyperXPulsefireRaidController* controller = new HyperXPulsefireRaidController(dev, *info, name); RGBController_HyperXPulsefireRaid* rgb_controller = new RGBController_HyperXPulsefireRaid(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectHyperXPulsefireRaidControllers() */ diff --git a/Controllers/HyperXMousematController/HyperXMousematControllerDetect.cpp b/Controllers/HyperXMousematController/HyperXMousematControllerDetect.cpp index c153415a0..9a530a42e 100644 --- a/Controllers/HyperXMousematController/HyperXMousematControllerDetect.cpp +++ b/Controllers/HyperXMousematController/HyperXMousematControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "HyperXMousematController.h" #include "RGBController_HyperXMousemat.h" #include "hidapi_wrapper.h" @@ -44,7 +44,7 @@ void DetectHyperXMousematControllers(hidapi_wrapper wrapper, hid_device_info* in HyperXMousematController* controller = new HyperXMousematController(wrapper, dev, info->path, name); RGBController_HyperXMousemat* rgb_controller = new RGBController_HyperXMousemat(controller, first_zone_leds_count, second_zone_leds_count); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectHyperXMousematControllers() */ diff --git a/Controllers/InstantMouseController/InstantMouseControllerDetect.cpp b/Controllers/InstantMouseController/InstantMouseControllerDetect.cpp index 0ac294dc1..1b887e261 100644 --- a/Controllers/InstantMouseController/InstantMouseControllerDetect.cpp +++ b/Controllers/InstantMouseController/InstantMouseControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "InstantMouseController.h" #include "RGBController_InstantMouse.h" #include "InstantMouseDevices.h" @@ -24,7 +24,7 @@ void DetectInstantMouseControllers(hid_device_info* info, const std::string& nam InstantMouseController* controller = new InstantMouseController(dev, *info, name); RGBController_InstantMouse* rgb_controller = new RGBController_InstantMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/IntelArcA770LEController/IntelArcA770LEControllerDetect.cpp b/Controllers/IntelArcA770LEController/IntelArcA770LEControllerDetect.cpp index 09274add1..9339ae268 100644 --- a/Controllers/IntelArcA770LEController/IntelArcA770LEControllerDetect.cpp +++ b/Controllers/IntelArcA770LEController/IntelArcA770LEControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "IntelArcA770LEController.h" #include "RGBController_IntelArcA770LE.h" @@ -33,7 +33,7 @@ void DetectIntelArcA770LEControllers(hid_device_info* info, const std::string&) IntelArcA770LEController* controller = new IntelArcA770LEController(dev, info->path); RGBController_IntelArcA770LE* rgb_controller = new RGBController_IntelArcA770LE(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/IonicoController/IonicoControllerDetect.cpp b/Controllers/IonicoController/IonicoControllerDetect.cpp index 2a82889c1..3b60cbae9 100644 --- a/Controllers/IonicoController/IonicoControllerDetect.cpp +++ b/Controllers/IonicoController/IonicoControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController.h" #include "hidapi.h" #include "IonicoController.h" @@ -37,7 +37,7 @@ void DetectIonicoControllers(hid_device_info* info, const std::string& name) IonicoController* controller = new IonicoController(dev, *info, info->product_id, name); RGBController_Ionico* rgb_controller = new RGBController_Ionico(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/JGINYUEInternalUSBController/JGINYUEInternalUSBControllerDetect.cpp b/Controllers/JGINYUEInternalUSBController/JGINYUEInternalUSBControllerDetect.cpp index 9338be721..573a1a1fb 100644 --- a/Controllers/JGINYUEInternalUSBController/JGINYUEInternalUSBControllerDetect.cpp +++ b/Controllers/JGINYUEInternalUSBController/JGINYUEInternalUSBControllerDetect.cpp @@ -14,7 +14,7 @@ #include #include "RGBController_JGINYUEInternalUSB.h" #include "JGINYUEInternalUSBController.h" -#include "Detector.h" +#include "DetectionManager.h" /*---------------------------------------------------------*\ | JGINYUE vendor ID | @@ -34,7 +34,7 @@ void DetectJGINYUEInternalUSBController(hid_device_info* info,const std::string& { JGINYUEInternalUSBController* controller =new JGINYUEInternalUSBController(dev,info->path); RGBController_JGINYUEInternalUSB* rgb_controller =new RGBController_JGINYUEInternalUSB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/JGINYUEInternalUSBV2Controller/JGINYUEInternalUSBV2Controller.cpp b/Controllers/JGINYUEInternalUSBV2Controller/JGINYUEInternalUSBV2Controller.cpp index 78e200099..3afda6f10 100644 --- a/Controllers/JGINYUEInternalUSBV2Controller/JGINYUEInternalUSBV2Controller.cpp +++ b/Controllers/JGINYUEInternalUSBV2Controller/JGINYUEInternalUSBV2Controller.cpp @@ -14,8 +14,8 @@ #include #include #include -#include "RGBController.h" #include "ResourceManager.h" +#include "RGBController.h" #include "SettingsManager.h" #include "JGINYUEInternalUSBV2Controller.h" diff --git a/Controllers/JGINYUEInternalUSBV2Controller/JGINYUEInternalUSBV2ControllerDetect.cpp b/Controllers/JGINYUEInternalUSBV2Controller/JGINYUEInternalUSBV2ControllerDetect.cpp index e98234ba8..bc233c053 100644 --- a/Controllers/JGINYUEInternalUSBV2Controller/JGINYUEInternalUSBV2ControllerDetect.cpp +++ b/Controllers/JGINYUEInternalUSBV2Controller/JGINYUEInternalUSBV2ControllerDetect.cpp @@ -20,7 +20,7 @@ #include "RGBController_JGINYUEInternalUSBV2.h" #include "JGINYUEInternalUSBV2Controller.h" #include "RGBController.h" -#include "Detector.h" +#include "DetectionManager.h" #include "dmiinfo.h" #include "LogManager.h" /*---------------------------------------------------------*\ @@ -67,7 +67,7 @@ void DetectJGINYUEInternalUSBV2Controller(hid_device_info* info,const std::strin } JGINYUEInternalUSBV2Controller *controller = new JGINYUEInternalUSBV2Controller(hid_dev, info->path,port); RGBController_JGINYUEInternalUSBV2 *rgb_controller = new RGBController_JGINYUEInternalUSBV2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); LOG_INFO("JGINYUE Internal USB ControllerV2 found"); } } diff --git a/Controllers/KasaSmartController/KasaSmartControllerDetect.cpp b/Controllers/KasaSmartController/KasaSmartControllerDetect.cpp index 5400908cc..311e9843c 100644 --- a/Controllers/KasaSmartController/KasaSmartControllerDetect.cpp +++ b/Controllers/KasaSmartController/KasaSmartControllerDetect.cpp @@ -9,8 +9,9 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "KasaSmartController.h" +#include "ResourceManager.h" #include "RGBController_KasaSmart.h" #include "SettingsManager.h" @@ -50,7 +51,7 @@ void DetectKasaSmartControllers() } RGBController_KasaSmart* rgb_controller = new RGBController_KasaSmart(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/KeychronKeyboardController/KeychronKeyboardControllerDetect.cpp b/Controllers/KeychronKeyboardController/KeychronKeyboardControllerDetect.cpp index 7022dd789..3ad3b221a 100644 --- a/Controllers/KeychronKeyboardController/KeychronKeyboardControllerDetect.cpp +++ b/Controllers/KeychronKeyboardController/KeychronKeyboardControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "KeychronKeyboardController.h" #include "RGBController_KeychronKeyboard.h" @@ -32,7 +32,7 @@ void DetectKeychronKeyboardControllers(hid_device_info* info, const std::string& KeychronKeyboardController* controller = new KeychronKeyboardController(dev, *info, name); RGBController_KeychronKeyboard* rgb_controller = new RGBController_KeychronKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/KingstonFuryDRAMController/KingstonFuryDRAMControllerDetect.cpp b/Controllers/KingstonFuryDRAMController/KingstonFuryDRAMControllerDetect.cpp index 8aa236be1..338b4b734 100644 --- a/Controllers/KingstonFuryDRAMController/KingstonFuryDRAMControllerDetect.cpp +++ b/Controllers/KingstonFuryDRAMController/KingstonFuryDRAMControllerDetect.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "KingstonFuryDRAMController.h" #include "LogManager.h" #include "RGBController_KingstonFuryDRAM.h" @@ -175,7 +175,7 @@ void DetectKingstonFuryDDR4Controllers(i2c_smbus_interface* bus, std::vectorRegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -190,12 +190,12 @@ void DetectKingstonFuryDDR5Controllers(i2c_smbus_interface* bus, std::vectorRegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } -REGISTER_I2C_DIMM_DETECTOR("Kingston Fury DDR4 DRAM", DetectKingstonFuryDDR4Controllers, JEDEC_KINGSTON, SPD_DDR4_SDRAM); -REGISTER_I2C_DIMM_DETECTOR("Kingston Fury DDR4 DRAM", DetectKingstonFuryDDR4Controllers, JEDEC_KINGSTON_2, SPD_DDR4_SDRAM); -REGISTER_I2C_DIMM_DETECTOR("Kingston Fury DDR5 DRAM", DetectKingstonFuryDDR5Controllers, JEDEC_KINGSTON, SPD_DDR5_SDRAM); -REGISTER_I2C_DIMM_DETECTOR("Kingston Fury DDR5 DRAM", DetectKingstonFuryDDR5Controllers, JEDEC_KINGSTON_2, SPD_DDR5_SDRAM); -REGISTER_I2C_DIMM_DETECTOR("Kingston Fury DDR5 DRAM", DetectKingstonFuryDDR5Controllers, JEDEC_KINGSTON_3, SPD_DDR5_SDRAM); +REGISTER_I2C_DRAM_DETECTOR("Kingston Fury DDR4 DRAM", DetectKingstonFuryDDR4Controllers, JEDEC_KINGSTON, SPD_DDR4_SDRAM); +REGISTER_I2C_DRAM_DETECTOR("Kingston Fury DDR4 DRAM", DetectKingstonFuryDDR4Controllers, JEDEC_KINGSTON_2, SPD_DDR4_SDRAM); +REGISTER_I2C_DRAM_DETECTOR("Kingston Fury DDR5 DRAM", DetectKingstonFuryDDR5Controllers, JEDEC_KINGSTON, SPD_DDR5_SDRAM); +REGISTER_I2C_DRAM_DETECTOR("Kingston Fury DDR5 DRAM", DetectKingstonFuryDDR5Controllers, JEDEC_KINGSTON_2, SPD_DDR5_SDRAM); +REGISTER_I2C_DRAM_DETECTOR("Kingston Fury DDR5 DRAM", DetectKingstonFuryDDR5Controllers, JEDEC_KINGSTON_3, SPD_DDR5_SDRAM); diff --git a/Controllers/LEDStripController/LEDStripControllerDetect.cpp b/Controllers/LEDStripController/LEDStripControllerDetect.cpp index 4ece79aad..26721e785 100644 --- a/Controllers/LEDStripController/LEDStripControllerDetect.cpp +++ b/Controllers/LEDStripController/LEDStripControllerDetect.cpp @@ -9,11 +9,12 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LEDStripController.h" +#include "LogManager.h" +#include "ResourceManager.h" #include "RGBController_LEDStrip.h" #include "SettingsManager.h" -#include "LogManager.h" /******************************************************************************************\ * * @@ -126,7 +127,7 @@ void DetectLEDStripControllers() RGBController_LEDStrip* rgb_controller = new RGBController_LEDStrip(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LGMonitorController/LGMonitorControllerDetect.cpp b/Controllers/LGMonitorController/LGMonitorControllerDetect.cpp index a661feae7..619ddc3b0 100644 --- a/Controllers/LGMonitorController/LGMonitorControllerDetect.cpp +++ b/Controllers/LGMonitorController/LGMonitorControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LGMonitorController.h" #include "RGBController_LGMonitor.h" @@ -33,7 +33,7 @@ static void DetectLGMonitorControllers(hid_device_info* info, const std::string& LGMonitorController* controller = new LGMonitorController(dev, *info, name); RGBController_LGMonitor* rgb_controller = new RGBController_LGMonitor(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LIFXController/LIFXControllerDetect.cpp b/Controllers/LIFXController/LIFXControllerDetect.cpp index e2cef44cf..ce2242b15 100644 --- a/Controllers/LIFXController/LIFXControllerDetect.cpp +++ b/Controllers/LIFXController/LIFXControllerDetect.cpp @@ -9,8 +9,9 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LIFXController.h" +#include "ResourceManager.h" #include "RGBController_LIFX.h" #include "SettingsManager.h" @@ -50,7 +51,7 @@ void DetectLIFXControllers() RGBController_LIFX* rgb_controller = new RGBController_LIFX(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/LaviewTechnologyController/LaviewTechnologyDetector.cpp b/Controllers/LaviewTechnologyController/LaviewTechnologyDetector.cpp index 37fe5bd75..78f52e83c 100644 --- a/Controllers/LaviewTechnologyController/LaviewTechnologyDetector.cpp +++ b/Controllers/LaviewTechnologyController/LaviewTechnologyDetector.cpp @@ -11,7 +11,7 @@ #include #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "LaviewTechnologyController.h" #include "RGBController.h" #include "RGBController_LaviewTechnology.h" @@ -38,7 +38,7 @@ static void DetectLaviewTechnologyMouse(hid_device_info* info, const std::string LaviewTechnologyController* controller = new LaviewTechnologyController(dev, info, name); RGBController_LaviewTechnology* rgb_controller = new RGBController_LaviewTechnology(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LegoDimensionsToypadBaseController/LegoDimensionsToypadBaseControllerDetect.cpp b/Controllers/LegoDimensionsToypadBaseController/LegoDimensionsToypadBaseControllerDetect.cpp index adda2f029..d74d50998 100644 --- a/Controllers/LegoDimensionsToypadBaseController/LegoDimensionsToypadBaseControllerDetect.cpp +++ b/Controllers/LegoDimensionsToypadBaseController/LegoDimensionsToypadBaseControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LegoDimensionsToypadBaseController.h" #include "RGBController_LegoDimensionsToypadBase.h" @@ -32,7 +32,7 @@ void DetectLegoDimensionsToypadBaseControllers(hid_device_info* info, const std: LegoDimensionsToypadBaseController* controller = new LegoDimensionsToypadBaseController(dev, *info, name); RGBController_LegoDimensionsToypadBase* rgb_controller = new RGBController_LegoDimensionsToypadBase(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LenovoControllers/Lenovo4ZoneUSBController/Lenovo4ZoneUSBControllerDetect.cpp b/Controllers/LenovoControllers/Lenovo4ZoneUSBController/Lenovo4ZoneUSBControllerDetect.cpp index edb17729c..1272d7520 100644 --- a/Controllers/LenovoControllers/Lenovo4ZoneUSBController/Lenovo4ZoneUSBControllerDetect.cpp +++ b/Controllers/LenovoControllers/Lenovo4ZoneUSBController/Lenovo4ZoneUSBControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "Lenovo4ZoneUSBController.h" #include "LenovoDevices4Zone.h" #include "RGBController_Lenovo4ZoneUSB.h" @@ -36,7 +36,7 @@ void DetectLenovo4ZoneUSBControllers(hid_device_info* info, const std::string& n Lenovo4ZoneUSBController* controller = new Lenovo4ZoneUSBController(dev, info->path, info->product_id, name); RGBController_Lenovo4ZoneUSB* rgb_controller = new RGBController_Lenovo4ZoneUSB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LenovoControllers/LenovoLegionK510Controller/LenovoK510ControllerDetect.cpp b/Controllers/LenovoControllers/LenovoLegionK510Controller/LenovoK510ControllerDetect.cpp index 62ba654b4..ae45193f8 100644 --- a/Controllers/LenovoControllers/LenovoLegionK510Controller/LenovoK510ControllerDetect.cpp +++ b/Controllers/LenovoControllers/LenovoLegionK510Controller/LenovoK510ControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_LenovoK510.h" #include "LenovoK510Controller.h" @@ -31,7 +31,7 @@ void DetectLenovoLegionK510Controllers(hid_device_info* info, const std::string& LenovoK510Controller* controller = new LenovoK510Controller(dev, *info, name); RGBController_LenovoK510* rgb_controller = new RGBController_LenovoK510(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LenovoControllers/LenovoM300Controller/LenovoM300ControllerDetect.cpp b/Controllers/LenovoControllers/LenovoM300Controller/LenovoM300ControllerDetect.cpp index 493d62792..5437ac3d6 100644 --- a/Controllers/LenovoControllers/LenovoM300Controller/LenovoM300ControllerDetect.cpp +++ b/Controllers/LenovoControllers/LenovoM300Controller/LenovoM300ControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_LenovoM300.h" #include "LenovoM300Controller.h" @@ -30,7 +30,7 @@ void DetectLenovoLegionM300Controllers(hid_device_info* info, const std::string& LenovoM300Controller* controller = new LenovoM300Controller(dev, *info, name); RGBController_LenovoM300* rgb_controller = new RGBController_LenovoM300(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LenovoControllers/LenovoUSBControllerDetect.cpp b/Controllers/LenovoControllers/LenovoUSBControllerDetect.cpp index 496f8633b..5c16ff4a8 100644 --- a/Controllers/LenovoControllers/LenovoUSBControllerDetect.cpp +++ b/Controllers/LenovoControllers/LenovoUSBControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "LenovoDevices.h" #include "RGBController_LenovoUSB.h" #include "RGBController_Lenovo_Gen7_8.h" @@ -38,7 +38,7 @@ void DetectLenovoLegionUSBControllers(hid_device_info* info, const std::string& LenovoUSBController* controller = new LenovoUSBController(dev, info->path, info->product_id, name); RGBController_LenovoUSB* rgb_controller = new RGBController_LenovoUSB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -51,7 +51,7 @@ void DetectLenovoLegionUSBControllersGen7And8(hid_device_info* info, const std:: LenovoGen7And8USBController* controller = new LenovoGen7And8USBController(dev, info->path, info->product_id, name); LenovoRGBController_Gen7_8* rgb_controller = new LenovoRGBController_Gen7_8(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LenovoMotherboardController/LenovoMotherboardControllerDetect.cpp b/Controllers/LenovoMotherboardController/LenovoMotherboardControllerDetect.cpp index f4876a90b..db24adb4b 100644 --- a/Controllers/LenovoMotherboardController/LenovoMotherboardControllerDetect.cpp +++ b/Controllers/LenovoMotherboardController/LenovoMotherboardControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LenovoMotherboardController.h" #include "RGBController_LenovoMotherboard.h" #include "dmiinfo.h" @@ -35,7 +35,7 @@ void DetectLenovoMotherboardControllers(hid_device_info* info, const std::string LenovoMotherboardController* controller = new LenovoMotherboardController(dev, *info, name + " " + dmi.getMainboard()); RGBController_LenovoMotherboard* rgb_controller = new RGBController_LenovoMotherboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LexipMouseController/LexipMouseControllerDetect.cpp b/Controllers/LexipMouseController/LexipMouseControllerDetect.cpp index d034aad93..00f0cd93c 100644 --- a/Controllers/LexipMouseController/LexipMouseControllerDetect.cpp +++ b/Controllers/LexipMouseController/LexipMouseControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LexipMouseController.h" #include "RGBController_LexipMouse.h" @@ -32,7 +32,7 @@ void DetectLexipMouseControllers(hid_device_info* info, const std::string& name) LexipMouseController* controller = new LexipMouseController(dev, *info, name); RGBController_LexipMouse* rgb_controller = new RGBController_LexipMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LianLiController/LianLiControllerDetect.cpp b/Controllers/LianLiController/LianLiControllerDetect.cpp index 925b463fe..4d6d189ce 100644 --- a/Controllers/LianLiController/LianLiControllerDetect.cpp +++ b/Controllers/LianLiController/LianLiControllerDetect.cpp @@ -10,7 +10,7 @@ #include #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "ResourceManager.h" /*-----------------------------------------------------*\ @@ -103,7 +103,7 @@ void DetectLianLiUniHub() { LianLiUniHubController* controller = new LianLiUniHubController(device, &descriptor); RGBController_LianLiUniHub* rgb_controller = new RGBController_LianLiUniHub(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -149,7 +149,7 @@ void DetectLianLiUniHub_AL10() { LianLiUniHub_AL10Controller* controller = new LianLiUniHub_AL10Controller(device, &descriptor); RGBController_LianLiUniHub_AL10* rgb_controller = new RGBController_LianLiUniHub_AL10(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -172,7 +172,7 @@ void DetectLianLiUniHubAL(hid_device_info* info, const std::string& name) if(firmwareVersion == "v1.7") { RGBController_LianLiUniHubAL* rgb_controller = new RGBController_LianLiUniHubAL(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else if(firmwareVersion == "v1.0") { @@ -197,7 +197,7 @@ void DetectLianLiUniHubSLV2(hid_device_info* info, const std::string& name) LianLiUniHubSLV2Controller* controller = new LianLiUniHubSLV2Controller(dev, info->path, name); RGBController_LianLiUniHubSLV2* rgb_controller = new RGBController_LianLiUniHubSLV2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectLianLiUniHubSLV2() */ @@ -210,7 +210,7 @@ void DetectLianLiUniHubSLInfinity(hid_device_info* info, const std::string& name LianLiUniHubSLInfinityController* controller = new LianLiUniHubSLInfinityController(dev, info->path, name); RGBController_LianLiUniHubSLInfinity* rgb_controller = new RGBController_LianLiUniHubSLInfinity(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectLianLiUniHubSLInfinity() */ @@ -223,7 +223,7 @@ void DetectLianLiStrimerControllers(hid_device_info* info, const std::string& /* LianLiStrimerLConnectController* controller = new LianLiStrimerLConnectController(dev, info->path); RGBController_LianLiStrimerLConnect* rgb_controller = new RGBController_LianLiStrimerLConnect(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -236,7 +236,7 @@ void DetectLianLiGAIITrinity(hid_device_info* info, const std::string& /*name*/) LianLiGAIITrinityController* controller = new LianLiGAIITrinityController(dev, info->path); RGBController_LianLiGAIITrinity* rgb_controller = new RGBController_LianLiGAIITrinity(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -258,7 +258,7 @@ void DetectLianLiUniversalScreen() LianLiUniversalScreenController* controller = new LianLiUniversalScreenController(dev); RGBController_LianLiUniversalScreen* rgb_controller = new RGBController_LianLiUniversalScreen(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LightSaltController/LightSaltControllerDetect.cpp b/Controllers/LightSaltController/LightSaltControllerDetect.cpp index 7196c3e43..d274a4b2f 100644 --- a/Controllers/LightSaltController/LightSaltControllerDetect.cpp +++ b/Controllers/LightSaltController/LightSaltControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "LightSaltController.h" #include "RGBController_LightSaltKeyboard.h" #include "RGBController_LightSaltKeypad.h" @@ -44,7 +44,7 @@ void DetectLightSaltControllers(hid_device_info* info, const std::string &) if(rgb_controller != nullptr) { - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectLightSaltControllers() */ diff --git a/Controllers/LinuxLEDController/LinuxLEDControllerDetect_Linux.cpp b/Controllers/LinuxLEDController/LinuxLEDControllerDetect_Linux.cpp index 268c3618d..3a3c6052e 100644 --- a/Controllers/LinuxLEDController/LinuxLEDControllerDetect_Linux.cpp +++ b/Controllers/LinuxLEDController/LinuxLEDControllerDetect_Linux.cpp @@ -10,7 +10,8 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" +#include "ResourceManager.h" #include "RGBController_LinuxLED_Linux.h" #include "SettingsManager.h" @@ -77,7 +78,7 @@ void DetectLinuxLEDControllers() RGBController_LinuxLED* rgb_controller = new RGBController_LinuxLED(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/LogitechController/LogitechControllerDetect.cpp b/Controllers/LogitechController/LogitechControllerDetect.cpp index 000bed028..1f374fe28 100644 --- a/Controllers/LogitechController/LogitechControllerDetect.cpp +++ b/Controllers/LogitechController/LogitechControllerDetect.cpp @@ -9,7 +9,7 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "LogitechProtocolCommon.h" #include "LogitechG203LController.h" @@ -155,7 +155,7 @@ void DetectLogitechKeyboardG213(hid_device_info* info, const std::string& name) LogitechG213Controller* controller = new LogitechG213Controller(dev, info->path, name); RGBController_LogitechG213* rgb_controller = new RGBController_LogitechG213(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -197,7 +197,7 @@ void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name) LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604, name); RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -213,7 +213,7 @@ void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name) LogitechG810Controller* controller = new LogitechG810Controller(dev, dev, name); RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } #endif } @@ -256,7 +256,7 @@ void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name) LogitechG910Controller* controller = new LogitechG910Controller(dev_usage_0x0602, dev_usage_0x0604, name); RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -272,7 +272,7 @@ void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name) LogitechG910Controller* controller = new LogitechG910Controller(dev, dev, name); RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } #endif } @@ -315,7 +315,7 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name) LogitechG815Controller* controller = new LogitechG815Controller(dev_usage_0x0602, dev_usage_0x0604, name); RGBController_LogitechG815* rgb_controller = new RGBController_LogitechG815(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -339,7 +339,7 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name) LogitechG815Controller* controller = new LogitechG815Controller(dev, dev, name); RGBController_LogitechG815* rgb_controller = new RGBController_LogitechG815(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } #endif } @@ -354,7 +354,7 @@ void DetectLogitechKeyboardG915(hid_device_info* info, const std::string& name) LogitechG915Controller* controller = new LogitechG915Controller(dev, false, name); RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller, is_tkl); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -368,7 +368,7 @@ void DetectLogitechKeyboardG915Wired(hid_device_info* info, const std::string& n LogitechG915Controller* controller = new LogitechG915Controller(dev, true, name); RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller, is_tkl); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -410,7 +410,7 @@ void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name) LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev_usage_0x0602, dev_usage_0x0604, name); RGBController_LogitechGProKeyboard* rgb_controller = new RGBController_LogitechGProKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -426,7 +426,7 @@ void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name) LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev, dev, name); RGBController_LogitechGProKeyboard* rgb_controller = new RGBController_LogitechGProKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } #endif } @@ -469,7 +469,7 @@ static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::str LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev_usage_1, dev_usage_2, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id, name); RGBController_LogitechGLightsync1zone* rgb_controller = new RGBController_LogitechGLightsync1zone (controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -488,7 +488,7 @@ static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::str LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id, name); RGBController_LogitechGLightsync1zone* rgb_controller = new RGBController_LogitechGLightsync1zone(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } #endif @@ -529,7 +529,7 @@ static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::str LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev_usage_1, dev_usage_2, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id, name); RGBController_LogitechGLightsync* rgb_controller = new RGBController_LogitechGLightsync (controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -547,7 +547,7 @@ static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::str LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id, name); RGBController_LogitechGLightsync* rgb_controller = new RGBController_LogitechGLightsync(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } #endif @@ -567,7 +567,7 @@ void DetectLogitechMouseG203L(hid_device_info* info, const std::string& name) LogitechG203LController* controller = new LogitechG203LController(dev, info->path, name); RGBController_LogitechG203L* rgb_controller = new RGBController_LogitechG203L(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -590,7 +590,7 @@ void DetectLogitechMouseG600(hid_device_info* info, const std::string& name) LogitechG600Controller* controller = new LogitechG600Controller(dev, info->path, name); RGBController_LogitechG600* rgb_controller = new RGBController_LogitechG600(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -614,7 +614,7 @@ void DetectLogitechG560(hid_device_info* info, const std::string& name) LogitechG560Controller* controller = new LogitechG560Controller(dev, info->path, name); RGBController_LogitechG560* rgb_controller = new RGBController_LogitechG560(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -630,7 +630,7 @@ void DetectLogitechG933(hid_device_info* info, const std::string& name) LogitechG933Controller* controller = new LogitechG933Controller(dev, info->path, name); RGBController_LogitechG933* rgb_controller = new RGBController_LogitechG933(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -646,7 +646,7 @@ void DetectLogitechX56(hid_device_info* info, const std::string& name) LogitechX56Controller* controller = new LogitechX56Controller(dev, info->path, name); RGBController_LogitechX56* rgb_controller = new RGBController_LogitechX56(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -726,7 +726,7 @@ void CreateLogitechLightspeedDevice(char *path, usages device_usages, uint8_t de { RGBController_LogitechLightspeed* rgb_controller = new RGBController_LogitechLightspeed(controller); rgb_controller->pid = pid; - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); LOG_DEBUG("Added controller in %i retries", retryCount); } else diff --git a/Controllers/LuxaforController/LuxaforControllerDetect.cpp b/Controllers/LuxaforController/LuxaforControllerDetect.cpp index 8958c292f..b5be53285 100644 --- a/Controllers/LuxaforController/LuxaforControllerDetect.cpp +++ b/Controllers/LuxaforController/LuxaforControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LuxaforController.h" #include "RGBController_Luxafor.h" @@ -32,7 +32,7 @@ void DetectLuxaforControllers(hid_device_info* info, const std::string& name) LuxaforController* controller = new LuxaforController(dev, info->path, name); RGBController_Luxafor* rgb_controller = new RGBController_Luxafor(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/MNTKeyboardController/MNTKeyboardController.h b/Controllers/MNTKeyboardController/MNTKeyboardController.h index 6897aea96..a5d74a871 100644 --- a/Controllers/MNTKeyboardController/MNTKeyboardController.h +++ b/Controllers/MNTKeyboardController/MNTKeyboardController.h @@ -15,7 +15,7 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #define KBD_ROWS 6 diff --git a/Controllers/MNTKeyboardController/MNTKeyboardControllerDetect.cpp b/Controllers/MNTKeyboardController/MNTKeyboardControllerDetect.cpp index a97b275f0..4a2eee2fb 100644 --- a/Controllers/MNTKeyboardController/MNTKeyboardControllerDetect.cpp +++ b/Controllers/MNTKeyboardController/MNTKeyboardControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include #include "MNTReformKeyboardController.h" @@ -31,13 +31,13 @@ void DetectMNTKeyboardControllers(hid_device_info *info, const std::string &name { MNTReformKeyboardController *controller = new MNTReformKeyboardController(dev, info->path); RGBController_MNTReformKeyboard *rgb_controller = new RGBController_MNTReformKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else if(info->product_id == PID_KBD_POCKET_REFORM) { MNTPocketReformKeyboardController *controller = new MNTPocketReformKeyboardController(dev, info->path); RGBController_MNTPocketReformKeyboard *rgb_controller = new RGBController_MNTPocketReformKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp b/Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp index 6ad51afa5..93f862216 100644 --- a/Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp +++ b/Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "MSI3ZoneController.h" #include "RGBController_MSI3Zone.h" @@ -36,7 +36,7 @@ void DetectMSI3ZoneControllers(hid_device_info* info, const std::string&) RGBController_MSI3Zone* rgb_controller = new RGBController_MSI3Zone(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectMSI3ZoneControllers() */ diff --git a/Controllers/MSIGPUController/MSIGPUController/MSIGPUControllerDetect.cpp b/Controllers/MSIGPUController/MSIGPUController/MSIGPUControllerDetect.cpp index 2b30371a6..99c7e1b76 100644 --- a/Controllers/MSIGPUController/MSIGPUController/MSIGPUControllerDetect.cpp +++ b/Controllers/MSIGPUController/MSIGPUController/MSIGPUControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "MSIGPUController.h" #include "RGBController_MSIGPU.h" #include "i2c_amd_gpu.h" @@ -36,7 +36,7 @@ void DetectMSIGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const s MSIGPUController* controller = new MSIGPUController(bus, i2c_addr, name); RGBController_MSIGPU* rgb_controller = new RGBController_MSIGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } /* DetectMSIGPUControllers() */ diff --git a/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2ControllerDetect.cpp b/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2ControllerDetect.cpp index 934692fb3..aa4f86b4b 100644 --- a/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2ControllerDetect.cpp +++ b/Controllers/MSIGPUController/MSIGPUv2Controller/MSIGPUv2ControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "i2c_smbus.h" #include "RGBController_MSIGPUv2.h" @@ -34,7 +34,7 @@ void DetectMSIGPUv2Controllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const MSIGPUv2Controller* controller = new MSIGPUv2Controller(bus, i2c_addr, name); RGBController_MSIGPUv2* rgb_controller = new RGBController_MSIGPUv2(controller, msi_gpu_id); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } /* DetectMSIGPUv2Controllers() */ REGISTER_I2C_PCI_DETECTOR("MSI GeForce RTX 4060 Gaming X", DetectMSIGPUv2Controllers, NVIDIA_VEN, NVIDIA_RTX4060_DEV, MSI_SUB_VEN, MSI_RTX4060_GAMING_X_8G_SUB_DEV, 0x68); diff --git a/Controllers/MSIKeyboardController/MSIKeyboardControllerDetect.cpp b/Controllers/MSIKeyboardController/MSIKeyboardControllerDetect.cpp index 6153c7a7c..9dbc08b2f 100644 --- a/Controllers/MSIKeyboardController/MSIKeyboardControllerDetect.cpp +++ b/Controllers/MSIKeyboardController/MSIKeyboardControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "MSIMysticLightKBController.h" #include "RGBController_MSIMysticLightKB.h" @@ -32,8 +32,8 @@ void DetectMSIKeyboardController { MSIKeyboardController* controller = new MSIKeyboardController(dev, info->path); RGBController_MSIKeyboard* rgb_controller = new RGBController_MSIKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } -REGISTER_HID_DETECTOR_PU("MSI Keyboard MS_1565", DetectMSIKeyboardController, MSI_USB_VID, 0x1601, 0x00FF, 0x01); \ No newline at end of file +REGISTER_HID_DETECTOR_PU("MSI Keyboard MS_1565", DetectMSIKeyboardController, MSI_USB_VID, 0x1601, 0x00FF, 0x01); diff --git a/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp b/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp index d9685bc72..6daefc1d4 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "MSIMysticLight64Controller.h" #include "MSIMysticLight112Controller.h" #include "MSIMysticLight162Controller.h" @@ -62,21 +62,21 @@ void DetectMSIMysticLightControllers MSIMysticLight185Controller* controller = new MSIMysticLight185Controller(dev, info->path, info->product_id, dmi_name); RGBController_MSIMysticLight185* rgb_controller = new RGBController_MSIMysticLight185(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else if((packet_length >= sizeof(FeaturePacket_162)) && (packet_length <= (sizeof(FeaturePacket_162) + 1))) { MSIMysticLight162Controller* controller = new MSIMysticLight162Controller(dev, info->path, info->product_id, dmi_name); RGBController_MSIMysticLight162* rgb_controller = new RGBController_MSIMysticLight162(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else if((packet_length >= sizeof(FeaturePacket_112)) && (packet_length <= (sizeof(FeaturePacket_112) + 1))) { MSIMysticLight112Controller* controller = new MSIMysticLight112Controller(dev, info->path, dmi_name); RGBController_MSIMysticLight112* rgb_controller = new RGBController_MSIMysticLight112(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else // no supported length returned { @@ -104,7 +104,7 @@ void DetectMSIMysticLightControllers { MSIMysticLight761Controller* controller = new MSIMysticLight761Controller(dev, (const char *) info->path, dmi_name); RGBController_MSIMysticLight761* rgb_controller = new RGBController_MSIMysticLight761(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } catch(const std::runtime_error& e) { @@ -142,7 +142,7 @@ void DetectMSIMysticLight64Controllers MSIMysticLight64Controller* controller = new MSIMysticLight64Controller(dev, info->path); RGBController_MSIMysticLight64* rgb_controller = new RGBController_MSIMysticLight64(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/MSIOptixController/MSIOptixControllerDetect.cpp b/Controllers/MSIOptixController/MSIOptixControllerDetect.cpp index 27641f2f7..dd93d384f 100644 --- a/Controllers/MSIOptixController/MSIOptixControllerDetect.cpp +++ b/Controllers/MSIOptixController/MSIOptixControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "MSIOptixController.h" #include "RGBController_MSIOptix.h" @@ -32,7 +32,7 @@ void DetectMSIOptixControllers(hid_device_info* info, const std::string& name) MSIOptixController* controller = new MSIOptixController(dev, *info, name); RGBController_MSIOptix* rgb_controller = new RGBController_MSIOptix(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/MSIRGBController/MSIRGBControllerDetect.cpp b/Controllers/MSIRGBController/MSIRGBControllerDetect.cpp index e5844a3f9..755ba1774 100644 --- a/Controllers/MSIRGBController/MSIRGBControllerDetect.cpp +++ b/Controllers/MSIRGBController/MSIRGBControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "MSIRGBController.h" #include "RGBController_MSIRGB.h" #include "super_io.h" @@ -117,7 +117,7 @@ void DetectMSIRGBControllers() MSIRGBController* controller = new MSIRGBController(sioaddr, compatible_devices[i].invert, "MSI " + board_dmi); RGBController_MSIRGB* rgb_controller = new RGBController_MSIRGB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); break; } } diff --git a/Controllers/MSIVigorController/MSIVigorControllerDetect.cpp b/Controllers/MSIVigorController/MSIVigorControllerDetect.cpp index ba401f5bb..5584af065 100644 --- a/Controllers/MSIVigorController/MSIVigorControllerDetect.cpp +++ b/Controllers/MSIVigorController/MSIVigorControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "MSIVigorGK30Controller.h" #include "RGBController_MSIVigorGK30.h" @@ -32,7 +32,7 @@ void DetectMSIVigorGK30Controllers(hid_device_info* info, const std::string& nam MSIVigorGK30Controller* controller = new MSIVigorGK30Controller(dev, *info, name); RGBController_MSIVigorGK30* rgb_controller = new RGBController_MSIVigorGK30(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/MadCatzCyborgController/MadCatzCyborgControllerDetect.cpp b/Controllers/MadCatzCyborgController/MadCatzCyborgControllerDetect.cpp index ead80b47f..4ed04d116 100644 --- a/Controllers/MadCatzCyborgController/MadCatzCyborgControllerDetect.cpp +++ b/Controllers/MadCatzCyborgController/MadCatzCyborgControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "MadCatzCyborgController.h" #include "RGBController_MadCatzCyborg.h" #include @@ -29,15 +29,15 @@ void DetectMadCatzCyborgControllers(hid_device_info* info, const std::string& /*name*/) { hid_device* dev = hid_open_path(info->path); - + if(dev) { MadCatzCyborgController* controller = new MadCatzCyborgController(dev, info->path); controller->Initialize(); - + RGBController_MadCatzCyborg* rgb_controller = new RGBController_MadCatzCyborg(controller); - - ResourceManager::get()->RegisterRGBController(rgb_controller); + + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/MintakaKeyboardController/MintakaKeyboardControllerDetect.cpp b/Controllers/MintakaKeyboardController/MintakaKeyboardControllerDetect.cpp index 25d53b489..f4eb38453 100644 --- a/Controllers/MintakaKeyboardController/MintakaKeyboardControllerDetect.cpp +++ b/Controllers/MintakaKeyboardController/MintakaKeyboardControllerDetect.cpp @@ -9,7 +9,7 @@ | This file is part of the OpenRGB project | | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "MintakaKeyboardController.h" #include "RGBController_MintakaKeyboard.h" @@ -32,7 +32,7 @@ void DetectMintakaKeyboardControllers(hid_device_info* info, const std::string& MintakaKeyboardController* controller = new MintakaKeyboardController(dev, *info, name); RGBController_MintakaKeyboard* rgb_controller = new RGBController_MintakaKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/MountainKeyboardController/MountainKeyboardControllerDetect.cpp b/Controllers/MountainKeyboardController/MountainKeyboardControllerDetect.cpp index 28e860c80..d129430b4 100644 --- a/Controllers/MountainKeyboardController/MountainKeyboardControllerDetect.cpp +++ b/Controllers/MountainKeyboardController/MountainKeyboardControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "MountainKeyboardController.h" #include "RGBController_MountainKeyboard.h" #include "Mountain60KeyboardController.h" @@ -47,7 +47,7 @@ void DetectMountain60KeyboardControllers(hid_device_info* info, const std::strin Mountain60KeyboardController* controller = new Mountain60KeyboardController(dev, info->path, name); RGBController_Mountain60Keyboard* rgb_controller = new RGBController_Mountain60Keyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -60,7 +60,7 @@ void DetectMountainKeyboardControllers(hid_device_info* info, const std::string& MountainKeyboardController* controller = new MountainKeyboardController(dev, info->path, name); RGBController_MountainKeyboard* rgb_controller = new RGBController_MountainKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/N5312AController/N5312AControllerDetect.cpp b/Controllers/N5312AController/N5312AControllerDetect.cpp index d4ad93ae6..6a84fb7d4 100644 --- a/Controllers/N5312AController/N5312AControllerDetect.cpp +++ b/Controllers/N5312AController/N5312AControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "N5312AController.h" #include "RGBController_N5312A.h" @@ -32,7 +32,7 @@ void DetectN5312AControllers(hid_device_info* info, const std::string& name) N5312AController* controller = new N5312AController(dev, *info, name); RGBController_N5312A* rgb_controller = new RGBController_N5312A(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect_Windows_Linux.cpp b/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect_Windows_Linux.cpp index 25847cf21..5a0540b89 100644 --- a/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect_Windows_Linux.cpp +++ b/Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect_Windows_Linux.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "RGBController_NVIDIAIllumination_Windows_Linux.h" #include "pci_ids.h" @@ -119,7 +119,7 @@ void DetectNVIDIAIllumGPUs() NVIDIAIlluminationV1Controller* controller = new NVIDIAIlluminationV1Controller(new_nvapi, device_list[dev_idx].treats_rgbw_as_rgb, device_list[dev_idx].name); RGBController_NVIDIAIlluminationV1* rgb_controller = new RGBController_NVIDIAIlluminationV1(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; } diff --git a/Controllers/NZXTHue1Controller/NZXTHue1ControllerDetect.cpp b/Controllers/NZXTHue1Controller/NZXTHue1ControllerDetect.cpp index 00a2bcdac..de94c4dd2 100644 --- a/Controllers/NZXTHue1Controller/NZXTHue1ControllerDetect.cpp +++ b/Controllers/NZXTHue1Controller/NZXTHue1ControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "NZXTHue1Controller.h" #include "RGBController_NZXTHue1.h" @@ -37,7 +37,7 @@ void DetectNZXTHue1Controllers(hid_device_info* info, const std::string& name) NZXTHue1Controller* controller = new NZXTHue1Controller(dev, 3, info->path, name); RGBController_NZXTHue1* rgb_controller = new RGBController_NZXTHue1(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectNZXTHue1Controllers() */ diff --git a/Controllers/NZXTHue2Controller/NZXTHue2ControllerDetect.cpp b/Controllers/NZXTHue2Controller/NZXTHue2ControllerDetect.cpp index f546efe4f..f326432e5 100644 --- a/Controllers/NZXTHue2Controller/NZXTHue2ControllerDetect.cpp +++ b/Controllers/NZXTHue2Controller/NZXTHue2ControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "NZXTHue2Controller.h" #include "RGBController_NZXTHue2.h" @@ -47,7 +47,7 @@ static void spawn_hue(hid_device_info* info, const std::string& name, int rgb_ch NZXTHue2Controller* controller = new NZXTHue2Controller(dev, rgb_channels, fan_channels, info->path, name); RGBController_NZXTHue2* rgb_controller = new RGBController_NZXTHue2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); LOG_TRACE("[NZXTHue2Controller] NZXT Controller setup: %s", info->path); } else diff --git a/Controllers/NZXTHuePlusController/NZXTHuePlusControllerDetect.cpp b/Controllers/NZXTHuePlusController/NZXTHuePlusControllerDetect.cpp index 9fd79b797..b12643f89 100644 --- a/Controllers/NZXTHuePlusController/NZXTHuePlusControllerDetect.cpp +++ b/Controllers/NZXTHuePlusController/NZXTHuePlusControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "NZXTHuePlusController.h" #include "RGBController_NZXTHuePlus.h" #include "find_usb_serial_port.h" @@ -38,7 +38,7 @@ void DetectNZXTHuePlusControllers() controller->Initialize((char *)ports[i]->c_str()); RGBController_HuePlus* rgb_controller = new RGBController_HuePlus(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectHuePlusControllers() */ diff --git a/Controllers/NZXTKrakenController/NZXTKrakenControllerDetect.cpp b/Controllers/NZXTKrakenController/NZXTKrakenControllerDetect.cpp index 35a946e4d..95c881901 100644 --- a/Controllers/NZXTKrakenController/NZXTKrakenControllerDetect.cpp +++ b/Controllers/NZXTKrakenController/NZXTKrakenControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "NZXTKrakenController.h" #include "RGBController_NZXTKraken.h" @@ -35,7 +35,7 @@ void DetectNZXTKrakenControllers(hid_device_info* info, const std::string& name) NZXTKrakenController* controller = new NZXTKrakenController(dev, info->path, name); RGBController_NZXTKraken* rgb_controller = new RGBController_NZXTKraken(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectNZXTKrakenControllers() */ diff --git a/Controllers/NZXTMouseController/NZXTMouseControllerDetect.cpp b/Controllers/NZXTMouseController/NZXTMouseControllerDetect.cpp index e84dcfe77..eb74c3055 100644 --- a/Controllers/NZXTMouseController/NZXTMouseControllerDetect.cpp +++ b/Controllers/NZXTMouseController/NZXTMouseControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "NZXTMouseController.h" #include "RGBController_NZXTMouse.h" @@ -37,7 +37,7 @@ static void DetectNZXTMouseControllers(hid_device_info* info, const std::string& NZXTMouseController* controller = new NZXTMouseController(dev, info->path, name); RGBController_NZXTMouse* rgb_controller = new RGBController_NZXTMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/NanoleafController/NanoleafControllerDetect.cpp b/Controllers/NanoleafController/NanoleafControllerDetect.cpp index 58a46fb2e..2a55f5468 100644 --- a/Controllers/NanoleafController/NanoleafControllerDetect.cpp +++ b/Controllers/NanoleafController/NanoleafControllerDetect.cpp @@ -9,10 +9,11 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" +#include "LogManager.h" +#include "ResourceManager.h" #include "RGBController_Nanoleaf.h" #include "SettingsManager.h" -#include "LogManager.h" /*----------------------------------------------------------------------------------------*\ | | @@ -37,7 +38,7 @@ void DetectNanoleafControllers() try { RGBController_Nanoleaf* rgb_controller = new RGBController_Nanoleaf(device["ip"], device["port"], device["auth_token"]); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } catch(...) { diff --git a/Controllers/NanoleafController/RGBController_Nanoleaf.cpp b/Controllers/NanoleafController/RGBController_Nanoleaf.cpp index e94cb34c5..82152402a 100644 --- a/Controllers/NanoleafController/RGBController_Nanoleaf.cpp +++ b/Controllers/NanoleafController/RGBController_Nanoleaf.cpp @@ -9,10 +9,10 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "RGBController_Nanoleaf.h" -#include "ResourceManager.h" -#include "LogManager.h" #include +#include "LogManager.h" +#include "ResourceManager.h" +#include "RGBController_Nanoleaf.h" using json = nlohmann::json; diff --git a/Controllers/NollieController/NollieControllerDetect.cpp b/Controllers/NollieController/NollieControllerDetect.cpp index bee11323b..199110a87 100644 --- a/Controllers/NollieController/NollieControllerDetect.cpp +++ b/Controllers/NollieController/NollieControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "NollieController.h" #include "RGBController_Nollie.h" @@ -28,7 +28,7 @@ void DetectNollieControllers(hid_device_info* info, const std::string& name) NollieController* controller = new NollieController(dev, info->path, info->vendor_id, info->product_id, name); RGBController_Nollie* rgb_controller = new RGBController_Nollie(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/NvidiaESAController/NvidiaESAControllerDetect.cpp b/Controllers/NvidiaESAController/NvidiaESAControllerDetect.cpp index b44088a65..383306c44 100644 --- a/Controllers/NvidiaESAController/NvidiaESAControllerDetect.cpp +++ b/Controllers/NvidiaESAController/NvidiaESAControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "NvidiaESAController.h" #include "RGBController_NvidiaESA.h" @@ -32,7 +32,7 @@ void DetectNvidiaESAControllers(hid_device_info* info, const std::string& name) NvidiaESAController* controller = new NvidiaESAController(dev, *info, name); RGBController_NvidiaESA* rgb_controller = new RGBController_NvidiaESA(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/OKSController/OKSKeyboardControllerDetect.cpp b/Controllers/OKSController/OKSKeyboardControllerDetect.cpp index 8f7aca149..d60cbc3d3 100644 --- a/Controllers/OKSController/OKSKeyboardControllerDetect.cpp +++ b/Controllers/OKSController/OKSKeyboardControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "OKSKeyboardController.h" #include "RGBController_OKSKeyboard.h" @@ -30,7 +30,7 @@ void DetectOKSKeyboardControllers(hid_device_info* info, const std::string& name OKSKeyboardController* controller = new OKSKeyboardController(dev, info->path, info->product_id, name); RGBController_OKSKeyboard* rgb_controller = new RGBController_OKSKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectOKSKeyboardControllers() */ diff --git a/Controllers/PNYARGBEpicXGPUController/PNYARGBEpicXGPUControllerDetect.cpp b/Controllers/PNYARGBEpicXGPUController/PNYARGBEpicXGPUControllerDetect.cpp index 009dbf64a..a6a60e066 100644 --- a/Controllers/PNYARGBEpicXGPUController/PNYARGBEpicXGPUControllerDetect.cpp +++ b/Controllers/PNYARGBEpicXGPUController/PNYARGBEpicXGPUControllerDetect.cpp @@ -10,7 +10,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "PNYARGBEpicXGPUController.h" #include "RGBController_PNYARGBEpicXGPU.h" @@ -31,7 +31,7 @@ void DetectPNYARGBEpicXGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr PNYARGBEpicXGPUController* controller = new PNYARGBEpicXGPUController(bus, i2c_addr, name); RGBController_PNYARGBEpicXGPU* rgb_controller = new RGBController_PNYARGBEpicXGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } /* DetectPNYARGBEpicXGPUControllers() */ REGISTER_I2C_PCI_DETECTOR("PNY GeForce RTX 5070Ti ARGB Epic-X OC", DetectPNYARGBEpicXGPUControllers, NVIDIA_VEN, NVIDIA_RTX5070TI_DEV, PNY_SUB_VEN, PNY_RTX_5070TI_ARGB_EPIC_X_OC_SUB_DEV, 0x60); diff --git a/Controllers/PNYGPUController/PNYGPUControllerDetect.cpp b/Controllers/PNYGPUController/PNYGPUControllerDetect.cpp index 2d20e3d96..813f00226 100644 --- a/Controllers/PNYGPUController/PNYGPUControllerDetect.cpp +++ b/Controllers/PNYGPUController/PNYGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "PNYGPUController.h" #include "RGBController_PNYGPU.h" #include "i2c_smbus.h" @@ -36,7 +36,7 @@ void DetectPNYGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const s PNYGPUController* controller = new PNYGPUController(bus, i2c_addr, name); RGBController_PNYGPU* rgb_controller = new RGBController_PNYGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } /* DetectPNYGPUControllers() */ REGISTER_I2C_PCI_DETECTOR("PNY GeForce RTX 2060 XLR8 OC EDITION", DetectPNYGPUControllers, NVIDIA_VEN, NVIDIA_RTX2060_TU104_DEV, PNY_SUB_VEN, PNY_RTX_2060_XLR8_OC_SUB_DEV, 0x49); diff --git a/Controllers/PNYLovelaceGPUController/PNYLovelaceGPUControllerDetect.cpp b/Controllers/PNYLovelaceGPUController/PNYLovelaceGPUControllerDetect.cpp index 1469c21f5..91961c579 100644 --- a/Controllers/PNYLovelaceGPUController/PNYLovelaceGPUControllerDetect.cpp +++ b/Controllers/PNYLovelaceGPUController/PNYLovelaceGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "PNYLovelaceGPUController.h" #include "RGBController_PNYLovelaceGPU.h" #include "i2c_smbus.h" @@ -34,7 +34,7 @@ void DetectPNYLovelaceGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, PNYLovelaceGPUController* controller = new PNYLovelaceGPUController(bus, i2c_addr, name); RGBController_PNYLovelaceGPU* rgb_controller = new RGBController_PNYLovelaceGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } /* DetectPNYLovelaceGPUControllers() */ REGISTER_I2C_PCI_DETECTOR("PNY GeForce RTX 4070 Ti XLR8 VERTO Epic-X", DetectPNYLovelaceGPUControllers, NVIDIA_VEN, NVIDIA_RTX4070TI_DEV, PNY_SUB_VEN, PNY_RTX_4070TI_XLR8_VERTO_EPIC_X_SUB_DEV, 0x60); diff --git a/Controllers/PalitGPUController/PalitGPUControllerDetect.cpp b/Controllers/PalitGPUController/PalitGPUControllerDetect.cpp index d6086b786..189127bec 100644 --- a/Controllers/PalitGPUController/PalitGPUControllerDetect.cpp +++ b/Controllers/PalitGPUController/PalitGPUControllerDetect.cpp @@ -11,7 +11,7 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "PalitGPUController.h" #include "RGBController_PalitGPU.h" #include "i2c_smbus.h" @@ -54,7 +54,7 @@ void DetectPalitGPUControllers(i2c_smbus_interface* bus, uint8_t i2c_addr, const PalitGPUController* controller = new PalitGPUController(bus, i2c_addr, name); RGBController_PalitGPU* rgb_controller = new RGBController_PalitGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } /* DetectPalitGPUControllers() */ REGISTER_I2C_PCI_DETECTOR("Palit GeForce GTX 1060", DetectPalitGPUControllers, NVIDIA_VEN, NVIDIA_GTX1060_DEV, NVIDIA_SUB_VEN, NVIDIA_GTX1060_DEV, 0x08); diff --git a/Controllers/PatriotViperController/PatriotViperControllerDetect.cpp b/Controllers/PatriotViperController/PatriotViperControllerDetect.cpp index 0c0d4edea..2748187f7 100644 --- a/Controllers/PatriotViperController/PatriotViperControllerDetect.cpp +++ b/Controllers/PatriotViperController/PatriotViperControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "PatriotViperController.h" #include "LogManager.h" #include "RGBController_PatriotViper.h" @@ -86,11 +86,11 @@ void DetectPatriotViperControllers(i2c_smbus_interface* bus, std::vectorRegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectPatriotViperControllers() */ -REGISTER_I2C_DIMM_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperControllers, JEDEC_PATRIOT, SPD_DDR4_SDRAM); +REGISTER_I2C_DRAM_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperControllers, JEDEC_PATRIOT, SPD_DDR4_SDRAM); diff --git a/Controllers/PatriotViperMouseController/PatriotViperMouseControllerDetect.cpp b/Controllers/PatriotViperMouseController/PatriotViperMouseControllerDetect.cpp index 5d75ec13e..ba5af63c2 100644 --- a/Controllers/PatriotViperMouseController/PatriotViperMouseControllerDetect.cpp +++ b/Controllers/PatriotViperMouseController/PatriotViperMouseControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "PatriotViperMouseController.h" #include "RGBController_PatriotViperMouse.h" @@ -31,7 +31,7 @@ void DetectPatriotViperMouseControllers(hid_device_info* info, const std::string PatriotViperMouseController* controller = new PatriotViperMouseController(dev, info->path, name); RGBController_PatriotViperMouse* rgb_controller = new RGBController_PatriotViperMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/PatriotViperSteelController/PatriotViperSteelControllerDetect.cpp b/Controllers/PatriotViperSteelController/PatriotViperSteelControllerDetect.cpp index 7f3d32126..2acde3447 100644 --- a/Controllers/PatriotViperSteelController/PatriotViperSteelControllerDetect.cpp +++ b/Controllers/PatriotViperSteelController/PatriotViperSteelControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "PatriotViperSteelController.h" #include "LogManager.h" #include "RGBController_PatriotViperSteel.h" @@ -84,11 +84,11 @@ void DetectPatriotViperSteelControllers(i2c_smbus_interface* bus, std::vectorRegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectPatriotViperSteelControllers() */ -REGISTER_I2C_DIMM_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperSteelControllers, 0xFF7E, SPD_DDR4_SDRAM); +REGISTER_I2C_DRAM_DETECTOR(PATRIOT_CONTROLLER_NAME, DetectPatriotViperSteelControllers, 0xFF7E, SPD_DDR4_SDRAM); diff --git a/Controllers/PhilipsHueController/PhilipsHueControllerDetect.cpp b/Controllers/PhilipsHueController/PhilipsHueControllerDetect.cpp index 4bdba3c0b..dd067cbc6 100644 --- a/Controllers/PhilipsHueController/PhilipsHueControllerDetect.cpp +++ b/Controllers/PhilipsHueController/PhilipsHueControllerDetect.cpp @@ -18,10 +18,11 @@ #include "LinHttpHandler.h" #endif -#include "Detector.h" +#include "DetectionManager.h" #include "LogManager.h" #include "PhilipsHueController.h" #include "PhilipsHueEntertainmentController.h" +#include "ResourceManager.h" #include "RGBController_PhilipsHue.h" #include "RGBController_PhilipsHueEntertainment.h" #include "PhilipsHueSettingsHandler.h" @@ -185,7 +186,7 @@ void DetectPhilipsHueControllers() PhilipsHueEntertainmentController* controller = new PhilipsHueEntertainmentController(bridge, groups[group_idx]); RGBController_PhilipsHueEntertainment* rgb_controller = new RGBController_PhilipsHueEntertainment(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -228,7 +229,7 @@ void DetectPhilipsHueControllers() PhilipsHueController* controller = new PhilipsHueController(lights[light_idx], bridge.getBridgeIP()); RGBController_PhilipsHue* rgb_controller = new RGBController_PhilipsHue(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/PhilipsHueController/RGBController_PhilipsHueEntertainment.cpp b/Controllers/PhilipsHueController/RGBController_PhilipsHueEntertainment.cpp index ca923a78e..51624c2ef 100644 --- a/Controllers/PhilipsHueController/RGBController_PhilipsHueEntertainment.cpp +++ b/Controllers/PhilipsHueController/RGBController_PhilipsHueEntertainment.cpp @@ -9,8 +9,8 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "RGBController_PhilipsHueEntertainment.h" #include "ResourceManager.h" +#include "RGBController_PhilipsHueEntertainment.h" using namespace std::chrono_literals; diff --git a/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp b/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp index 11c5b7ef8..97a7b40c7 100644 --- a/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp +++ b/Controllers/PhilipsWizController/PhilipsWizControllerDetect.cpp @@ -9,8 +9,9 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "PhilipsWizController.h" +#include "ResourceManager.h" #include "RGBController_PhilipsWiz.h" #include "SettingsManager.h" @@ -63,7 +64,7 @@ void DetectPhilipsWizControllers() PhilipsWizController* controller = new PhilipsWizController(wiz_ip, wiz_cool, wiz_warm, wiz_white_strategy); RGBController_PhilipsWiz* rgb_controller = new RGBController_PhilipsWiz(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/PowerColorGPUController/PowerColorGPUControllerDetect.cpp b/Controllers/PowerColorGPUController/PowerColorGPUControllerDetect.cpp index 2650e0d59..820074338 100644 --- a/Controllers/PowerColorGPUController/PowerColorGPUControllerDetect.cpp +++ b/Controllers/PowerColorGPUController/PowerColorGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "pci_ids.h" #include "i2c_amd_gpu.h" #include "PowerColorRedDevilV1Controller/RGBController_PowerColorRedDevilV1.h" @@ -40,7 +40,7 @@ void DetectPowerColorRedDevilGPUControllersV1(i2c_smbus_interface* bus, uint8_t PowerColorRedDevilV1Controller* controller = new PowerColorRedDevilV1Controller(bus, i2c_addr, name); RGBController_PowerColorRedDevilV1* rgb_controller = new RGBController_PowerColorRedDevilV1(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -59,7 +59,7 @@ void DetectPowerColorRedDevilGPUControllersV2(i2c_smbus_interface* bus, uint8_t PowerColorRedDevilV2Controller* controller = new PowerColorRedDevilV2Controller(bus, i2c_addr, name); RGBController_PowerColorRedDevilV2* rgb_controller = new RGBController_PowerColorRedDevilV2(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBBaseController.cpp b/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBBaseController.cpp index 3a9e43ac3..60d01c203 100644 --- a/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBBaseController.cpp +++ b/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBBaseController.cpp @@ -10,9 +10,10 @@ \*---------------------------------------------------------*/ #include "LogManager.h" +#include "QMKOpenRGBBaseController.h" +#include "ResourceManager.h" #include "RGBControllerKeyNames.h" #include "SettingsManager.h" -#include "QMKOpenRGBBaseController.h" using namespace std::chrono_literals; diff --git a/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBControllerDetect.cpp b/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBControllerDetect.cpp index aa9655283..f22e99d94 100644 --- a/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBControllerDetect.cpp +++ b/Controllers/QMKController/QMKOpenRGBController/QMKOpenRGBControllerDetect.cpp @@ -12,15 +12,16 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" +#include "LogManager.h" #include "QMKOpenRGBRev9Controller.h" #include "QMKOpenRGBRevBController.h" #include "QMKOpenRGBRevDController.h" +#include "ResourceManager.h" #include "RGBController_QMKOpenRGBRev9.h" #include "RGBController_QMKOpenRGBRevB.h" #include "RGBController_QMKOpenRGBRevD.h" #include "RGBController_QMKOpenRGBRevE.h" -#include "LogManager.h" #include "SettingsManager.h" /*-----------------------------------------------------*\ @@ -82,35 +83,35 @@ void DetectQMKOpenRGBControllers(hid_device_info *info, const std::string&) { QMKOpenRGBRev9Controller* controller = new QMKOpenRGBRev9Controller(dev, info->path); RGBController_QMKOpenRGBRev9* rgb_controller = new RGBController_QMKOpenRGBRev9(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; case QMK_OPENRGB_PROTOCOL_VERSION_B: { QMKOpenRGBRevBController* controller = new QMKOpenRGBRevBController(dev, info->path); RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller, false); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; case QMK_OPENRGB_PROTOCOL_VERSION_C: { QMKOpenRGBRevBController* controller = new QMKOpenRGBRevBController(dev, info->path); RGBController_QMKOpenRGBRevB* rgb_controller = new RGBController_QMKOpenRGBRevB(controller, true); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; case QMK_OPENRGB_PROTOCOL_VERSION_D: { QMKOpenRGBRevDController* controller = new QMKOpenRGBRevDController(dev, info->path); RGBController_QMKOpenRGBRevD* rgb_controller = new RGBController_QMKOpenRGBRevD(controller, true); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; case QMK_OPENRGB_PROTOCOL_VERSION_E: { QMKOpenRGBRevDController* controller = new QMKOpenRGBRevDController(dev, info->path); RGBController_QMKOpenRGBRevE* rgb_controller = new RGBController_QMKOpenRGBRevE(controller, true); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } break; default: diff --git a/Controllers/QMKController/QMKVialRGBController/QMKVialRGBControllerDetect.cpp b/Controllers/QMKController/QMKVialRGBController/QMKVialRGBControllerDetect.cpp index 38ba6293e..7ed2fe8aa 100644 --- a/Controllers/QMKController/QMKVialRGBController/QMKVialRGBControllerDetect.cpp +++ b/Controllers/QMKController/QMKVialRGBController/QMKVialRGBControllerDetect.cpp @@ -11,8 +11,9 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "QMKVialRGBController.h" +#include "ResourceManager.h" #include "RGBController_QMKVialRGB.h" #include "SettingsManager.h" @@ -39,7 +40,7 @@ void DetectQMKVialRGBControllers(hid_device_info *info, const std::string&) if(controller->GetSupported()) { RGBController_QMKVialRGB* rgb_controller = new RGBController_QMKVialRGB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/RazerController/RazerControllerDetect.cpp b/Controllers/RazerController/RazerControllerDetect.cpp index 51f0a38c0..bc307fe4b 100644 --- a/Controllers/RazerController/RazerControllerDetect.cpp +++ b/Controllers/RazerController/RazerControllerDetect.cpp @@ -11,7 +11,7 @@ #include #include -#include "Detector.h" +#include "DetectionManager.h" #include "RazerController.h" #include "RazerKrakenController.h" #include "RazerKrakenV3Controller.h" @@ -43,7 +43,7 @@ void DetectRazerControllers(hid_device_info* info, const std::string& name) RazerController* controller = new RazerController(dev, dev, info->path, info->product_id, name); RGBController_Razer* rgb_controller = new RGBController_Razer(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectRazerControllers() */ @@ -124,7 +124,7 @@ void DetectRazerARGBControllers(hid_device_info* info, const std::string& name) { RazerController* controller = new RazerController(dev_interface_0, dev_interface_1, info->path, info->product_id, name); RGBController_RazerAddressable* rgb_controller = new RGBController_RazerAddressable(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); used_paths.insert(dev_interface_0_path); used_paths.insert(dev_interface_1_path); } @@ -153,7 +153,7 @@ void DetectRazerKrakenControllers(hid_device_info* info, const std::string& name RazerKrakenController* controller = new RazerKrakenController(dev, info->path, info->product_id, name); RGBController_RazerKraken* rgb_controller = new RGBController_RazerKraken(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectRazerKrakenControllers() */ @@ -174,7 +174,7 @@ void DetectRazerKrakenV3Controllers(hid_device_info* info, const std::string& na RazerKrakenV3Controller* controller = new RazerKrakenV3Controller(dev, info->path, info->product_id, name); RGBController_RazerKrakenV3* rgb_controller = new RGBController_RazerKrakenV3(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectRazerKrakenV3Controllers() */ @@ -195,7 +195,7 @@ void DetectRazerKrakenV4Controllers(hid_device_info* info, const std::string& na RazerKrakenV4Controller* controller = new RazerKrakenV4Controller(dev, info->path, info->product_id, name); RGBController_RazerKrakenV4* rgb_controller = new RGBController_RazerKrakenV4(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectRazerKrakenV4Controllers() */ @@ -216,7 +216,7 @@ void DetectRazerHanboControllers(hid_device_info* info, const std::string& name) RazerHanboController* controller = new RazerHanboController(dev, info->path, info->product_id, name); RGBController_RazerHanbo* rgb_controller = new RGBController_RazerHanbo(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectRazerHanboControllers() */ diff --git a/Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp b/Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp index 21afaae5c..c9b46469b 100644 --- a/Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp +++ b/Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "RedSquareKeyroxController.h" #include "RedSquareKeyroxTKLClassicController.h" #include "RGBController_RedSquareKeyrox.h" @@ -38,7 +38,7 @@ void DetectRedSquareKeyroxTKL(hid_device_info* info, const std::string& name) RedSquareKeyroxController* controller = new RedSquareKeyroxController(dev, *info, KEYROX_VARIANT_TKL, name); RGBController_RedSquareKeyrox* rgb_controller = new RGBController_RedSquareKeyrox(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } void DetectRedSquareKeyroxTKLClassic(hid_device_info* info, const std::string& name) @@ -50,7 +50,7 @@ void DetectRedSquareKeyroxTKLClassic(hid_device_info* info, const std::string& n RedSquareKeyroxTKLClassicController* controller = new RedSquareKeyroxTKLClassicController(dev, *info, name); RGBController_RedSquareKeyroxTKLClassic* rgb_controller = new RGBController_RedSquareKeyroxTKLClassic(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/RedragonController/RedragonControllerDetect.cpp b/Controllers/RedragonController/RedragonControllerDetect.cpp index 430446cbd..ed46f8301 100644 --- a/Controllers/RedragonController/RedragonControllerDetect.cpp +++ b/Controllers/RedragonController/RedragonControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "RedragonMouseController.h" #include "RGBController_RedragonMouse.h" @@ -46,7 +46,7 @@ void DetectRedragonMice(hid_device_info* info, const std::string& name) RedragonMouseController* controller = new RedragonMouseController(dev, info->path, name); RGBController_RedragonMouse* rgb_controller = new RGBController_RedragonMouse(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/RobobloqLightStripController/RobobloqLightStripControllerDetect.cpp b/Controllers/RobobloqLightStripController/RobobloqLightStripControllerDetect.cpp index 1217bb0ac..9e37e677e 100644 --- a/Controllers/RobobloqLightStripController/RobobloqLightStripControllerDetect.cpp +++ b/Controllers/RobobloqLightStripController/RobobloqLightStripControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "RobobloqLightStripController.h" #include "RGBController_RobobloqLightStrip.h" @@ -32,7 +32,7 @@ void DetectRobobloqLightStripController { RobobloqLightStripController* controller = new RobobloqLightStripController(dev, info->path, name); RGBController_RobobloqLightStrip* rgb_controller = new RGBController_RobobloqLightStrip(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/RoccatController/RoccatControllerDetect.cpp b/Controllers/RoccatController/RoccatControllerDetect.cpp index 5d0e4743b..aaeffd44e 100644 --- a/Controllers/RoccatController/RoccatControllerDetect.cpp +++ b/Controllers/RoccatController/RoccatControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "RoccatBurstController.h" #include "RoccatBurstProAirController.h" #include "RoccatKoneAimoController.h" @@ -75,7 +75,7 @@ void DetectRoccatMouseControllers(hid_device_info* info, const std::string& name RoccatKoneAimoController * controller = new RoccatKoneAimoController(dev, info->path, name); RGBController_RoccatKoneAimo * rgb_controller = new RGBController_RoccatKoneAimo(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -178,7 +178,7 @@ void DetectRoccatVulcanKeyboardControllers(hid_device_info* info, const std::str RoccatVulcanKeyboardController * controller = new RoccatVulcanKeyboardController(dev_ctrl, dev_led, info->path, info->product_id, name); RGBController_RoccatVulcanKeyboard * rgb_controller = new RGBController_RoccatVulcanKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); used_paths.insert(dev_ctrl_path); used_paths.insert(dev_led_path); @@ -200,7 +200,7 @@ void DetectRoccatHordeAimoKeyboardControllers(hid_device_info* info, const std:: RoccatHordeAimoController * controller = new RoccatHordeAimoController(dev, *info, name); RGBController_RoccatHordeAimo * rgb_controller = new RGBController_RoccatHordeAimo(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -213,7 +213,7 @@ void DetectRoccatBurstCoreControllers(hid_device_info* info, const std::string& RoccatBurstController * controller = new RoccatBurstController(dev, *info, name); RGBController_RoccatBurst * rgb_controller = new RGBController_RoccatBurst(controller, ROCCAT_BURST_CORE_NUMBER_OF_LEDS); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -226,7 +226,7 @@ void DetectRoccatBurstProControllers(hid_device_info* info, const std::string& n RoccatBurstController * controller = new RoccatBurstController(dev, *info, name); RGBController_RoccatBurst * rgb_controller = new RGBController_RoccatBurst(controller, ROCCAT_BURST_PRO_NUMBER_OF_LEDS); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -239,7 +239,7 @@ void DetectRoccatBurstProAirControllers(hid_device_info* info, const std::string RoccatBurstProAirController * controller = new RoccatBurstProAirController(dev, *info, name); RGBController_RoccatBurstProAir * rgb_controller = new RGBController_RoccatBurstProAir(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -252,7 +252,7 @@ void DetectRoccatKoneProControllers(hid_device_info* info, const std::string& na RoccatKoneProController * controller = new RoccatKoneProController(dev, *info, name); RGBController_RoccatKonePro * rgb_controller = new RGBController_RoccatKonePro(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -265,7 +265,7 @@ void DetectRoccatKoneProAirControllers(hid_device_info* info, const std::string& RoccatKoneProAirController * controller = new RoccatKoneProAirController(dev, *info, name); RGBController_RoccatKoneProAir * rgb_controller = new RGBController_RoccatKoneProAir(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -278,7 +278,7 @@ void DetectRoccatKoneXPControllers(hid_device_info* info, const std::string& nam RoccatKoneXPController * controller = new RoccatKoneXPController(dev, info->path, name); RGBController_RoccatKoneXP * rgb_controller = new RGBController_RoccatKoneXP(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -291,7 +291,7 @@ void DetectRoccatKovaControllers(hid_device_info* info, const std::string& name) RoccatKovaController * controller = new RoccatKovaController(dev, info->path, name); RGBController_RoccatKova * rgb_controller = new RGBController_RoccatKova(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -304,7 +304,7 @@ void DetectRoccatEloControllers(hid_device_info* info, const std::string& name) RoccatEloController * controller = new RoccatEloController(dev, *info, name); RGBController_RoccatElo * rgb_controller = new RGBController_RoccatElo(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -317,7 +317,7 @@ void DetectRoccatSenseAimoControllers(hid_device_info* info, const std::string& RoccatSenseAimoController * controller = new RoccatSenseAimoController(dev, info->path, name); RGBController_RoccatSenseAimo * rgb_controller = new RGBController_RoccatSenseAimo(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/SRGBmodsController/SRGBmodsControllerDetect.cpp b/Controllers/SRGBmodsController/SRGBmodsControllerDetect.cpp index 3b2dc537f..6a9032ae4 100644 --- a/Controllers/SRGBmodsController/SRGBmodsControllerDetect.cpp +++ b/Controllers/SRGBmodsController/SRGBmodsControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "SRGBmodsLEDControllerV1.h" #include "SRGBmodsPicoController.h" #include "RGBController_SRGBmodsLEDControllerV1.h" @@ -49,14 +49,14 @@ void DetectSRGBmodsControllers(hid_device_info* info, const std::string& name) SRGBmodsPicoController* controller = new SRGBmodsPicoController(dev, info->path, name); RGBController_SRGBmodsPico* rgb_controller = new RGBController_SRGBmodsPico(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else if(product_str == L"LED Controller v1") { SRGBmodsLEDControllerV1* controller = new SRGBmodsLEDControllerV1(dev, info->path, name); RGBController_SRGBmodsLEDControllerV1* rgb_controller = new RGBController_SRGBmodsLEDControllerV1(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectSRGBmodsControllers() */ diff --git a/Controllers/SapphireGPUController/SapphireGPUControllerDetect.cpp b/Controllers/SapphireGPUController/SapphireGPUControllerDetect.cpp index 40c4773ab..b629ba5cb 100644 --- a/Controllers/SapphireGPUController/SapphireGPUControllerDetect.cpp +++ b/Controllers/SapphireGPUController/SapphireGPUControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "SapphireNitroGlowV1Controller.h" #include "SapphireNitroGlowV3Controller.h" #include "RGBController_SapphireNitroGlowV1.h" @@ -60,7 +60,7 @@ void DetectSapphireV1Controllers(i2c_smbus_interface* bus, uint8_t i2c_addr, con SapphireNitroGlowV1Controller* new_sapphire_gpu = new SapphireNitroGlowV1Controller(bus, i2c_addr, name); RGBController_SapphireNitroGlowV1* new_controller = new RGBController_SapphireNitroGlowV1(new_sapphire_gpu); - ResourceManager::get()->RegisterRGBController(new_controller); + DetectionManager::get()->RegisterRGBController(new_controller); } } /* DetectSapphireV1Controllers() */ @@ -71,7 +71,7 @@ void DetectSapphireV3Controllers(i2c_smbus_interface* bus, uint8_t i2c_addr, con SapphireNitroGlowV3Controller* new_sapphire_gpu = new SapphireNitroGlowV3Controller(bus, i2c_addr, name); RGBController_SapphireNitroGlowV3* new_controller = new RGBController_SapphireNitroGlowV3(new_sapphire_gpu); - ResourceManager::get()->RegisterRGBController(new_controller); + DetectionManager::get()->RegisterRGBController(new_controller); } } /* DetectSapphireV3Controllers() */ diff --git a/Controllers/SeagateController/SeagateControllerDetect.cpp b/Controllers/SeagateController/SeagateControllerDetect.cpp index 2338a6b9c..e770d5389 100644 --- a/Controllers/SeagateController/SeagateControllerDetect.cpp +++ b/Controllers/SeagateController/SeagateControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "SeagateController.h" #include "RGBController_Seagate.h" #include "scsiapi.h" @@ -37,7 +37,7 @@ void DetectSeagateControllers() SeagateController* controller = new SeagateController(dev, info->path); RGBController_Seagate* rgb_controller = new RGBController_Seagate(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } info = info->next; diff --git a/Controllers/SinowealthController/SinowealthControllerDetect.cpp b/Controllers/SinowealthController/SinowealthControllerDetect.cpp index 72daf335d..e11afb971 100644 --- a/Controllers/SinowealthController/SinowealthControllerDetect.cpp +++ b/Controllers/SinowealthController/SinowealthControllerDetect.cpp @@ -7,7 +7,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_SinowealthKeyboard10c.h" #include "SinowealthController.h" #include "SinowealthController1007.h" @@ -257,7 +257,7 @@ static void DetectGenesisXenon200(hid_device_info* info, const std::string name) GenesisXenon200Controller* controller = new GenesisXenon200Controller(dev, cmd_dev, info->path, name); RGBController* rgb_controller = new RGBController_GenesisXenon200(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } @@ -279,7 +279,7 @@ static void DetectZetFuryPro(hid_device_info* info, const std::string& name) SinowealthController1007* controller = new SinowealthController1007(dev, info->path, name); RGBController_Sinowealth1007* rgb_controller = new RGBController_Sinowealth1007(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -306,7 +306,7 @@ static void DetectSinowealthMouse(hid_device_info* info, const std::string& name SinowealthController* controller = new SinowealthController(dev, dev_cmd, info->path, name); RGBController_Sinowealth* rgb_controller = new RGBController_Sinowealth(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -320,7 +320,7 @@ static void DetectGMOW_Cable(hid_device_info* info, const std::string& name) SinowealthGMOWController* controller = new SinowealthGMOWController(dev, info->path, GMOW_CABLE_CONNECTED, name); RGBController_GMOW* rgb_controller = new RGBController_GMOW(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -354,7 +354,7 @@ static void DetectGMOW_Dongle(hid_device_info* info, const std::string& name) SinowealthGMOWController* controller = new SinowealthGMOWController(dev, info->path, GMOW_DONGLE_CONNECTED, name); RGBController_GMOW* rgb_controller = new RGBController_GMOW(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -378,7 +378,7 @@ static void DetectGMOW_Dongle(hid_device_info* info, const std::string& name) // SinowealthKeyboard16Controller* controller = new SinowealthKeyboard16Controller(dev_cmd, dev, info->path, name); // RGBController_SinowealthKeyboard16* rgb_controller = new RGBController_SinowealthKeyboard16(controller); // -// ResourceManager::get()->RegisterRGBController(rgb_controller); +// DetectionManager::get()->RegisterRGBController(rgb_controller); // } // } @@ -400,7 +400,7 @@ static void DetectGMOW_Dongle(hid_device_info* info, const std::string& name) // SinowealthKeyboardController* controller = new SinowealthKeyboardController(dev_cmd, dev, info->path, name); // RGBController_SinowealthKeyboard* rgb_controller = new RGBController_SinowealthKeyboard(controller); // -// ResourceManager::get()->RegisterRGBController(rgb_controller); +// DetectionManager::get()->RegisterRGBController(rgb_controller); // } // #else // // It is unknown why this code used the MOUSE controller here; could it be the reason why it was disabled? @@ -411,7 +411,7 @@ static void DetectGMOW_Dongle(hid_device_info* info, const std::string& name) // SinowealthController* controller = new SinowealthController(dev, dev, info->path, name); // RGBController_Sinowealth* rgb_controller = new RGBController_Sinowealth(controller); // -// ResourceManager::get()->RegisterRGBController(rgb_controller); +// DetectionManager::get()->RegisterRGBController(rgb_controller); // } // #endif // } @@ -426,7 +426,7 @@ static void DetectSinowealthGenesisKeyboard(hid_device_info* info, const std::st SinowealthKeyboard90Controller* controller = new SinowealthKeyboard90Controller(dev, info->path, pid, name); RGBController_SinowealthKeyboard90* rgb_controller = new RGBController_SinowealthKeyboard90(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -448,7 +448,7 @@ static void DetectSinowealthKeyboard10c(hid_device_info* info, const std::string SinowealthKeyboard10cController* controller = new SinowealthKeyboard10cController(dev, info->path, sinowealth_10c_keyboards.at(model_id).device_name); RGBController_SinowealthKeyboard10c* rgb_controller = new RGBController_SinowealthKeyboard10c(controller, model_id); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/SkyloongController/SkyloongControllerDetect.cpp b/Controllers/SkyloongController/SkyloongControllerDetect.cpp index ba6d2072e..7cba3c265 100644 --- a/Controllers/SkyloongController/SkyloongControllerDetect.cpp +++ b/Controllers/SkyloongController/SkyloongControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "SkyloongGK104ProController.h" #include "RGBController_SkyloongGK104Pro.h" @@ -36,7 +36,7 @@ void DetectSkyloongGK104Pro(hid_device_info* info, const std::string& name) SkyloongGK104ProController* controller = new SkyloongGK104ProController(dev, info->path, name); RGBController_SkyloongGK104Pro* rgb_controller = new RGBController_SkyloongGK104Pro(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/SonyGamepadController/SonyGamepadControllerDetect.cpp b/Controllers/SonyGamepadController/SonyGamepadControllerDetect.cpp index c6d195e32..f168fd2ae 100644 --- a/Controllers/SonyGamepadController/SonyGamepadControllerDetect.cpp +++ b/Controllers/SonyGamepadController/SonyGamepadControllerDetect.cpp @@ -15,7 +15,7 @@ #include #include "RGBController_SonyDS4.h" #include "RGBController_SonyDualSense.h" -#include "Detector.h" +#include "DetectionManager.h" #define SONY_VID 0x054C @@ -34,7 +34,7 @@ void DetectSonyDS4Controllers(hid_device_info* info, const std::string&) SonyDS4Controller* controller = new SonyDS4Controller(dev, info->path); RGBController_SonyDS4* rgb_controller = new RGBController_SonyDS4(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -48,7 +48,7 @@ void DetectSonyDualSenseControllers(hid_device_info* info, const std::string& na SonyDualSenseController* controller = new SonyDualSenseController(dev, info->path, is_bluetooth, name); RGBController_SonyDualSense* rgb_controller = new RGBController_SonyDualSense(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/SteelSeriesController/SteelSeriesControllerDetect.cpp b/Controllers/SteelSeriesController/SteelSeriesControllerDetect.cpp index 8590f0719..a3a0ddbac 100644 --- a/Controllers/SteelSeriesController/SteelSeriesControllerDetect.cpp +++ b/Controllers/SteelSeriesController/SteelSeriesControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "SteelSeriesGeneric.h" #include "SteelSeriesAeroxWirelessController.h" #include "SteelSeriesAerox5Controller.h" @@ -132,7 +132,7 @@ void DetectSteelSeriesAerox3(hid_device_info* info, const std::string& name) SteelSeriesAerox3Controller* controller = new SteelSeriesAerox3Controller(dev, AEROX_3, info->path, name); RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -145,7 +145,7 @@ void DetectSteelSeriesAeroxWireless(hid_device_info* info, const std::string& na SteelSeriesAeroxWirelessController* controller = new SteelSeriesAeroxWirelessController(dev, proto_type, info->path, name); RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -168,7 +168,7 @@ void DetectSteelSeriesAerox5(hid_device_info* info, const std::string& name) SteelSeriesAerox5Controller* controller = new SteelSeriesAerox5Controller(dev, AEROX_3, info->path, name); RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -221,7 +221,7 @@ void DetectSteelSeriesApex3Full(hid_device_info* info, const std::string& name) SteelSeriesApexTZoneController* controller = new SteelSeriesApexTZoneController(dev, info->path, name); RGBController_SteelSeriesApex3* rgb_controller = new RGBController_SteelSeriesApex3(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -234,7 +234,7 @@ void DetectSteelSeriesApex3TKL(hid_device_info* info, const std::string& name) SteelSeriesApex8ZoneController* controller = new SteelSeriesApex8ZoneController(dev, info->path, name); RGBController_SteelSeriesApex3* rgb_controller = new RGBController_SteelSeriesApex3(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -247,7 +247,7 @@ void DetectSteelSeriesApex(hid_device_info* info, const std::string& name) SteelSeriesApexController* controller = new SteelSeriesApexController(dev, APEX, info->path, name); RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -259,7 +259,7 @@ void DetectSteelSeriesApex9(hid_device_info* info, const std::string& name, stee SteelSeriesApex9Controller* controller = new SteelSeriesApex9Controller(dev, proto_type, info->path, name); RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -282,7 +282,7 @@ void DetectSteelSeriesApexM(hid_device_info* info, const std::string& name) SteelSeriesApexMController* controller = new SteelSeriesApexMController(dev, APEX_M, info->path, name); RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -295,7 +295,7 @@ void DetectSteelSeriesApexOld(hid_device_info* info, const std::string& name) SteelSeriesOldApexController* controller = new SteelSeriesOldApexController(dev, APEX_OLD, info->path, name); RGBController_SteelSeriesOldApex* rgb_controller = new RGBController_SteelSeriesOldApex(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -308,7 +308,7 @@ void DetectSteelSeriesHeadset(hid_device_info* info, const std::string& name) SteelSeriesSiberiaController* controller = new SteelSeriesSiberiaController(dev, info->path, name); RGBController_SteelSeriesSiberia* rgb_controller = new RGBController_SteelSeriesSiberia(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -321,7 +321,7 @@ void DetectSteelSeriesMousemat(hid_device_info* info, const std::string& name) SteelSeriesQCKMatController* controller = new SteelSeriesQCKMatController(dev, info->path, name); RGBController_SteelSeriesQCKMat* rgb_controller = new RGBController_SteelSeriesQCKMat(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -334,7 +334,7 @@ void DetectSteelSeriesRival100(hid_device_info* info, const std::string& name) SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_100, info->path, name); RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -347,7 +347,7 @@ void DetectSteelSeriesRival300(hid_device_info* info, const std::string& name) SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_300, info->path, name); RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -360,7 +360,7 @@ void DetectSteelSeriesRival600(hid_device_info* info, const std::string& name) SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_600, info->path, name); RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -374,7 +374,7 @@ void DetectSteelSeriesRival650(hid_device_info* info, const std::string& name) SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_650, info->path, name); RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -387,7 +387,7 @@ void DetectSteelSeriesRival700(hid_device_info* info, const std::string& name) SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_700, info->path, name); RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -401,7 +401,7 @@ void DetectSteelSeriesRival3(hid_device_info* info, const std::string& name) SteelSeriesRival3Controller* controller = new SteelSeriesRival3Controller(dev, RIVAL_3, info->path, name); RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -414,7 +414,7 @@ void DetectSteelSeriesSensei(hid_device_info* info, const std::string& name) SteelSeriesSenseiController* controller = new SteelSeriesSenseiController(dev, SENSEI, info->path, name); RGBController_SteelSeriesSensei* rgb_controller = new RGBController_SteelSeriesSensei(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -427,7 +427,7 @@ void DetectSteelSeriesArctis5(hid_device_info* info, const std::string& name) SteelSeriesArctis5Controller* controller = new SteelSeriesArctis5Controller(dev, *info, name); RGBController_SteelSeriesArctis5* rgb_controller = new RGBController_SteelSeriesArctis5(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/StreamDeckController/ElgatoStreamDeckControllerDetect.cpp b/Controllers/StreamDeckController/ElgatoStreamDeckControllerDetect.cpp index e13b51011..bd64ae3b0 100644 --- a/Controllers/StreamDeckController/ElgatoStreamDeckControllerDetect.cpp +++ b/Controllers/StreamDeckController/ElgatoStreamDeckControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "ElgatoStreamDeckController.h" #include "RGBController_ElgatoStreamDeck.h" @@ -25,7 +25,7 @@ void DetectElgatoStreamDeckControllers(hid_device_info* info, const std::string& { ElgatoStreamDeckController* controller = new ElgatoStreamDeckController(dev, info->path); RGBController_ElgatoStreamDeck* rgb_controller = new RGBController_ElgatoStreamDeck(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/TForceXtreemController/TForceXtreemControllerDetect.cpp b/Controllers/TForceXtreemController/TForceXtreemControllerDetect.cpp index 1423f6627..e96da7050 100644 --- a/Controllers/TForceXtreemController/TForceXtreemControllerDetect.cpp +++ b/Controllers/TForceXtreemController/TForceXtreemControllerDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "TForceXtreemController.h" #include "LogManager.h" #include "RGBController_TForceXtreem.h" @@ -176,9 +176,9 @@ void DetectTForceXtreemControllers(i2c_smbus_interface* bus, std::vectorRegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } /* DetectTForceXtreemControllers() */ -REGISTER_I2C_DIMM_DETECTOR("T-Force Xtreem DDR4 DRAM", DetectTForceXtreemControllers, JEDEC_TEAMGROUP, SPD_DDR4_SDRAM); +REGISTER_I2C_DRAM_DETECTOR("T-Force Xtreem DDR4 DRAM", DetectTForceXtreemControllers, JEDEC_TEAMGROUP, SPD_DDR4_SDRAM); diff --git a/Controllers/TecknetController/TecknetControllerDetect.cpp b/Controllers/TecknetController/TecknetControllerDetect.cpp index b5b1a2104..24f8a52fe 100644 --- a/Controllers/TecknetController/TecknetControllerDetect.cpp +++ b/Controllers/TecknetController/TecknetControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "TecknetController.h" #include "RGBController_Tecknet.h" @@ -36,7 +36,7 @@ void DetectTecknetControllers(hid_device_info* info, const std::string&) TecknetController* controller = new TecknetController(dev, info->path); RGBController_Tecknet* rgb_controller = new RGBController_Tecknet(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectTecknetControllers) */ diff --git a/Controllers/ThermaltakePoseidonZRGBController/ThermaltakePoseidonZRGBControllerDetect.cpp b/Controllers/ThermaltakePoseidonZRGBController/ThermaltakePoseidonZRGBControllerDetect.cpp index eb277cd4c..11c322331 100644 --- a/Controllers/ThermaltakePoseidonZRGBController/ThermaltakePoseidonZRGBControllerDetect.cpp +++ b/Controllers/ThermaltakePoseidonZRGBController/ThermaltakePoseidonZRGBControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ThermaltakePoseidonZRGBController.h" #include "RGBController_ThermaltakePoseidonZRGB.h" @@ -34,7 +34,7 @@ void DetectPoseidonZRGBControllers(hid_device_info* info, const std::string&) PoseidonZRGBController* controller = new PoseidonZRGBController(dev, info->path); RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectPoseidonZRGBControllers() */ diff --git a/Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp b/Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp index 6aef3fba3..d1a594c21 100644 --- a/Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp +++ b/Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp @@ -12,7 +12,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ThermaltakeRiingController.h" #include "ThermaltakeRiingQuadController.h" #include "ThermaltakeRiingTrioController.h" @@ -41,7 +41,7 @@ void DetectThermaltakeRiingControllers(hid_device_info* info, const std::string& ThermaltakeRiingController* controller = new ThermaltakeRiingController(dev, info->path); RGBController_ThermaltakeRiing* rgb_controller = new RGBController_ThermaltakeRiing(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectThermaltakeRiingControllers() */ @@ -53,7 +53,7 @@ void DetectThermaltakeRiingQuadControllers(hid_device_info* info, const std::str ThermaltakeRiingQuadController* controller = new ThermaltakeRiingQuadController(dev, info->path); RGBController_ThermaltakeRiingQuad* rgb_controller = new RGBController_ThermaltakeRiingQuad(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -65,7 +65,7 @@ void DetectThermaltakeRiingTrioControllers(hid_device_info* info, const std::str ThermaltakeRiingTrioController* controller = new ThermaltakeRiingTrioController(dev, info->path); RGBController_ThermaltakeRiingTrio* rgb_controller = new RGBController_ThermaltakeRiingTrio(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ThingMController/ThingMControllerDetect.cpp b/Controllers/ThingMController/ThingMControllerDetect.cpp index 8a0e12cde..75b6fa196 100644 --- a/Controllers/ThingMController/ThingMControllerDetect.cpp +++ b/Controllers/ThingMController/ThingMControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "BlinkController.h" #include "RGBController_BlinkController.h" @@ -34,7 +34,7 @@ void DetectThingMBlink(hid_device_info* info, const std::string&) BlinkController* controller = new BlinkController(dev, info->path); RGBController_BlinkController* rgb_controller = new RGBController_BlinkController(controller); // Constructor sets the name - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/TrustController/TrustControllerDetect.cpp b/Controllers/TrustController/TrustControllerDetect.cpp index 583684938..7875a0ae4 100644 --- a/Controllers/TrustController/TrustControllerDetect.cpp +++ b/Controllers/TrustController/TrustControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "TrustGXT114Controller.h" #include "TrustGXT180Controller.h" #include "RGBController_TrustGXT114.h" @@ -38,7 +38,7 @@ void DetectTrustGXT114Controllers(hid_device_info* info, const std::string& name { RGBController_TrustGXT114* rgb_controller = new RGBController_TrustGXT114(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { @@ -56,7 +56,7 @@ void DetectTrustGXT180Controllers(hid_device_info* info, const std::string& name TrustGXT180Controller* controller = new TrustGXT180Controller(dev, *info, name); RGBController_TrustGXT180* rgb_controller = new RGBController_TrustGXT180(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ValkyrieKeyboardController/ValkyrieKeyboardControllerDetect.cpp b/Controllers/ValkyrieKeyboardController/ValkyrieKeyboardControllerDetect.cpp index b2744f431..c13125ae7 100644 --- a/Controllers/ValkyrieKeyboardController/ValkyrieKeyboardControllerDetect.cpp +++ b/Controllers/ValkyrieKeyboardController/ValkyrieKeyboardControllerDetect.cpp @@ -11,7 +11,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_ValkyrieKeyboard.h" void DetectValkyrieKeyboardControllers(hid_device_info* info, const std::string& name) @@ -22,7 +22,7 @@ void DetectValkyrieKeyboardControllers(hid_device_info* info, const std::string& { ValkyrieKeyboardController* controller = new ValkyrieKeyboardController(dev, info->path, info->product_id, info->interface_number, name); RGBController_ValkyrieKeyboard* rgb_controller = new RGBController_ValkyrieKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ViewSonicController/ViewSonicControllerDetect.cpp b/Controllers/ViewSonicController/ViewSonicControllerDetect.cpp index 3ede6db51..dfbf72c4a 100644 --- a/Controllers/ViewSonicController/ViewSonicControllerDetect.cpp +++ b/Controllers/ViewSonicController/ViewSonicControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "VS_XG270QG_Controller.h" #include "RGBController_XG270QG.h" #include "VS_XG270QC_Controller.h" @@ -31,7 +31,7 @@ void DetectViewSonicQG(hid_device_info* info, const std::string& name) VS_XG270QG_Controller* controller = new VS_XG270QG_Controller(dev, info->path, name); RGBController_XG270QG* rgb_controller = new RGBController_XG270QG(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } @@ -44,7 +44,7 @@ void DetectViewSonicQC(hid_device_info* info, const std::string& name) VS_XG270QC_Controller* controller = new VS_XG270QC_Controller(dev, info->path, name); RGBController_XG270QC* rgb_controller = new RGBController_XG270QC(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/WinbondGamingKeyboardController/WinbondGamingKeyboardControllerDetect.cpp b/Controllers/WinbondGamingKeyboardController/WinbondGamingKeyboardControllerDetect.cpp index 3b57208ff..82dc9a008 100644 --- a/Controllers/WinbondGamingKeyboardController/WinbondGamingKeyboardControllerDetect.cpp +++ b/Controllers/WinbondGamingKeyboardController/WinbondGamingKeyboardControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "RGBController_WinbondGamingKeyboard.h" #include "LogManager.h" @@ -55,7 +55,7 @@ void DetectWinbondGamingKeyboard(hid_device_info* info, const std::string& name) WinbondGamingKeyboardController* controller = new WinbondGamingKeyboardController(dev, *info, name); RGBController* rgb_controller = new RGBController_WinbondGamingKeyboard(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp b/Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp index 3fbf516c9..6368429b1 100644 --- a/Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp +++ b/Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "WootingV1KeyboardController.h" #include "WootingV2KeyboardController.h" #include "WootingV3KeyboardController.h" @@ -121,7 +121,7 @@ void DetectWootingControllers(hid_device_info *info, const std::string &name) RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller); LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str()); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); return; } @@ -135,7 +135,7 @@ void DetectWootingControllers(hid_device_info *info, const std::string &name) RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller); LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str()); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); return; } @@ -149,7 +149,7 @@ void DetectWootingControllers(hid_device_info *info, const std::string &name) RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller); LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str()); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); return; } diff --git a/Controllers/WushiController/WushiL50USBDetect.cpp b/Controllers/WushiController/WushiL50USBDetect.cpp index 5f5da900e..2e9978d35 100644 --- a/Controllers/WushiController/WushiL50USBDetect.cpp +++ b/Controllers/WushiController/WushiL50USBDetect.cpp @@ -8,7 +8,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "WushiL50USBController.h" #include "RGBController_WushiL50USB.h" @@ -31,7 +31,7 @@ void DetectWushiL50USBControllers(hidapi_wrapper wrapper, hid_device_info* info, WushiL50USBController* controller = new WushiL50USBController(wrapper, dev, info->path, name); RGBController_WushiL50USB* rgb_controller = new RGBController_WushiL50USB(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/XPGSummonerKeyboardController/XPGSummonerControllerDetect.cpp b/Controllers/XPGSummonerKeyboardController/XPGSummonerControllerDetect.cpp index 7d7b8a930..0c4e310d9 100644 --- a/Controllers/XPGSummonerKeyboardController/XPGSummonerControllerDetect.cpp +++ b/Controllers/XPGSummonerKeyboardController/XPGSummonerControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "XPGSummonerController.h" #include "RGBController_XPGSummoner.h" #include @@ -30,7 +30,7 @@ void DetectXPGSummonerControllers(hid_device_info *info, const std::string &name { XPGSummonerController *controller = new XPGSummonerController(dev, info->path, info->product_id, name); RGBController_XPGSummoner *rgb_controller = new RGBController_XPGSummoner(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectXPGSummonerControllers() */ diff --git a/Controllers/YeelightController/YeelightControllerDetect.cpp b/Controllers/YeelightController/YeelightControllerDetect.cpp index 3eb872b82..263e55fa2 100644 --- a/Controllers/YeelightController/YeelightControllerDetect.cpp +++ b/Controllers/YeelightController/YeelightControllerDetect.cpp @@ -9,8 +9,9 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "YeelightController.h" +#include "ResourceManager.h" #include "RGBController_Yeelight.h" #include "SettingsManager.h" @@ -58,7 +59,7 @@ void DetectYeelightControllers() YeelightController* controller = new YeelightController(yeelight_ip, yeelight_host_ip, music_mode); RGBController_Yeelight* rgb_controller = new RGBController_Yeelight(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } } diff --git a/Controllers/ZETKeyboardController/ZETKeyboardControllerDetect.cpp b/Controllers/ZETKeyboardController/ZETKeyboardControllerDetect.cpp index 80d92ede3..0e4149782 100644 --- a/Controllers/ZETKeyboardController/ZETKeyboardControllerDetect.cpp +++ b/Controllers/ZETKeyboardController/ZETKeyboardControllerDetect.cpp @@ -13,7 +13,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ZETBladeOpticalController.h" #include "RGBController_ZETBladeOptical.h" @@ -32,7 +32,7 @@ void DetectZETBladeOptical(hid_device_info* info, const std::string& name) ZETBladeOpticalController* controller = new ZETBladeOpticalController(dev, info->path, name); RGBController_ZETBladeOptical* rgb_controller = new RGBController_ZETBladeOptical(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ZalmanZSyncController/ZalmanZSyncControllerDetect.cpp b/Controllers/ZalmanZSyncController/ZalmanZSyncControllerDetect.cpp index 1396a74c8..7f566c268 100644 --- a/Controllers/ZalmanZSyncController/ZalmanZSyncControllerDetect.cpp +++ b/Controllers/ZalmanZSyncController/ZalmanZSyncControllerDetect.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "ZalmanZSyncController.h" #include "RGBController_ZalmanZSync.h" @@ -34,7 +34,7 @@ void DetectZalmanZSyncControllers(hid_device_info* info, const std::string& name ZalmanZSyncController* controller = new ZalmanZSyncController(dev, info->path, name); RGBController_ZalmanZSync* rgb_controller = new RGBController_ZalmanZSync(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } /* DetectZalmanZSyncControllers() */ diff --git a/Controllers/ZotacTuringGPUController/ZotacTuringGPUControllerDetect.cpp b/Controllers/ZotacTuringGPUController/ZotacTuringGPUControllerDetect.cpp index 17c40297a..419d212a0 100644 --- a/Controllers/ZotacTuringGPUController/ZotacTuringGPUControllerDetect.cpp +++ b/Controllers/ZotacTuringGPUController/ZotacTuringGPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "ZotacTuringGPUController.h" #include "RGBController_ZotacTuringGPU.h" #include "i2c_smbus.h" @@ -54,7 +54,7 @@ void DetectZotacTuringGPUControllers(i2c_smbus_interface* bus, u8 i2c_addr, cons ZotacTuringGPUController* controller = new ZotacTuringGPUController(bus, i2c_addr, name); RGBController_ZotacTuringGPU* rgb_controller = new RGBController_ZotacTuringGPU(controller); - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/ZotacV2GPUController/ZotacV2GPUControllerDetect.cpp b/Controllers/ZotacV2GPUController/ZotacV2GPUControllerDetect.cpp index c2f54f661..680404663 100644 --- a/Controllers/ZotacV2GPUController/ZotacV2GPUControllerDetect.cpp +++ b/Controllers/ZotacV2GPUController/ZotacV2GPUControllerDetect.cpp @@ -9,7 +9,7 @@ | SPDX-License-Identifier: GPL-2.0-or-later | \*---------------------------------------------------------*/ -#include "Detector.h" +#include "DetectionManager.h" #include "ZotacV2GPUController.h" #include "RGBController_ZotacV2GPU.h" #include "i2c_smbus.h" @@ -40,7 +40,7 @@ void DetectZotacV2GPUControllers(i2c_smbus_interface* bus, u8 i2c_addr, const st if(rgb_controller->config.numberOfZones > 0) { - ResourceManager::get()->RegisterRGBController(rgb_controller); + DetectionManager::get()->RegisterRGBController(rgb_controller); } else { diff --git a/DetectionManager.cpp b/DetectionManager.cpp new file mode 100644 index 000000000..c0fbd5cf2 --- /dev/null +++ b/DetectionManager.cpp @@ -0,0 +1,1629 @@ +/*---------------------------------------------------------*\ +| DetectionManager.cpp | +| | +| OpenRGB Detection Manager handles detecting supported | +| devices and initializing their RGBControllers | +| | +| Adam Honse 08 Jan 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#include +#include "DetectionManager.h" +#include "LogManager.h" +#include "pci_ids.h" +#include "ProfileManager.h" +#include "ResourceManager.h" +#include "SettingsManager.h" +#include "StringUtils.h" + +#ifdef __linux__ +#include +#endif + +using namespace std::chrono_literals; + +/*---------------------------------------------------------*\ +| DetectionManager name for log entries | +\*---------------------------------------------------------*/ +const char* DETECTIONMANAGER = "DetectionManager"; + +/*---------------------------------------------------------*\ +| Define a macro for QT lupdate to parse | +\*---------------------------------------------------------*/ +#define QT_TRANSLATE_NOOP(scope, x) x + +/*---------------------------------------------------------*\ +| Warning Strings | +\*---------------------------------------------------------*/ +const char* I2C_ERR_WIN = QT_TRANSLATE_NOOP("DetectionManager", + "

Some internal devices may not be detected:

" + "

One or more I2C or SMBus interfaces failed to initialize.

" + "

RGB DRAM modules, some motherboards' onboard RGB lighting, and RGB Graphics Cards, will not be available in OpenRGB without I2C or SMBus.

" + "

How to fix this:

" + "

On Windows, this is usually caused by a failure to load the PawnIO driver.

" + "

You must first install PawnIO, then you must OpenRGB as administrator in order to access these devices.

" + "

See help.openrgb.org for additional troubleshooting steps if you keep seeing this message.

" + "

If you are not using internal RGB on a desktop this message is not important to you.

"); +const char* I2C_ERR_LINUX = QT_TRANSLATE_NOOP("DetectionManager", + "

Some internal devices may not be detected:

" + "

One or more I2C or SMBus interfaces failed to initialize.

" + "

RGB DRAM modules, some motherboards' onboard RGB lighting, and RGB Graphics Cards, will not be available in OpenRGB without I2C or SMBus.

" + "

How to fix this:

" + "

On Linux, this is usually because the i2c-dev module is not loaded.

" + "

You must load the i2c-dev module along with the correct i2c driver for your motherboard. " + "This is usually i2c-piix4 for AMD systems and i2c-i801 for Intel systems.

" + "

See help.openrgb.org for additional troubleshooting steps if you keep seeing this message.

" + "

If you are not using internal RGB on a desktop this message is not important to you.

"); + +const char* UDEV_MISSING = QT_TRANSLATE_NOOP("DetectionManager", + "

WARNING:

" + "

The OpenRGB udev rules are not installed.

" + "

Most devices will not be available unless running OpenRGB as root.

" + "

If using AppImage, Flatpak, or self-compiled versions of OpenRGB you must install the udev rules manually

" + "

See https://openrgb.org/udev to install the udev rules manually

"); +const char* UDEV_MUTLI = QT_TRANSLATE_NOOP("DetectionManager", + "

WARNING:

" + "

Multiple OpenRGB udev rules are installed.

" + "

The udev rules file 60-openrgb.rules is installed in both /etc/udev/rules.d and /usr/lib/udev/rules.d.

" + "

Multiple udev rules files can conflict, it is recommended to remove one of them.

"); + +/*---------------------------------------------------------*\ +| Default hidapi wrappter that just uses default hidapi | +\*---------------------------------------------------------*/ +const hidapi_wrapper default_hidapi_wrapper = +{ + NULL, + (hidapi_wrapper_send_feature_report) hid_send_feature_report, + (hidapi_wrapper_get_feature_report) hid_get_feature_report, + (hidapi_wrapper_get_serial_number_string) hid_get_serial_number_string, + (hidapi_wrapper_open_path) hid_open_path, + (hidapi_wrapper_enumerate) hid_enumerate, + (hidapi_wrapper_free_enumeration) hid_free_enumeration, + (hidapi_wrapper_close) hid_close, + (hidapi_wrapper_error) hid_error +}; + +/*---------------------------------------------------------*\ +| BasicHIDBlock Implementation | +\*---------------------------------------------------------*/ +bool BasicHIDBlock::compare(hid_device_info* info) +{ + return((vid == info->vendor_id) + && (pid == info->product_id) +#ifdef USE_HID_USAGE + && ((usage_page == HID_USAGE_PAGE_ANY) + || (usage_page == info->usage_page)) + && ((usage == HID_USAGE_ANY) + || (usage == info->usage)) + && ((interface == HID_INTERFACE_ANY) + || (interface == info->interface_number)) +#else + && ((interface == HID_INTERFACE_ANY) + || (interface == info->interface_number)) +#endif + ); +} + +/*---------------------------------------------------------*\ +| DetectionManager Global Instance Pointer | +\*---------------------------------------------------------*/ +DetectionManager* DetectionManager::instance; + +DetectionManager::DetectionManager() +{ + /*-----------------------------------------------------*\ + | Initialize global instance pointer the when created | + | There should only ever be one instance of | + | DetectionManager | + \*-----------------------------------------------------*/ + if(!instance) + { + instance = this; + } + /*-----------------------------------------------------*\ + | If, for whatever reason, DetectionManager already | + | exists, delete this instance as only one should exist | + \*-----------------------------------------------------*/ + else + { + delete this; + return; + } + + /*-----------------------------------------------------*\ + | Initialize variables | + \*-----------------------------------------------------*/ + detection_in_progress = false; + detection_percent = 100; + detection_percent_denominator = 0; + detection_string = ""; + dynamic_detectors_processed = false; + initial_detection = true; + + /*-----------------------------------------------------*\ + | Start the background thread | + \*-----------------------------------------------------*/ + background_thread_running = true; + BackgroundThread = new std::thread(&DetectionManager::BackgroundThreadFunction, this); +} + +DetectionManager::~DetectionManager() +{ + /*-----------------------------------------------------*\ + | Exit HID in background thread | + \*-----------------------------------------------------*/ + RunInBackgroundThread(std::bind(&DetectionManager::BackgroundHidExit, this)); + + /*-----------------------------------------------------*\ + | Mark the background detection thread as not running | + | and then wake it up so it knows that it has to stop | + \*-----------------------------------------------------*/ + background_thread_running = false; + BackgroundThreadScheduledFunctionStart.notify_one(); + + /*-----------------------------------------------------*\ + | Stop the background thread | + \*-----------------------------------------------------*/ + if(BackgroundThread) + { + BackgroundThread->join(); + delete BackgroundThread; + BackgroundThread = nullptr; + } +} + +/*---------------------------------------------------------*\ +| DetectionManager Global Instance Accessor | +\*---------------------------------------------------------*/ +DetectionManager* DetectionManager::get() +{ + /*-----------------------------------------------------*\ + | If DetectionManager does not exist yet, create it | + \*-----------------------------------------------------*/ + if(!instance) + { + instance = new DetectionManager(); + } + + return instance; +} + +/*---------------------------------------------------------*\ +| Functions to access device lists | +\*---------------------------------------------------------*/ +std::vector& DetectionManager::GetI2CBuses() +{ + return(i2c_buses); +} + +std::vector& DetectionManager::GetRGBControllers() +{ + return(rgb_controllers); +} + +/*---------------------------------------------------------*\ +| I2C Bus Detector Registration Function | +\*---------------------------------------------------------*/ +void DetectionManager::RegisterI2CBusDetector(I2CBusDetectorFunction detector) +{ + i2c_bus_detectors.push_back(detector); +} + +/*---------------------------------------------------------*\ +| RGBController Detector Registration Functions | +\*---------------------------------------------------------*/ +void DetectionManager::RegisterDeviceDetector(std::string name, DeviceDetectorFunction detector) +{ + device_detector_strings.push_back(name); + device_detectors.push_back(detector); +} + +void DetectionManager::RegisterDynamicDetector(std::string name, DynamicDetectorFunction detector) +{ + dynamic_detector_strings.push_back(name); + dynamic_detectors.push_back(detector); +} + +void DetectionManager::RegisterHIDDeviceDetector(std::string name, HIDDeviceDetectorFunction detector, uint16_t vid, uint16_t pid, int interface, int usage_page, int usage) +{ + HIDDeviceDetectorBlock block; + + block.name = name; + block.vid = vid; + block.pid = pid; + block.function = detector; + block.interface = interface; + block.usage_page = usage_page; + block.usage = usage; + + hid_device_detectors.push_back(block); +} + +void DetectionManager::RegisterHIDWrappedDeviceDetector(std::string name, HIDWrappedDeviceDetectorFunction detector, uint16_t vid, uint16_t pid, int interface, int usage_page, int usage) +{ + HIDWrappedDeviceDetectorBlock block; + + block.name = name; + block.vid = vid; + block.pid = pid; + block.function = detector; + block.interface = interface; + block.usage_page = usage_page; + block.usage = usage; + + hid_wrapped_device_detectors.push_back(block); +} + +void DetectionManager::RegisterI2CDeviceDetector(std::string name, I2CDeviceDetectorFunction detector) +{ + i2c_device_detector_strings.push_back(name); + i2c_device_detectors.push_back(detector); +} + +void DetectionManager::RegisterI2CDRAMDeviceDetector(std::string name, I2CDRAMDeviceDetectorFunction detector, uint16_t jedec_id, uint8_t dram_type) +{ + I2CDRAMDeviceDetectorBlock block; + + block.name = name; + block.function = detector; + block.jedec_id = jedec_id; + block.dram_type = dram_type; + + i2c_dram_device_detectors.push_back(block); +} + +void DetectionManager::RegisterI2CPCIDeviceDetector(std::string name, I2CPCIDeviceDetectorFunction detector, uint16_t ven_id, uint16_t dev_id, uint16_t subven_id, uint16_t subdev_id, uint8_t i2c_addr) +{ + I2CPCIDeviceDetectorBlock block; + + block.name = name; + block.function = detector; + block.ven_id = ven_id; + block.dev_id = dev_id; + block.subven_id = subven_id; + block.subdev_id = subdev_id; + block.i2c_addr = i2c_addr; + + i2c_pci_device_detectors.push_back(block); +} + +/*---------------------------------------------------------*\ +| Pre-Detection Hook Function Registration Function | +\*---------------------------------------------------------*/ +void DetectionManager::RegisterPreDetectionHook(PreDetectionHookFunction hook) +{ + pre_detection_hooks.push_back(hook); +} + +/*---------------------------------------------------------*\ +| Detection Callback Registration Functions | +\*---------------------------------------------------------*/ +void DetectionManager::RegisterDetectionCallback(DetectionCallback new_callback, void * new_callback_arg) +{ + DetectionCallbackMutex.lock(); + + for(std::size_t idx = 0; idx < DetectionCallbacks.size(); idx++) + { + if(DetectionCallbacks[idx] == new_callback && DetectionCallbackArgs[idx] == new_callback_arg) + { + DetectionCallbackMutex.unlock(); + + LOG_TRACE("[%s] Tried to register an already registered detection callback, skipping. Total callbacks registered: %d", DETECTIONMANAGER, DetectionCallbacks.size()); + + return; + } + } + + DetectionCallbacks.push_back(new_callback); + DetectionCallbackArgs.push_back(new_callback_arg); + + DetectionCallbackMutex.unlock(); + + LOG_TRACE("[%s] Registered detection callback. Total callbacks registered: %d", DETECTIONMANAGER, DetectionCallbacks.size()); +} + +void DetectionManager::UnregisterDetectionCallback(DetectionCallback callback, void *callback_arg) +{ + DetectionCallbackMutex.lock(); + + for(std::size_t idx = 0; idx < DetectionCallbacks.size(); idx++) + { + if(DetectionCallbacks[idx] == callback && DetectionCallbackArgs[idx] == callback_arg) + { + DetectionCallbacks.erase(DetectionCallbacks.begin() + idx); + DetectionCallbackArgs.erase(DetectionCallbackArgs.begin() + idx); + } + } + + DetectionCallbackMutex.unlock(); + + LOG_TRACE("[%s] Unregistered detection callback. Total callbacks registered: %d", DETECTIONMANAGER, DetectionCallbacks.size()); +} + +/*---------------------------------------------------------*\ +| Functions for registering I2C buses from within detectors | +\*---------------------------------------------------------*/ +void DetectionManager::RegisterI2CBus(i2c_smbus_interface *bus) +{ + LOG_INFO("[%s] Registering I2C interface: %s Device %04X:%04X Subsystem: %04X:%04X", DETECTIONMANAGER, bus->device_name, bus->pci_vendor, bus->pci_device, bus->pci_subsystem_vendor, bus->pci_subsystem_device); + + /*-----------------------------------------------------*\ + | Add the new bus to the list | + \*-----------------------------------------------------*/ + i2c_buses.push_back(bus); + + /*-----------------------------------------------------*\ + | Signal I2C Bus List Update | + \*-----------------------------------------------------*/ + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_I2C_BUS_REGISTERED); +} + +/*---------------------------------------------------------*\ +| Functions for registering RGBControllers from within | +| detectors | +\*---------------------------------------------------------*/ +void DetectionManager::RegisterRGBController(RGBController *rgb_controller) +{ + LOG_INFO("[%s] Registering RGB controller %s", DETECTIONMANAGER, rgb_controller->GetName().c_str()); + + /*-----------------------------------------------------*\ + | Mark this controller as locally owned | + \*-----------------------------------------------------*/ + rgb_controller->flags &= ~CONTROLLER_FLAG_REMOTE; + rgb_controller->flags |= CONTROLLER_FLAG_LOCAL; + + /*-----------------------------------------------------*\ + | Load sizes for the new controller | + \*-----------------------------------------------------*/ + ResourceManager::get()->GetProfileManager()->LoadControllerFromListWithOptions(rgb_controllers_sizes, detection_size_entry_used, rgb_controller, true, false); + + /*-----------------------------------------------------*\ + | Add the new controller to the list | + \*-----------------------------------------------------*/ + rgb_controllers.push_back(rgb_controller); + + /*-----------------------------------------------------*\ + | Signal Device List Update | + \*-----------------------------------------------------*/ + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_RGBCONTROLLER_REGISTERED); +} + +void DetectionManager::UnregisterRGBController(RGBController* rgb_controller) +{ + LOG_INFO("[%s] Unregistering RGB controller %s", DETECTIONMANAGER, rgb_controller->GetName().c_str()); + + /*-----------------------------------------------------*\ + | Clear callbacks from the controller before removal | + \*-----------------------------------------------------*/ + rgb_controller->ClearCallbacks(); + + /*-----------------------------------------------------*\ + | Find the controller to remove and remove it from the | + | master list | + \*-----------------------------------------------------*/ + std::vector::iterator rgb_it = std::find(rgb_controllers.begin(), rgb_controllers.end(), rgb_controller); + + if(rgb_it != rgb_controllers.end()) + { + rgb_controllers.erase(rgb_it); + } + + /*-----------------------------------------------------*\ + | Signal Device List Update | + \*-----------------------------------------------------*/ + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_RGBCONTROLLER_UNREGISTERED); +} + +/*---------------------------------------------------------*\ +| Detection state functions | +\*---------------------------------------------------------*/ +void DetectionManager::AbortDetection() +{ + LOG_INFO("[%s] Detection abort requested", DETECTIONMANAGER); + + detection_in_progress = false; + detection_percent = 100; + detection_string = "Stopping"; +} + +void DetectionManager::BeginDetection() +{ + /*-----------------------------------------------------*\ + | Perform pre-detection setup | + \*-----------------------------------------------------*/ + bool detection_ready = ProcessPreDetection(); + + /*-----------------------------------------------------*\ + | Run DetectDevices function in background thread if | + | ready to run detection | + \*-----------------------------------------------------*/ + if(detection_ready) + { + RunInBackgroundThread(std::bind(&DetectionManager::BackgroundDetectDevices, this)); + } +} + +unsigned int DetectionManager::GetDetectionPercent() +{ + return(detection_percent.load()); +} + +std::string DetectionManager::GetDetectionString() +{ + return(detection_string); +} + +void DetectionManager::WaitForDetection() +{ + DetectDevicesMutex.lock(); + DetectDevicesMutex.unlock(); +} + +/*---------------------------------------------------------*\ +| DetectionManager Background Thread Functions | +\*---------------------------------------------------------*/ +void DetectionManager::BackgroundThreadFunction() +{ + /*-----------------------------------------------------*\ + | The background thread that runs scheduled coroutines | + | when applicable | + | Stays asleep if nothing is scheduled | + | NOTE: this thread owns the HIDAPI library internal | + | objects on MacOS | + | hid_init and hid_exit may not be called outside of | + | this thread. Calling hid_exit outside of this thread | + | WILL cause an immediate CRASH on MacOS. | + | BackgroundThreadStateMutex will be UNLOCKED as long | + | as the thread is suspended. It locks automatically | + | when any coroutine is running. However, it seems to | + | be necessary to be separate from the | + | DeviceDetectionMutex, even though their states are | + | nearly identical. | + \------------------------------------------------------*/ + std::unique_lock lock(BackgroundThreadStateMutex); + + while(background_thread_running) + { + if(BackgroundThreadScheduledFunction) + { + std::function coroutine = nullptr; + std::swap(BackgroundThreadScheduledFunction, coroutine); + + try + { + coroutine(); + } + catch(std::exception& e) + { + LOG_ERROR("[%s] Unhandled exception in coroutine; e.what(): %s", DETECTIONMANAGER, e.what()); + } + catch(...) + { + LOG_ERROR("[%s] Unhandled exception in coroutine", DETECTIONMANAGER); + } + } + + /*-------------------------------------------------*\ + | This line will cause the thread to suspend until | + | the condition variable is triggered | + | NOTE: it may be subject to "spurious wakeups" | + \*-------------------------------------------------*/ + BackgroundThreadScheduledFunctionStart.wait(lock); + } +} + +void DetectionManager::RunInBackgroundThread(std::function coroutine) +{ + if(std::this_thread::get_id() == BackgroundThread->get_id()) + { + /*-------------------------------------------------*\ + | We are already in the background thread - don't | + | schedule the call, run it immediately | + \*-------------------------------------------------*/ + coroutine(); + } + else + { + /*-------------------------------------------------*\ + | Lock the background thread state mutex and assign | + | the new function to the background thread, then | + | trigger the background thread to start it | + \*-------------------------------------------------*/ + BackgroundThreadStateMutex.lock(); + + if(BackgroundThreadScheduledFunction != nullptr) + { + LOG_WARNING("[%s] Detection coroutine: assigned a new coroutine when one was already scheduled - probably two rescan events sent at once", DETECTIONMANAGER); + } + + BackgroundThreadScheduledFunction = coroutine; + BackgroundThreadStateMutex.unlock(); + BackgroundThreadScheduledFunctionStart.notify_one(); + } +} + +/*---------------------------------------------------------*\ +| Functions that must be run in the background thread | +\*---------------------------------------------------------*/ +void DetectionManager::BackgroundDetectDevices() +{ + /*-----------------------------------------------------*\ + | Lock detection mutex | + \*-----------------------------------------------------*/ + DetectDevicesMutex.lock(); + + /*-----------------------------------------------------*\ + | Set detection in progress flag | + \*-----------------------------------------------------*/ + detection_in_progress = true; + + /*-----------------------------------------------------*\ + | Initialize local variables | + \*-----------------------------------------------------*/ + hid_device_info* current_hid_device; + json detector_settings; + hid_device_info* hid_devices = NULL; + bool hid_safe_mode = false; + unsigned int initial_detection_delay_ms = 0; + + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Start device detection |"); + LOG_INFO("------------------------------------------------------"); + + /*-----------------------------------------------------*\ + | Start at 0% detection progress | + \*-----------------------------------------------------*/ + detection_percent = 0; + detection_string = ""; + + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + /*-----------------------------------------------------*\ + | Open device disable list and read in disabled | + | device strings | + \*-----------------------------------------------------*/ + detector_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Detectors"); + + /*-----------------------------------------------------*\ + | Check HID safe mode setting | + \*-----------------------------------------------------*/ + if(detector_settings.contains("hid_safe_mode")) + { + hid_safe_mode = detector_settings["hid_safe_mode"]; + } + + /*-----------------------------------------------------*\ + | Check initial detection delay setting | + \*-----------------------------------------------------*/ + if(detector_settings.contains("initial_detection_delay_ms")) + { + initial_detection_delay_ms = detector_settings["initial_detection_delay_ms"]; + } + + /*-----------------------------------------------------*\ + | If configured, delay detection for the configured | + | time only on first detection | + \*-----------------------------------------------------*/ + if(initial_detection) + { + if(initial_detection_delay_ms != 0) + { + LOG_INFO("[ResourceManager] Delaying detection for %d ms", initial_detection_delay_ms); + std::this_thread::sleep_for(initial_detection_delay_ms * 1ms); + } + + /*-------------------------------------------------*\ + | Also initialize HID on first detection, as this | + | must be called from the background thread | + \*-------------------------------------------------*/ + BackgroundHidInit(); + + initial_detection = false; + } + + /*-----------------------------------------------------*\ + | Reset the size entry used flags vector | + \*-----------------------------------------------------*/ + detection_size_entry_used.resize(rgb_controllers_sizes.size()); + + for(std::size_t size_idx = 0; size_idx < detection_size_entry_used.size(); size_idx++) + { + detection_size_entry_used[size_idx] = false; + } + + /*-----------------------------------------------------*\ + | Enumerate HID devices unless using HID safe mode | + \*-----------------------------------------------------*/ + if(!hid_safe_mode) + { + hid_devices = hid_enumerate(0, 0); + } + + /*-----------------------------------------------------*\ + | Calculate the percentage denominator by adding the | + | number of I2C and miscellaneous detectors and the | + | number of enumerated HID devices | + | | + | Start by iterating through all HID devices in list to | + | get a total count | + \*-----------------------------------------------------*/ + detection_percent_i2c_count = (unsigned int)i2c_device_detectors.size(); + detection_percent_i2c_dram_count = (unsigned int)i2c_dram_device_detectors.size(); + detection_percent_i2c_pci_count = (unsigned int)i2c_pci_device_detectors.size(); + + if(hid_safe_mode) + { + detection_percent_hid_count = (unsigned int)hid_device_detectors.size(); + } + else + { + current_hid_device = hid_devices; + detection_percent_hid_count = 0; + + while(current_hid_device) + { + detection_percent_hid_count++; + + current_hid_device = current_hid_device->next; + } + } + + detection_percent_other_count = (unsigned int)device_detectors.size(); + + detection_percent_denominator = detection_percent_i2c_count + + detection_percent_i2c_dram_count + + detection_percent_i2c_pci_count + + detection_percent_other_count + + detection_percent_hid_count; + + /*-----------------------------------------------------*\ + | Detect I2C interfaces | + \*-----------------------------------------------------*/ + BackgroundDetectI2CBuses(); + + /*-----------------------------------------------------*\ + | Detect I2C devices | + \*-----------------------------------------------------*/ + BackgroundDetectI2CDevices(detector_settings); + + /*-----------------------------------------------------*\ + | Detect I2C DRAM devices | + \*-----------------------------------------------------*/ + BackgroundDetectI2CDRAMDevices(detector_settings); + + /*-----------------------------------------------------*\ + | Detect I2C PCI devices | + \*-----------------------------------------------------*/ + BackgroundDetectI2CPCIDevices(detector_settings); + + /*-----------------------------------------------------*\ + | Detect HID devices | + \*-----------------------------------------------------*/ + if(hid_safe_mode) + { + BackgroundDetectHIDDevicesSafe(detector_settings); + } + else + { + BackgroundDetectHIDDevices(hid_devices, detector_settings); + } + + /*-----------------------------------------------------*\ + | Detect Wrapped HID devices (GLIBC Linux only) | + \*-----------------------------------------------------*/ +#ifdef __linux__ +#ifdef __GLIBC__ + BackgroundDetectHIDDevicesWrapped(hid_devices, detector_settings); +#endif +#endif + + /*-----------------------------------------------------*\ + | Detect other devices | + \*-----------------------------------------------------*/ + BackgroundDetectOtherDevices(detector_settings); + + /*-----------------------------------------------------*\ + | Signal that detection progress reached 100% | + \*-----------------------------------------------------*/ + detection_percent = 100; + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + /*-----------------------------------------------------*\ + | Signal that detection is complete | + \*-----------------------------------------------------*/ + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_COMPLETE); + + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detection completed |"); + LOG_INFO("------------------------------------------------------"); + + /*-----------------------------------------------------*\ + | Clear detection in progress flag | + \*-----------------------------------------------------*/ + detection_in_progress = false; + + /*-----------------------------------------------------*\ + | Unlock detection mutex | + \*-----------------------------------------------------*/ + DetectDevicesMutex.unlock(); + +#ifdef __linux__ + /*-----------------------------------------------------*\ + | Check if the udev rules exist | + \*-----------------------------------------------------*/ + bool udev_not_exist = false; + bool udev_multiple = false; + + if(access("/etc/udev/rules.d/60-openrgb.rules", F_OK) != 0) + { + if(access("/usr/lib/udev/rules.d/60-openrgb.rules", F_OK) != 0) + { + udev_not_exist = true; + } + } + else + { + if(access("/usr/lib/udev/rules.d/60-openrgb.rules", F_OK) == 0) + { + udev_multiple = true; + } + } + + /*-----------------------------------------------------*\ + | If the udev rules file is not installed, show a dialog| + \*-----------------------------------------------------*/ + if(udev_not_exist) + { + LOG_DIALOG("%s", UDEV_MISSING); + + udev_multiple = false; + i2c_interface_fail = false; + } + + /*-----------------------------------------------------*\ + | If multiple udev rules files are installed, show a | + | dialog | + \*-----------------------------------------------------*/ + if(udev_multiple) + { + LOG_DIALOG("%s", UDEV_MUTLI); + + i2c_interface_fail = false; + } + +#endif + + /*-----------------------------------------------------*\ + | If any i2c interfaces failed to detect due to an | + | error condition, show a dialog | + \*-----------------------------------------------------*/ + if(i2c_interface_fail) + { +#ifdef _WIN32 + LOG_DIALOG("%s", I2C_ERR_WIN); +#endif +#ifdef __linux__ + LOG_DIALOG("%s", I2C_ERR_LINUX); +#endif + } +} + +void DetectionManager::BackgroundDetectI2CBuses() +{ + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detecting I2C interfaces |"); + LOG_INFO("------------------------------------------------------"); + + detection_percent = 0; + detection_string = "Detecting I2C interfaces"; + + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + i2c_interface_fail = false; + + for(std::size_t i2c_bus_detector_idx = 0; i2c_bus_detector_idx < i2c_bus_detectors.size(); i2c_bus_detector_idx++) + { + if(i2c_bus_detectors[i2c_bus_detector_idx]() == false) + { + i2c_interface_fail = true; + } + } +} + +void DetectionManager::BackgroundDetectI2CDevices(json detector_settings) +{ + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detecting I2C devices |"); + LOG_INFO("------------------------------------------------------"); + + for(std::size_t i2c_detector_idx = 0; i2c_detector_idx < i2c_device_detectors.size(); i2c_detector_idx++) + { + /*-------------------------------------------------*\ + | Update detection string | + \*-------------------------------------------------*/ + detection_string = i2c_device_detector_strings[i2c_detector_idx].c_str(); + + /*-------------------------------------------------*\ + | Check if this detector is enabled | + \*-------------------------------------------------*/ + bool this_device_enabled = true; + + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) + { + this_device_enabled = detector_settings["detectors"][detection_string]; + } + + LOG_DEBUG("[%s] %s is %s", DETECTIONMANAGER, detection_string.c_str(), ((this_device_enabled == true) ? "enabled" : "disabled")); + + /*-------------------------------------------------*\ + | If enabled, signal progress changed and call the | + | detector | + \*-------------------------------------------------*/ + if(this_device_enabled) + { + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + i2c_device_detectors[i2c_detector_idx](i2c_buses); + } + + LOG_TRACE("[%s] %s detection end", DETECTIONMANAGER, detection_string.c_str()); + + /*-------------------------------------------------*\ + | Update detection percent | + \*-------------------------------------------------*/ + unsigned int detection_percent_numerator = i2c_detector_idx; + + detection_percent = (unsigned int)(100.0f * (detection_percent_numerator / detection_percent_denominator)); + } +} + +void DetectionManager::BackgroundDetectI2CDRAMDevices(json detector_settings) +{ + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detecting I2C DRAM modules |"); + LOG_INFO("------------------------------------------------------"); + + detection_string = "Reading DRAM SPD Information"; + + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + for(std::size_t bus = 0; bus < i2c_buses.size() && IsAnyDimmDetectorEnabled(detector_settings); bus++) + { + IF_DRAM_SMBUS(i2c_buses[bus]->pci_vendor, i2c_buses[bus]->pci_device) + { + std::vector slots; + SPDMemoryType dram_type = SPD_RESERVED; + + for(uint8_t spd_addr = 0x50; spd_addr < 0x58; spd_addr++) + { + SPDDetector spd(i2c_buses[bus], spd_addr, dram_type); + if(spd.is_valid()) + { + SPDWrapper accessor(spd); + dram_type = spd.memory_type(); + LOG_INFO("[%s] Detected occupied slot %d, bus %d, type %s", DETECTIONMANAGER, spd_addr - 0x50 + 1, bus, spd_memory_type_name[dram_type]); + LOG_DEBUG("[%s] JEDEC ID: 0x%04x", DETECTIONMANAGER, accessor.jedec_id()); + slots.push_back(accessor); + } + } + + for(std::size_t i2c_detector_idx = 0; i2c_detector_idx < i2c_dram_device_detectors.size(); i2c_detector_idx++) + { + if((i2c_dram_device_detectors[i2c_detector_idx].dram_type == dram_type) && is_jedec_in_slots(slots, i2c_dram_device_detectors[i2c_detector_idx].jedec_id)) + { + detection_string = i2c_dram_device_detectors[i2c_detector_idx].name.c_str(); + + /*-------------------------------------*\ + | Check if this detector is enabled | + \*-------------------------------------*/ + bool this_device_enabled = true; + + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) + { + this_device_enabled = detector_settings["detectors"][detection_string]; + } + + LOG_DEBUG("[%s] %s is %s", DETECTIONMANAGER, detection_string.c_str(), ((this_device_enabled == true) ? "enabled" : "disabled")); + + if(this_device_enabled) + { + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + std::vector matching_slots = slots_with_jedec(slots, i2c_dram_device_detectors[i2c_detector_idx].jedec_id); + i2c_dram_device_detectors[i2c_detector_idx].function(i2c_buses[bus], matching_slots, i2c_dram_device_detectors[i2c_detector_idx].name); + } + + LOG_TRACE("[%s] %s detection end", DETECTIONMANAGER, detection_string.c_str()); + } + + /*-----------------------------------------*\ + | Update detection percent | + \*-----------------------------------------*/ + unsigned int detection_percent_numerator = detection_percent_i2c_count + + i2c_detector_idx; + + detection_percent = (unsigned int)(100.0f * (detection_percent_numerator / detection_percent_denominator)); + } + } + } +} + +void DetectionManager::BackgroundDetectI2CPCIDevices(json detector_settings) +{ + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detecting I2C PCI devices |"); + LOG_INFO("------------------------------------------------------"); + + for(std::size_t i2c_detector_idx = 0; i2c_detector_idx < i2c_pci_device_detectors.size(); i2c_detector_idx++) + { + detection_string = i2c_pci_device_detectors[i2c_detector_idx].name.c_str(); + + /*-------------------------------------------------*\ + | Check if this detector is enabled | + \*-------------------------------------------------*/ + bool this_device_enabled = true; + + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) + { + this_device_enabled = detector_settings["detectors"][detection_string]; + } + + LOG_DEBUG("[%s] %s is %s", DETECTIONMANAGER, detection_string.c_str(), ((this_device_enabled == true) ? "enabled" : "disabled")); + + if(this_device_enabled) + { + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + for(std::size_t bus = 0; bus < i2c_buses.size(); bus++) + { + if(i2c_buses[bus]->pci_vendor == i2c_pci_device_detectors[i2c_detector_idx].ven_id && + i2c_buses[bus]->pci_device == i2c_pci_device_detectors[i2c_detector_idx].dev_id && + i2c_buses[bus]->pci_subsystem_vendor == i2c_pci_device_detectors[i2c_detector_idx].subven_id && + i2c_buses[bus]->pci_subsystem_device == i2c_pci_device_detectors[i2c_detector_idx].subdev_id) + { + i2c_pci_device_detectors[i2c_detector_idx].function(i2c_buses[bus], i2c_pci_device_detectors[i2c_detector_idx].i2c_addr, i2c_pci_device_detectors[i2c_detector_idx].name); + } + } + } + + LOG_TRACE("[%s] %s detection end", DETECTIONMANAGER, detection_string.c_str()); + + /*-------------------------------------------------*\ + | Update detection percent | + \*-------------------------------------------------*/ + unsigned int detection_percent_numerator = detection_percent_i2c_count + + detection_percent_i2c_dram_count + + i2c_detector_idx; + + detection_percent = (unsigned int)(100.0f * (detection_percent_numerator / detection_percent_denominator)); + } +} + +void DetectionManager::BackgroundDetectHIDDevices(hid_device_info* hid_devices, json detector_settings) +{ + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detecting HID devices |"); + LOG_INFO("------------------------------------------------------"); + + hid_device_info* current_hid_device = hid_devices; + + /*-----------------------------------------------------*\ + | Iterate through all devices in list and run detectors | + \*-----------------------------------------------------*/ + unsigned int hid_device_count = 0; + + while(current_hid_device) + { + if(LogManager::get()->getLoglevel() >= LL_DEBUG) + { + const char* manu_name = StringUtils::wchar_to_char(current_hid_device->manufacturer_string); + const char* prod_name = StringUtils::wchar_to_char(current_hid_device->product_string); + + LOG_DEBUG("[%s] %04X:%04X U=%04X P=0x%04X I=%d - %-25s - %s", DETECTIONMANAGER, current_hid_device->vendor_id, current_hid_device->product_id, current_hid_device->usage, current_hid_device->usage_page, current_hid_device->interface_number, manu_name, prod_name); + } + + detection_string = ""; + + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + /*-------------------------------------------------*\ + | Loop through all available detectors. If all | + | required information matches, run the detector | + \*-------------------------------------------------*/ + for(std::size_t hid_detector_idx = 0; hid_detector_idx < hid_device_detectors.size(); hid_detector_idx++) + { + HIDDeviceDetectorBlock & detector = hid_device_detectors[hid_detector_idx]; + + if(detector.compare(current_hid_device)) + { + detection_string = detector.name.c_str(); + + /*-----------------------------------------*\ + | Check if this detector is enabled or | + | needs to be added to the settings list | + \*-----------------------------------------*/ + bool this_device_enabled = true; + + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) + { + this_device_enabled = detector_settings["detectors"][detection_string]; + } + + LOG_DEBUG("[%s] %s is %s", DETECTIONMANAGER, detection_string.c_str(), ((this_device_enabled == true) ? "enabled" : "disabled")); + + if(this_device_enabled) + { + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + detector.function(current_hid_device, hid_device_detectors[hid_detector_idx].name); + } + } + } + + /*-------------------------------------------------*\ + | Loop through all available wrapped HID detectors. | + | If all required information matches, run the | + | detector | + \*-------------------------------------------------*/ + for(std::size_t hid_detector_idx = 0; hid_detector_idx < hid_wrapped_device_detectors.size(); hid_detector_idx++) + { + HIDWrappedDeviceDetectorBlock & detector = hid_wrapped_device_detectors[hid_detector_idx]; + + if(detector.compare(current_hid_device)) + { + detection_string = detector.name.c_str(); + + /*-----------------------------------------*\ + | Check if this detector is enabled or | + | needs to be added to the settings list | + \*-----------------------------------------*/ + bool this_device_enabled = true; + + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) + { + this_device_enabled = detector_settings["detectors"][detection_string]; + } + + LOG_DEBUG("[%s] %s is %s", DETECTIONMANAGER, detection_string.c_str(), ((this_device_enabled == true) ? "enabled" : "disabled")); + + if(this_device_enabled) + { + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + detector.function(default_hidapi_wrapper, current_hid_device, hid_wrapped_device_detectors[hid_detector_idx].name); + } + } + } + + /*-------------------------------------------------*\ + | Update detection percent | + \*-------------------------------------------------*/ + hid_device_count++; + + unsigned int detection_percent_numerator = detection_percent_i2c_count + + detection_percent_i2c_dram_count + + detection_percent_i2c_pci_count + + hid_device_count; + + detection_percent = (unsigned int)(100.0f * (detection_percent_numerator / detection_percent_denominator)); + + /*-------------------------------------------------*\ + | Move on to the next HID device | + \*-------------------------------------------------*/ + current_hid_device = current_hid_device->next; + } + + /*-----------------------------------------------------*\ + | Done using the device list, free it | + \*-----------------------------------------------------*/ + hid_free_enumeration(hid_devices); +} + +void DetectionManager::BackgroundDetectHIDDevicesSafe(json detector_settings) +{ + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detecting HID devices |"); + LOG_INFO("| with safe mode |"); + LOG_INFO("------------------------------------------------------"); + + /*-----------------------------------------------------*\ + | Loop through all available detectors. If all | + | required information matches, run the detector | + \*-----------------------------------------------------*/ + for(std::size_t hid_detector_idx = 0; hid_detector_idx < hid_device_detectors.size(); hid_detector_idx++) + { + HIDDeviceDetectorBlock & detector = hid_device_detectors[hid_detector_idx]; + + LOG_VERBOSE("[%s] Trying to run detector for [%s] (for %04x:%04x)", DETECTIONMANAGER, detector.name.c_str(), detector.vid, detector.pid); + + hid_device_info* current_hid_device = hid_enumerate(detector.vid, detector.pid); + + while(current_hid_device) + { + if(detector.compare(current_hid_device)) + { + detection_string = detector.name.c_str(); + + /*-----------------------------------------*\ + | Check if this detector is enabled or | + | needs to be added to the settings list | + \*-----------------------------------------*/ + bool this_device_enabled = true; + + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) + { + this_device_enabled = detector_settings["detectors"][detection_string]; + } + + LOG_DEBUG("[%s] %s is %s", DETECTIONMANAGER, detection_string.c_str(), ((this_device_enabled == true) ? "enabled" : "disabled")); + + if(this_device_enabled) + { + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + detector.function(current_hid_device, hid_device_detectors[hid_detector_idx].name); + + LOG_TRACE("[%s] %s detection end", DETECTIONMANAGER, detection_string.c_str()); + } + } + + current_hid_device = current_hid_device->next; + + /*---------------------------------------------*\ + | Update detection percent | + \*---------------------------------------------*/ + unsigned int detection_percent_numerator = detection_percent_i2c_count + + detection_percent_i2c_dram_count + + detection_percent_i2c_pci_count + + hid_detector_idx; + + detection_percent = (unsigned int)(100.0f * (detection_percent_numerator / detection_percent_denominator)); + } + + hid_free_enumeration(current_hid_device); + } +} + +#ifdef __linux__ +#ifdef __GLIBC__ +void DetectionManager::BackgroundDetectHIDDevicesWrapped(hid_device_info* hid_devices, json detector_settings) +{ + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detecting libusb HID devices |"); + LOG_INFO("------------------------------------------------------"); + + void * dyn_handle = NULL; + hidapi_wrapper wrapper; + + /*-----------------------------------------------------*\ + | Load the libhidapi-libusb library | + \*-----------------------------------------------------*/ + if((dyn_handle = dlopen("libhidapi-libusb.so", RTLD_NOW | RTLD_NODELETE | RTLD_DEEPBIND))) + { + /*-------------------------------------------------*\ + | Create a wrapper with the libusb functions | + \*-------------------------------------------------*/ + wrapper = + { + .dyn_handle = dyn_handle, + .hid_send_feature_report = (hidapi_wrapper_send_feature_report) dlsym(dyn_handle,"hid_send_feature_report"), + .hid_get_feature_report = (hidapi_wrapper_get_feature_report) dlsym(dyn_handle,"hid_get_feature_report"), + .hid_get_serial_number_string = (hidapi_wrapper_get_serial_number_string) dlsym(dyn_handle,"hid_get_serial_number_string"), + .hid_open_path = (hidapi_wrapper_open_path) dlsym(dyn_handle,"hid_open_path"), + .hid_enumerate = (hidapi_wrapper_enumerate) dlsym(dyn_handle,"hid_enumerate"), + .hid_free_enumeration = (hidapi_wrapper_free_enumeration) dlsym(dyn_handle,"hid_free_enumeration"), + .hid_close = (hidapi_wrapper_close) dlsym(dyn_handle,"hid_close"), + .hid_error = (hidapi_wrapper_error) dlsym(dyn_handle,"hid_free_enumeration") + }; + + hid_devices = wrapper.hid_enumerate(0, 0); + + hid_device_info* current_hid_device = hid_devices; + + /*-------------------------------------------------*\ + | Iterate through all devices in list and run | + | detectors | + \*-------------------------------------------------*/ + unsigned int hid_device_count = 0; + + while(current_hid_device) + { + if(LogManager::get()->getLoglevel() >= LL_DEBUG) + { + const char* manu_name = StringUtils::wchar_to_char(current_hid_device->manufacturer_string); + const char* prod_name = StringUtils::wchar_to_char(current_hid_device->product_string); + + LOG_DEBUG("[%s] %04X:%04X U=%04X P=0x%04X I=%d - %-25s - %s", DETECTIONMANAGER, current_hid_device->vendor_id, current_hid_device->product_id, current_hid_device->usage, current_hid_device->usage_page, current_hid_device->interface_number, manu_name, prod_name); + } + + detection_string = ""; + + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + /*---------------------------------------------*\ + | Loop through all available wrapped HID | + | detectors. If all required information | + | matches, run the detector | + \*---------------------------------------------*/ + for(std::size_t hid_detector_idx = 0; hid_detector_idx < hid_wrapped_device_detectors.size(); hid_detector_idx++) + { + HIDWrappedDeviceDetectorBlock & detector = hid_wrapped_device_detectors[hid_detector_idx]; + + if(detector.compare(current_hid_device)) + { + detection_string = detector.name.c_str(); + + /*-------------------------------------*\ + | Check if this detector is enabled or | + | needs to be added to the settings list| + \*-------------------------------------*/ + bool this_device_enabled = true; + + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) + { + this_device_enabled = detector_settings["detectors"][detection_string]; + } + + LOG_DEBUG("[%s] %s is %s", DETECTIONMANAGER, detection_string.c_str(), ((this_device_enabled == true) ? "enabled" : "disabled")); + + if(this_device_enabled) + { + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + detector.function(wrapper, current_hid_device, detector.name); + } + } + } + + /*---------------------------------------------*\ + | Update detection percent | + \*---------------------------------------------*/ + hid_device_count++; + + detection_percent = (unsigned int)(100.0f * ((i2c_device_detectors.size() + i2c_dram_device_detectors.size() + i2c_pci_device_detectors.size() + hid_device_count) / detection_percent_denominator)); + + /*---------------------------------------------*\ + | Move on to the next HID device | + \*---------------------------------------------*/ + current_hid_device = current_hid_device->next; + } + + /*-------------------------------------------------*\ + | Done using the device list, free it | + \*-------------------------------------------------*/ + wrapper.hid_free_enumeration(hid_devices); + } +} +#endif +#endif + +void DetectionManager::BackgroundDetectOtherDevices(json detector_settings) +{ + LOG_INFO("------------------------------------------------------"); + LOG_INFO("| Detecting other devices |"); + LOG_INFO("------------------------------------------------------"); + + for(std::size_t detector_idx = 0; detector_idx < device_detectors.size(); detector_idx++) + { + detection_string = device_detector_strings[detector_idx].c_str(); + + /*-------------------------------------------------*\ + | Check if this detector is enabled | + \*-------------------------------------------------*/ + bool this_device_enabled = true; + + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) + { + this_device_enabled = detector_settings["detectors"][detection_string]; + } + + LOG_DEBUG("[%s] %s is %s", DETECTIONMANAGER, detection_string.c_str(), ((this_device_enabled == true) ? "enabled" : "disabled")); + + if(this_device_enabled) + { + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + + device_detectors[detector_idx](); + } + + LOG_TRACE("[%s] %s detection end", DETECTIONMANAGER, detection_string.c_str()); + + /*-------------------------------------------------*\ + | Update detection percent | + \*-------------------------------------------------*/ + unsigned int detection_percent_numerator = detection_percent_i2c_count + + detection_percent_i2c_dram_count + + detection_percent_i2c_pci_count + + detection_percent_hid_count + + detector_idx; + + detection_percent = (unsigned int)(100.0f * (detection_percent_numerator / detection_percent_denominator)); + } +} + +void DetectionManager::BackgroundHidExit() +{ + /*-----------------------------------------------------*\ + | Exit HID interface | + \*-----------------------------------------------------*/ + int hid_status = hid_exit(); + + LOG_DEBUG("[%s] Exiting HID interface: %s", DETECTIONMANAGER, ((hid_status == 0) ? "Success" : "Failed")); +} + +void DetectionManager::BackgroundHidInit() +{ + /*-----------------------------------------------------*\ + | Initialize HID interface | + \*-----------------------------------------------------*/ + int hid_status = hid_init(); + + LOG_DEBUG("[%s] Initializing HID interfaces: %s", DETECTIONMANAGER, ((hid_status == 0) ? "Success" : "Failed")); +} + +/*---------------------------------------------------------*\ +| Detection processing functions | +\*---------------------------------------------------------*/ +void DetectionManager::ProcessCleanup() +{ + WaitForDetection(); + + /*-----------------------------------------------------*\ + | Make a copy of the list so that the controllers can | + | be deleted after the list is cleared | + \*-----------------------------------------------------*/ + std::vector rgb_controllers_copy = rgb_controllers; + + /*-----------------------------------------------------*\ + | Clear the controllers list | + \*-----------------------------------------------------*/ + rgb_controllers.clear(); + + /*-----------------------------------------------------*\ + | Delete the controllers | + \*-----------------------------------------------------*/ + for(RGBController* rgb_controller : rgb_controllers_copy) + { + delete rgb_controller; + } + + /*-----------------------------------------------------*\ + | Make a copy of the list so that the I2C buses can be | + | deleted after the list is cleared | + \*-----------------------------------------------------*/ + std::vector i2c_buses_copy = i2c_buses; + + /*-----------------------------------------------------*\ + | Clear the I2C buses list | + \*-----------------------------------------------------*/ + i2c_buses.clear(); + + /*-----------------------------------------------------*\ + | Delete the I2C buses | + \*-----------------------------------------------------*/ + for(i2c_smbus_interface* bus : i2c_buses_copy) + { + delete bus; + } +} + +void DetectionManager::ProcessDynamicDetectors() +{ + for(std::size_t detector_idx = 0; detector_idx < dynamic_detectors.size(); detector_idx++) + { + dynamic_detectors[detector_idx](); + } + + dynamic_detectors_processed = true; +} + +bool DetectionManager::ProcessPreDetection() +{ + /*-----------------------------------------------------*\ + | Check if detection is already in progress before | + | continuing | + \*-----------------------------------------------------*/ + if(detection_in_progress.load()) + { + return false; + } + + /*-----------------------------------------------------*\ + | Process pre-detection hooks | + \*-----------------------------------------------------*/ + ProcessPreDetectionHooks(); + + /*-----------------------------------------------------*\ + | Process Dynamic Detectors | + \*-----------------------------------------------------*/ + if(!dynamic_detectors_processed) + { + ProcessDynamicDetectors(); + } + + /*-----------------------------------------------------*\ + | Call detection start callbacks | + \*-----------------------------------------------------*/ + LOG_TRACE("[%s] Signaling detection start", DETECTIONMANAGER); + + SignalUpdate(DETECTIONMANAGER_UPDATE_REASON_DETECTION_STARTED); + + /*-----------------------------------------------------*\ + | Update the detector settings | + \*-----------------------------------------------------*/ + UpdateDetectorSettings(); + + /*-----------------------------------------------------*\ + | Initialize sizes list | + \*-----------------------------------------------------*/ + rgb_controllers_sizes = ResourceManager::get()->GetProfileManager()->GetControllerListFromSizes(); + + /*-----------------------------------------------------*\ + | Clean up any existing detected devices | + \*-----------------------------------------------------*/ + ProcessCleanup(); + + return true; +} + +void DetectionManager::ProcessPreDetectionHooks() +{ + for(std::size_t hook_idx = 0; hook_idx < pre_detection_hooks.size(); hook_idx++) + { + pre_detection_hooks[hook_idx](); + } +} + +void DetectionManager::UpdateDetectorSettings() +{ + json detector_settings; + bool save_settings = false; + + /*-----------------------------------------------------*\ + | Open device disable list and read in disabled device | + | strings | + \*-----------------------------------------------------*/ + detector_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Detectors"); + + /*-----------------------------------------------------*\ + | Loop through all I2C detectors and see if any need to | + | be saved to the settings | + \*-----------------------------------------------------*/ + for(std::size_t i2c_detector_idx = 0; i2c_detector_idx < i2c_device_detectors.size(); i2c_detector_idx++) + { + detection_string = i2c_device_detector_strings[i2c_detector_idx].c_str(); + + if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) + { + detector_settings["detectors"][detection_string] = true; + save_settings = true; + } + } + + /*-----------------------------------------------------*\ + | Loop through all I2C DRAM detectors and see if any | + | need to be saved to the settings | + \*-----------------------------------------------------*/ + for(std::size_t i2c_detector_idx = 0; i2c_detector_idx < i2c_dram_device_detectors.size(); i2c_detector_idx++) + { + detection_string = i2c_dram_device_detectors[i2c_detector_idx].name.c_str(); + + if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) + { + detector_settings["detectors"][detection_string] = true; + save_settings = true; + } + } + + /*-----------------------------------------------------*\ + | Loop through all I2C PCI detectors and see if any | + | need to be saved to the settings | + \*-----------------------------------------------------*/ + for(std::size_t i2c_pci_detector_idx = 0; i2c_pci_detector_idx < i2c_pci_device_detectors.size(); i2c_pci_detector_idx++) + { + detection_string = i2c_pci_device_detectors[i2c_pci_detector_idx].name.c_str(); + + if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) + { + detector_settings["detectors"][detection_string] = true; + save_settings = true; + } + } + + /*-----------------------------------------------------*\ + | Loop through all HID detectors and see if any need to | + | be saved to the settings | + \*-----------------------------------------------------*/ + for(std::size_t hid_detector_idx = 0; hid_detector_idx < hid_device_detectors.size(); hid_detector_idx++) + { + detection_string = hid_device_detectors[hid_detector_idx].name.c_str(); + + if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) + { + detector_settings["detectors"][detection_string] = true; + save_settings = true; + } + } + + /*-----------------------------------------------------*\ + | Loop through all HID wrapped detectors and see if any | + | need to be saved to the settings | + \*-----------------------------------------------------*/ + for(std::size_t hid_wrapped_detector_idx = 0; hid_wrapped_detector_idx < hid_wrapped_device_detectors.size(); hid_wrapped_detector_idx++) + { + detection_string = hid_wrapped_device_detectors[hid_wrapped_detector_idx].name.c_str(); + + if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) + { + detector_settings["detectors"][detection_string] = true; + save_settings = true; + } + } + + /*-----------------------------------------------------*\ + | Loop through remaining detectors and see if any need | + | to be saved to the settings | + \*-----------------------------------------------------*/ + for(std::size_t detector_idx = 0; detector_idx < device_detectors.size(); detector_idx++) + { + detection_string = device_detector_strings[detector_idx].c_str(); + + if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) + { + detector_settings["detectors"][detection_string] = true; + save_settings = true; + } + } + + /*-----------------------------------------------------*\ + | If there were any setting changes that need to be | + | saved, set the settings in the settings manager and | + | save them. | + \*-----------------------------------------------------*/ + if(save_settings) + { + LOG_INFO("[%s] Saving detector settings", DETECTIONMANAGER); + + ResourceManager::get()->GetSettingsManager()->SetSettings("Detectors", detector_settings); + + ResourceManager::get()->GetSettingsManager()->SaveSettings(); + } +} + +/*---------------------------------------------------------*\ +| Function for signalling DetectionManager updates to | +| registered callbacks | +\*---------------------------------------------------------*/ +void DetectionManager::SignalUpdate(unsigned int update_reason) +{ + DetectionCallbackMutex.lock(); + + for(std::size_t callback_idx = 0; callback_idx < DetectionCallbacks.size(); callback_idx++) + { + DetectionCallbacks[callback_idx](DetectionCallbackArgs[callback_idx], update_reason); + } + + DetectionCallbackMutex.unlock(); + + LOG_TRACE("[%s] Update signalled: %d.", DETECTIONMANAGER, update_reason); +} + +bool DetectionManager::IsAnyDimmDetectorEnabled(json &detector_settings) +{ + for(std::size_t i2c_detector_idx = 0; i2c_detector_idx < i2c_dram_device_detectors.size(); i2c_detector_idx++) + { + std::string detector_name_string = i2c_dram_device_detectors[i2c_detector_idx].name.c_str(); + /*-------------------------------------------------*\ + | Check if this detector is enabled | + \*-------------------------------------------------*/ + if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detector_name_string) && + detector_settings["detectors"][detector_name_string] == true) + { + return true; + } + } + return false; +} diff --git a/DetectionManager.h b/DetectionManager.h new file mode 100644 index 000000000..3054c3b1a --- /dev/null +++ b/DetectionManager.h @@ -0,0 +1,420 @@ +/*---------------------------------------------------------*\ +| DetectionManager.h | +| | +| OpenRGB Detection Manager handles detecting supported | +| devices and initializing their RGBControllers | +| | +| Adam Honse 08 Jan 2026 | +| | +| This file is part of the OpenRGB project | +| SPDX-License-Identifier: GPL-2.0-or-later | +\*---------------------------------------------------------*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "hidapi_wrapper.h" +#include "i2c_smbus.h" +#include "RGBController.h" +#include "SPDWrapper.h" + +using json = nlohmann::json; + +/*---------------------------------------------------------*\ +| Windows defines "interface" in its headers, stop it | +\*---------------------------------------------------------*/ +#undef interface + +/*---------------------------------------------------------*\ +| HID Default Values | +\*---------------------------------------------------------*/ +#define HID_INTERFACE_ANY -1 +#define HID_USAGE_ANY -1 +#define HID_USAGE_PAGE_ANY -1 + +/*---------------------------------------------------------*\ +| Detector Function Types | +\*---------------------------------------------------------*/ +typedef std::function I2CBusDetectorFunction; +typedef std::function DeviceDetectorFunction; +typedef std::function&)> I2CDeviceDetectorFunction; +typedef std::function&, const std::string&)> I2CDRAMDeviceDetectorFunction; +typedef std::function I2CPCIDeviceDetectorFunction; +typedef std::function HIDDeviceDetectorFunction; +typedef std::function HIDWrappedDeviceDetectorFunction; +typedef std::function DynamicDetectorFunction; +typedef std::function PreDetectionHookFunction; + +/*---------------------------------------------------------*\ +| Detector Block Types | +\*---------------------------------------------------------*/ +class BasicHIDBlock +{ +public: + std::string name; + uint16_t vid; + uint16_t pid; + int interface; + int usage_page; + int usage; + + bool compare(hid_device_info* info); +}; + +class HIDDeviceDetectorBlock : public BasicHIDBlock +{ +public: + HIDDeviceDetectorFunction function; +}; + +class HIDWrappedDeviceDetectorBlock : public BasicHIDBlock +{ +public: + HIDWrappedDeviceDetectorFunction function; +}; + +typedef struct +{ + std::string name; + I2CPCIDeviceDetectorFunction function; + uint16_t ven_id; + uint16_t dev_id; + uint16_t subven_id; + uint16_t subdev_id; + uint8_t i2c_addr; +} I2CPCIDeviceDetectorBlock; + +typedef struct +{ + std::string name; + I2CDRAMDeviceDetectorFunction function; + uint16_t jedec_id; + uint8_t dram_type; +} I2CDRAMDeviceDetectorBlock; + +/*---------------------------------------------------------*\ +| Detection Callback Type | +\*---------------------------------------------------------*/ +typedef void (*DetectionCallback)(void *, unsigned int); + +/*---------------------------------------------------------*\ +| Update Reason Codes | +\*---------------------------------------------------------*/ +enum +{ + DETECTIONMANAGER_UPDATE_REASON_I2C_BUS_REGISTERED, /* RegisterI2CBus() called */ + DETECTIONMANAGER_UPDATE_REASON_RGBCONTROLLER_REGISTERED, /* RegisterRGBController() called */ + DETECTIONMANAGER_UPDATE_REASON_RGBCONTROLLER_UNREGISTERED, /* UnregisterRGBController() called */ + DETECTIONMANAGER_UPDATE_REASON_DETECTION_STARTED, /* Detection started */ + DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED, /* Detection progress changed */ + DETECTIONMANAGER_UPDATE_REASON_DETECTION_COMPLETE, /* Detection completed */ +}; + +/*---------------------------------------------------------*\ +| DetectionManager class | +\*---------------------------------------------------------*/ +class DetectionManager +{ +public: + DetectionManager(); + ~DetectionManager(); + + /*-----------------------------------------------------*\ + | DetectionManager Global Instance Accessor | + \*-----------------------------------------------------*/ + static DetectionManager* get(); + + /*-----------------------------------------------------*\ + | Functions to access device lists | + \*-----------------------------------------------------*/ + std::vector& GetI2CBuses(); + std::vector& GetRGBControllers(); + + /*-----------------------------------------------------*\ + | I2C Bus Detector Registration Function | + \*-----------------------------------------------------*/ + void RegisterI2CBusDetector(I2CBusDetectorFunction detector); + + /*-----------------------------------------------------*\ + | RGBController Detector Registration Functions | + \*-----------------------------------------------------*/ + void RegisterDeviceDetector(std::string name, DeviceDetectorFunction detector); + void RegisterDynamicDetector(std::string name, DynamicDetectorFunction detector); + void RegisterHIDDeviceDetector(std::string name, HIDDeviceDetectorFunction detector, uint16_t vid, uint16_t pid, int interface = HID_INTERFACE_ANY, int usage_page = HID_USAGE_PAGE_ANY, int usage = HID_USAGE_ANY); + void RegisterHIDWrappedDeviceDetector(std::string name, HIDWrappedDeviceDetectorFunction detector, uint16_t vid, uint16_t pid, int interface = HID_INTERFACE_ANY, int usage_page = HID_USAGE_PAGE_ANY, int usage = HID_USAGE_ANY); + void RegisterI2CDeviceDetector(std::string name, I2CDeviceDetectorFunction detector); + void RegisterI2CDRAMDeviceDetector(std::string name, I2CDRAMDeviceDetectorFunction detector, uint16_t jedec_id, uint8_t dram_type); + void RegisterI2CPCIDeviceDetector(std::string name, I2CPCIDeviceDetectorFunction detector, uint16_t ven_id, uint16_t dev_id, uint16_t subven_id, uint16_t subdev_id, uint8_t i2c_addr); + + /*-----------------------------------------------------*\ + | Pre-Detection Hook Function Registration Function | + \*-----------------------------------------------------*/ + void RegisterPreDetectionHook(PreDetectionHookFunction hook); + + /*-----------------------------------------------------*\ + | Detection Callback Registration Functions | + \*-----------------------------------------------------*/ + void RegisterDetectionCallback(DetectionCallback new_callback, void * new_callback_arg); + void UnregisterDetectionCallback(DetectionCallback callback, void *callback_arg); + + /*-----------------------------------------------------*\ + | Functions for registering I2C buses from within | + | detectors | + \*-----------------------------------------------------*/ + void RegisterI2CBus(i2c_smbus_interface *bus); + + /*-----------------------------------------------------*\ + | Functions for registering RGBControllers from within | + | detectors | + \*-----------------------------------------------------*/ + void RegisterRGBController(RGBController *rgb_controller); + void UnregisterRGBController(RGBController *rgb_controller); + + /*-----------------------------------------------------*\ + | Detection state functions | + \*-----------------------------------------------------*/ + void AbortDetection(); + void BeginDetection(); + unsigned int GetDetectionPercent(); + std::string GetDetectionString(); + void WaitForDetection(); + +private: + /*-----------------------------------------------------*\ + | Static pointer to shared instance of DetectionManager | + \*-----------------------------------------------------*/ + static DetectionManager* instance; + + /*-----------------------------------------------------*\ + | List of I2C buses managed by DetectorManager | + \*-----------------------------------------------------*/ + std::vector i2c_buses; + + /*-----------------------------------------------------*\ + | List of RGBControllers managed by DetectorManager | + \*-----------------------------------------------------*/ + std::vector rgb_controllers; + + /*-----------------------------------------------------*\ + | List of manually configured RGBController information | + | from stored sizes profile | + \*-----------------------------------------------------*/ + std::vector rgb_controllers_sizes; + + /*-----------------------------------------------------*\ + | Detectors | + \*-----------------------------------------------------*/ + std::vector device_detectors; + std::vector device_detector_strings; + std::vector i2c_bus_detectors; + std::vector i2c_device_detectors; + std::vector i2c_device_detector_strings; + std::vector i2c_dram_device_detectors; + std::vector i2c_pci_device_detectors; + std::vector hid_device_detectors; + std::vector hid_wrapped_device_detectors; + std::vector dynamic_detectors; + std::vector dynamic_detector_strings; + std::vector pre_detection_hooks; + + /*-----------------------------------------------------*\ + | Detection Callbacks | + \*-----------------------------------------------------*/ + std::vector DetectionCallbacks; + std::vector DetectionCallbackArgs; + std::mutex DetectionCallbackMutex; + + /*-----------------------------------------------------*\ + | Detection State Variables | + \*-----------------------------------------------------*/ + std::mutex DetectDevicesMutex; + std::atomic detection_percent; + unsigned int detection_percent_hid_count; + unsigned int detection_percent_i2c_count; + unsigned int detection_percent_i2c_dram_count; + unsigned int detection_percent_i2c_pci_count; + unsigned int detection_percent_other_count; + unsigned int detection_percent_denominator; + std::vector detection_size_entry_used; + std::string detection_string; + bool dynamic_detectors_processed; + bool initial_detection; + bool i2c_interface_fail; + + /*-----------------------------------------------------*\ + | Background Thread Variables | + \*-----------------------------------------------------*/ + std::thread * BackgroundThread; + std::function BackgroundThreadScheduledFunction; + std::condition_variable BackgroundThreadScheduledFunctionStart; + std::mutex BackgroundThreadStateMutex; + + std::atomic background_thread_running; + std::atomic detection_in_progress; + + /*-----------------------------------------------------*\ + | Background Thread Functions | + \*-----------------------------------------------------*/ + void BackgroundThreadFunction(); + void RunInBackgroundThread(std::function); + + /*-----------------------------------------------------*\ + | Functions that must be run in the background thread | + \*-----------------------------------------------------*/ + void BackgroundDetectDevices(); + void BackgroundDetectHIDDevices(hid_device_info* hid_devices, json detector_settings); + void BackgroundDetectHIDDevicesSafe(json detector_settings); +#ifdef __linux__ +#ifdef __GLIBC__ + void BackgroundDetectHIDDevicesWrapped(hid_device_info* hid_devices, json detector_settings); +#endif +#endif + void BackgroundDetectI2CBuses(); + void BackgroundDetectI2CDevices(json detector_settings); + void BackgroundDetectI2CDRAMDevices(json detector_settings); + void BackgroundDetectI2CPCIDevices(json detector_settings); + void BackgroundDetectOtherDevices(json detector_settings); + void BackgroundHidExit(); + void BackgroundHidInit(); + + /*-----------------------------------------------------*\ + | Detection processing functions | + \*-----------------------------------------------------*/ + void ProcessCleanup(); + void ProcessDynamicDetectors(); + bool ProcessPreDetection(); + void ProcessPreDetectionHooks(); + void UpdateDetectorSettings(); + + /*-----------------------------------------------------*\ + | Function for signalling DetectionManager updates to | + | registered callbacks | + \*-----------------------------------------------------*/ + void SignalUpdate(unsigned int update_reason); + + bool IsAnyDimmDetectorEnabled(json &detector_settings); +}; + +/*---------------------------------------------------------*\ +| Detector Types | +\*---------------------------------------------------------*/ +class DeviceDetector +{ +public: + DeviceDetector(std::string name, DeviceDetectorFunction detector) + { + DetectionManager::get()->RegisterDeviceDetector(name, detector); + } +}; + +class I2CDeviceDetector +{ +public: + I2CDeviceDetector(std::string name, I2CDeviceDetectorFunction detector) + { + DetectionManager::get()->RegisterI2CDeviceDetector(name, detector); + } +}; + +class I2CDRAMDeviceDetector +{ +public: + I2CDRAMDeviceDetector(std::string name, I2CDRAMDeviceDetectorFunction detector, uint16_t jedec_id, uint8_t dram_type) + { + DetectionManager::get()->RegisterI2CDRAMDeviceDetector(name, detector, jedec_id, dram_type); + } +}; + +class I2CPCIDeviceDetector +{ +public: + I2CPCIDeviceDetector(std::string name, I2CPCIDeviceDetectorFunction detector, uint16_t ven_id, uint16_t dev_id, uint16_t subven_id, uint16_t subdev_id, uint8_t i2c_addr) + { + DetectionManager::get()->RegisterI2CPCIDeviceDetector(name, detector, ven_id, dev_id, subven_id, subdev_id, i2c_addr); + } +}; + +class I2CBusDetector +{ +public: + I2CBusDetector(I2CBusDetectorFunction detector) + { + DetectionManager::get()->RegisterI2CBusDetector(detector); + } +}; + +class HIDDeviceDetector +{ +public: + HIDDeviceDetector(std::string name, HIDDeviceDetectorFunction detector, uint16_t vid, uint16_t pid, int interface, int usage_page, int usage) + { + DetectionManager::get()->RegisterHIDDeviceDetector(name, detector, vid, pid, interface, usage_page, usage); + } +}; + +class HIDWrappedDeviceDetector +{ +public: + HIDWrappedDeviceDetector(std::string name, HIDWrappedDeviceDetectorFunction detector, uint16_t vid, uint16_t pid, int interface, int usage_page, int usage) + { + DetectionManager::get()->RegisterHIDWrappedDeviceDetector(name, detector, vid, pid, interface, usage_page, usage); + } +}; + +class DynamicDetector +{ +public: + DynamicDetector(std::string name, DynamicDetectorFunction detector) + { + DetectionManager::get()->RegisterDynamicDetector(name, detector); + } +}; + +class PreDetectionHook +{ +public: + PreDetectionHook(PreDetectionHookFunction hook) + { + DetectionManager::get()->RegisterPreDetectionHook(hook); + } +}; + +/*---------------------------------------------------------*\ +| Detector Registration Macros | +\*---------------------------------------------------------*/ +#define REGISTER_DETECTOR(name, func) static DeviceDetector device_detector_obj_##func(name, func) +#define REGISTER_I2C_DETECTOR(name, func) static I2CDeviceDetector device_detector_obj_##func(name, func) +#define REGISTER_I2C_DRAM_DETECTOR(name, func, jedec_id, dram_type) static I2CDRAMDeviceDetector device_detector_obj_##func##jedec_id(name, func, jedec_id, dram_type) +#define REGISTER_I2C_PCI_DETECTOR(name, func, ven, dev, subven, subdev, addr) static I2CPCIDeviceDetector device_detector_obj_##ven##dev##subven##subdev##addr##func(name, func, ven, dev, subven, subdev, addr) +#define REGISTER_I2C_BUS_DETECTOR(func) static I2CBusDetector device_detector_obj_##func(func) +#define REGISTER_HID_DETECTOR(name, func, vid, pid) static HIDDeviceDetector device_detector_obj_##vid##pid(name, func, vid, pid, HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) +#define REGISTER_HID_DETECTOR_I(name, func, vid, pid, interface) static HIDDeviceDetector device_detector_obj_##vid##pid##_##interface(name, func, vid, pid, interface, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) +#define REGISTER_HID_DETECTOR_IP(name, func, vid, pid, interface, page) static HIDDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page(name, func, vid, pid, interface, page, HID_USAGE_ANY) +#define REGISTER_HID_DETECTOR_IPU(name, func, vid, pid, interface, page, usage) static HIDDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page##_##usage(name, func, vid, pid, interface, page, usage) +#define REGISTER_HID_DETECTOR_P(name, func, vid, pid, page) static HIDDeviceDetector device_detector_obj_##vid##pid##__##page(name, func, vid, pid, HID_INTERFACE_ANY, page, HID_USAGE_ANY) +#define REGISTER_HID_DETECTOR_PU(name, func, vid, pid, page, usage) static HIDDeviceDetector device_detector_obj_##vid##pid##__##page##_##usage(name, func, vid, pid, HID_INTERFACE_ANY, page, usage) +#define REGISTER_HID_WRAPPED_DETECTOR(name, func, vid, pid) static HIDWrappedDeviceDetector device_detector_obj_##vid##pid(name, func, vid, pid, HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) +#define REGISTER_HID_WRAPPED_DETECTOR_I(name, func, vid, pid, interface) static HIDWrappedDeviceDetector device_detector_obj_##vid##pid##_##interface(name, func, vid, pid, interface, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) +#define REGISTER_HID_WRAPPED_DETECTOR_IPU(name, func, vid, pid, interface, page, usage) static HIDWrappedDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page##_##usage(name, func, vid, pid, interface, page, usage) +#define REGISTER_HID_WRAPPED_DETECTOR_PU(name, func, vid, pid, page, usage) static HIDWrappedDeviceDetector device_detector_obj_##vid##pid##__##page##_##usage(name, func, vid, pid, HID_INTERFACE_ANY, page, usage) +#define REGISTER_DYNAMIC_DETECTOR(name, func) static DynamicDetector device_detector_obj_##func(name, func) +#define REGISTER_PRE_DETECTION_HOOK(func) static PreDetectionHook device_detector_obj_##func(func) + +#define REGISTER_DYNAMIC_I2C_DETECTOR(name, func) I2CDeviceDetector device_detector_obj_##func(name, func) +#define REGISTER_DYNAMIC_I2C_DRAM_DETECTOR(name, func, jedec_id, dram_type) I2CDRAMDeviceDetector device_detector_obj_##func(name, func, jedec_id, dram_type) +#define REGISTER_DYNAMIC_I2C_PCI_DETECTOR(name, func, ven, dev, subven, subdev, addr) I2CPCIDeviceDetector device_detector_obj_##ven##dev##subven##subdev##addr##func(name, func, ven, dev, subven, subdev, addr) +#define REGISTER_DYNAMIC_I2C_BUS_DETECTOR(func) I2CBusDetector device_detector_obj_##func(func) +#define REGISTER_DYNAMIC_HID_DETECTOR(name, func, vid, pid) HIDDeviceDetector device_detector_obj_##vid##pid(name, func, vid, pid, HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) +#define REGISTER_DYNAMIC_HID_DETECTOR_I(name, func, vid, pid, interface) HIDDeviceDetector device_detector_obj_##vid##pid##_##interface(name, func, vid, pid, interface, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) +#define REGISTER_DYNAMIC_HID_DETECTOR_IP(name, func, vid, pid, interface, page) HIDDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page(name, func, vid, pid, interface, page, HID_USAGE_ANY) +#define REGISTER_DYNAMIC_HID_DETECTOR_IPU(name, func, vid, pid, interface, page, usage) HIDDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page##_##usage(name, func, vid, pid, interface, page, usage) +#define REGISTER_DYNAMIC_HID_DETECTOR_P(name, func, vid, pid, page) HIDDeviceDetector device_detector_obj_##vid##pid##__##page(name, func, vid, pid, HID_INTERFACE_ANY, page, HID_USAGE_ANY) +#define REGISTER_DYNAMIC_HID_DETECTOR_PU(name, func, vid, pid, page, usage) HIDDeviceDetector device_detector_obj_##vid##pid##__##page##_##usage(name, func, vid, pid, HID_INTERFACE_ANY, page, usage) diff --git a/Detector.h b/Detector.h deleted file mode 100644 index f29573f22..000000000 --- a/Detector.h +++ /dev/null @@ -1,41 +0,0 @@ -/*---------------------------------------------------------*\ -| Detector.h | -| | -| Macros for registering detectors | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#pragma once - -#include "DeviceDetector.h" - -#define REGISTER_DETECTOR(name, func) static DeviceDetector device_detector_obj_##func(name, func) -#define REGISTER_I2C_DETECTOR(name, func) static I2CDeviceDetector device_detector_obj_##func(name, func) -#define REGISTER_I2C_DIMM_DETECTOR(name, func, jedec_id, dimm_type) static I2CDIMMDeviceDetector device_detector_obj_##func##jedec_id(name, func, jedec_id, dimm_type) -#define REGISTER_I2C_PCI_DETECTOR(name, func, ven, dev, subven, subdev, addr) static I2CPCIDeviceDetector device_detector_obj_##ven##dev##subven##subdev##addr##func(name, func, ven, dev, subven, subdev, addr) -#define REGISTER_I2C_BUS_DETECTOR(func) static I2CBusDetector device_detector_obj_##func(func) -#define REGISTER_HID_DETECTOR(name, func, vid, pid) static HIDDeviceDetector device_detector_obj_##vid##pid(name, func, vid, pid, HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) -#define REGISTER_HID_DETECTOR_I(name, func, vid, pid, interface) static HIDDeviceDetector device_detector_obj_##vid##pid##_##interface(name, func, vid, pid, interface, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) -#define REGISTER_HID_DETECTOR_IP(name, func, vid, pid, interface, page) static HIDDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page(name, func, vid, pid, interface, page, HID_USAGE_ANY) -#define REGISTER_HID_DETECTOR_IPU(name, func, vid, pid, interface, page, usage) static HIDDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page##_##usage(name, func, vid, pid, interface, page, usage) -#define REGISTER_HID_DETECTOR_P(name, func, vid, pid, page) static HIDDeviceDetector device_detector_obj_##vid##pid##__##page(name, func, vid, pid, HID_INTERFACE_ANY, page, HID_USAGE_ANY) -#define REGISTER_HID_DETECTOR_PU(name, func, vid, pid, page, usage) static HIDDeviceDetector device_detector_obj_##vid##pid##__##page##_##usage(name, func, vid, pid, HID_INTERFACE_ANY, page, usage) -#define REGISTER_HID_WRAPPED_DETECTOR(name, func, vid, pid) static HIDWrappedDeviceDetector device_detector_obj_##vid##pid(name, func, vid, pid, HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) -#define REGISTER_HID_WRAPPED_DETECTOR_I(name, func, vid, pid, interface) static HIDWrappedDeviceDetector device_detector_obj_##vid##pid##_##interface(name, func, vid, pid, interface, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) -#define REGISTER_HID_WRAPPED_DETECTOR_IPU(name, func, vid, pid, interface, page, usage) static HIDWrappedDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page##_##usage(name, func, vid, pid, interface, page, usage) -#define REGISTER_HID_WRAPPED_DETECTOR_PU(name, func, vid, pid, page, usage) static HIDWrappedDeviceDetector device_detector_obj_##vid##pid##__##page##_##usage(name, func, vid, pid, HID_INTERFACE_ANY, page, usage) -#define REGISTER_DYNAMIC_DETECTOR(name, func) static DynamicDetector device_detector_obj_##func(name, func) -#define REGISTER_PRE_DETECTION_HOOK(func) static PreDetectionHook device_detector_obj_##func(func) - -#define REGISTER_DYNAMIC_I2C_DETECTOR(name, func) I2CDeviceDetector device_detector_obj_##func(name, func) -#define REGISTER_DYNAMIC_I2C_DIMM_DETECTOR(name, func, jedec_id, dimm_type) I2CDIMMDeviceDetector device_detector_obj_##func(name, func, jedec_id, dimm_type) -#define REGISTER_DYNAMIC_I2C_PCI_DETECTOR(name, func, ven, dev, subven, subdev, addr) I2CPCIDeviceDetector device_detector_obj_##ven##dev##subven##subdev##addr##func(name, func, ven, dev, subven, subdev, addr) -#define REGISTER_DYNAMIC_I2C_BUS_DETECTOR(func) I2CBusDetector device_detector_obj_##func(func) -#define REGISTER_DYNAMIC_HID_DETECTOR(name, func, vid, pid) HIDDeviceDetector device_detector_obj_##vid##pid(name, func, vid, pid, HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) -#define REGISTER_DYNAMIC_HID_DETECTOR_I(name, func, vid, pid, interface) HIDDeviceDetector device_detector_obj_##vid##pid##_##interface(name, func, vid, pid, interface, HID_USAGE_PAGE_ANY, HID_USAGE_ANY) -#define REGISTER_DYNAMIC_HID_DETECTOR_IP(name, func, vid, pid, interface, page) HIDDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page(name, func, vid, pid, interface, page, HID_USAGE_ANY) -#define REGISTER_DYNAMIC_HID_DETECTOR_IPU(name, func, vid, pid, interface, page, usage) HIDDeviceDetector device_detector_obj_##vid##pid##_##interface##_##page##_##usage(name, func, vid, pid, interface, page, usage) -#define REGISTER_DYNAMIC_HID_DETECTOR_P(name, func, vid, pid, page) HIDDeviceDetector device_detector_obj_##vid##pid##__##page(name, func, vid, pid, HID_INTERFACE_ANY, page, HID_USAGE_ANY) -#define REGISTER_DYNAMIC_HID_DETECTOR_PU(name, func, vid, pid, page, usage) HIDDeviceDetector device_detector_obj_##vid##pid##__##page##_##usage(name, func, vid, pid, HID_INTERFACE_ANY, page, usage) diff --git a/DeviceDetector.h b/DeviceDetector.h deleted file mode 100644 index 4d478105a..000000000 --- a/DeviceDetector.h +++ /dev/null @@ -1,97 +0,0 @@ -/*---------------------------------------------------------*\ -| DeviceDetector.h | -| | -| Device detector functionality | -| | -| This file is part of the OpenRGB project | -| SPDX-License-Identifier: GPL-2.0-or-later | -\*---------------------------------------------------------*/ - -#pragma once - -#include -#include -#include - -#include "ResourceManager.h" - -class DeviceDetector -{ -public: - DeviceDetector(std::string name, DeviceDetectorFunction detector) - { - ResourceManager::get()->RegisterDeviceDetector(name, detector); - } -}; - -class I2CDeviceDetector -{ -public: - I2CDeviceDetector(std::string name, I2CDeviceDetectorFunction detector) - { - ResourceManager::get()->RegisterI2CDeviceDetector(name, detector); - } -}; - -class I2CDIMMDeviceDetector -{ -public: - I2CDIMMDeviceDetector(std::string name, I2CDIMMDeviceDetectorFunction detector, uint16_t jedec_id, uint8_t dimm_type) - { - ResourceManager::get()->RegisterI2CDIMMDeviceDetector(name, detector, jedec_id, dimm_type); - } -}; - -class I2CPCIDeviceDetector -{ -public: - I2CPCIDeviceDetector(std::string name, I2CPCIDeviceDetectorFunction detector, uint16_t ven_id, uint16_t dev_id, uint16_t subven_id, uint16_t subdev_id, uint8_t i2c_addr) - { - ResourceManager::get()->RegisterI2CPCIDeviceDetector(name, detector, ven_id, dev_id, subven_id, subdev_id, i2c_addr); - } -}; - -class I2CBusDetector -{ -public: - I2CBusDetector(I2CBusDetectorFunction detector) - { - ResourceManager::get()->RegisterI2CBusDetector(detector); - } -}; - -class HIDDeviceDetector -{ -public: - HIDDeviceDetector(std::string name, HIDDeviceDetectorFunction detector, uint16_t vid, uint16_t pid, int interface, int usage_page, int usage) - { - ResourceManager::get()->RegisterHIDDeviceDetector(name, detector, vid, pid, interface, usage_page, usage); - } -}; - -class HIDWrappedDeviceDetector -{ -public: - HIDWrappedDeviceDetector(std::string name, HIDWrappedDeviceDetectorFunction detector, uint16_t vid, uint16_t pid, int interface, int usage_page, int usage) - { - ResourceManager::get()->RegisterHIDWrappedDeviceDetector(name, detector, vid, pid, interface, usage_page, usage); - } -}; - -class DynamicDetector -{ -public: - DynamicDetector(std::string name, DynamicDetectorFunction detector) - { - ResourceManager::get()->RegisterDynamicDetector(name, detector); - } -}; - -class PreDetectionHook -{ -public: - PreDetectionHook(PreDetectionHookFunction hook) - { - ResourceManager::get()->RegisterPreDetectionHook(hook); - } -}; diff --git a/OpenRGB.pro b/OpenRGB.pro index 4a4fd8a37..b4792725d 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -183,8 +183,7 @@ HEADERS += ResourceManager.h \ ResourceManagerInterface.h \ SettingsManager.h \ - Detector.h \ - DeviceDetector.h \ + DetectionManager.h \ dmiinfo/dmiinfo.h \ filesystem.h \ hidapi_wrapper/hidapi_wrapper.h \ @@ -244,6 +243,7 @@ SOURCES += dependencies/hueplusplus-1.2.0/src/ZLLSensors.cpp \ startup/startup.cpp \ cli.cpp \ + DetectionManager.cpp \ dmiinfo/dmiinfo.cpp \ LogManager.cpp \ NetworkClient.cpp \ diff --git a/RGBController/RGBController.h b/RGBController/RGBController.h index 5b92e5658..b5e17ea99 100644 --- a/RGBController/RGBController.h +++ b/RGBController/RGBController.h @@ -753,6 +753,7 @@ private: | Certain internal OpenRGB framework classes can modify | | protected members | \*-----------------------------------------------------*/ + friend class DetectionManager; friend class NetworkClient; friend class NetworkServer; friend class ProfileManager; diff --git a/ResourceManager.cpp b/ResourceManager.cpp index 7d027f86a..114e2fa26 100644 --- a/ResourceManager.cpp +++ b/ResourceManager.cpp @@ -18,9 +18,8 @@ #include #include -#include #include "cli.h" -#include "pci_ids/pci_ids.h" +#include "DetectionManager.h" #include "ResourceManager.h" #include "ProfileManager.h" #include "LogManager.h" @@ -28,92 +27,61 @@ #include "NetworkClient.h" #include "NetworkServer.h" #include "filesystem.h" -#include "StringUtils.h" - -/*---------------------------------------------------------*\ -| Translation Strings | -\*---------------------------------------------------------*/ -const char* I2C_ERR_WIN = QT_TRANSLATE_NOOP("ResourceManager", - "

Some internal devices may not be detected:

" - "

One or more I2C or SMBus interfaces failed to initialize.

" - "

RGB DRAM modules, some motherboards' onboard RGB lighting, and RGB Graphics Cards, will not be available in OpenRGB without I2C or SMBus.

" - "

How to fix this:

" - "

On Windows, this is usually caused by a failure to load the PawnIO driver.

" - "

You must first install PawnIO, then you must OpenRGB as administrator in order to access these devices.

" - "

See help.openrgb.org for additional troubleshooting steps if you keep seeing this message.

" - "

If you are not using internal RGB on a desktop this message is not important to you.

"); -const char* I2C_ERR_LINUX = QT_TRANSLATE_NOOP("ResourceManager", - "

Some internal devices may not be detected:

" - "

One or more I2C or SMBus interfaces failed to initialize.

" - "

RGB DRAM modules, some motherboards' onboard RGB lighting, and RGB Graphics Cards, will not be available in OpenRGB without I2C or SMBus.

" - "

How to fix this:

" - "

On Linux, this is usually because the i2c-dev module is not loaded.

" - "

You must load the i2c-dev module along with the correct i2c driver for your motherboard. " - "This is usually i2c-piix4 for AMD systems and i2c-i801 for Intel systems.

" - "

See help.openrgb.org for additional troubleshooting steps if you keep seeing this message.

" - "

If you are not using internal RGB on a desktop this message is not important to you.

"); - -const char* UDEV_MISSING = QT_TRANSLATE_NOOP("ResourceManager", - "

WARNING:

" - "

The OpenRGB udev rules are not installed.

" - "

Most devices will not be available unless running OpenRGB as root.

" - "

If using AppImage, Flatpak, or self-compiled versions of OpenRGB you must install the udev rules manually

" - "

See https://openrgb.org/udev to install the udev rules manually

"); -const char* UDEV_MUTLI = QT_TRANSLATE_NOOP("ResourceManager", - "

WARNING:

" - "

Multiple OpenRGB udev rules are installed.

" - "

The udev rules file 60-openrgb.rules is installed in both /etc/udev/rules.d and /usr/lib/udev/rules.d.

" - "

Multiple udev rules files can conflict, it is recommended to remove one of them.

"); - - -const hidapi_wrapper default_wrapper = -{ - NULL, - (hidapi_wrapper_send_feature_report) hid_send_feature_report, - (hidapi_wrapper_get_feature_report) hid_get_feature_report, - (hidapi_wrapper_get_serial_number_string) hid_get_serial_number_string, - (hidapi_wrapper_open_path) hid_open_path, - (hidapi_wrapper_enumerate) hid_enumerate, - (hidapi_wrapper_free_enumeration) hid_free_enumeration, - (hidapi_wrapper_close) hid_close, - (hidapi_wrapper_error) hid_error -}; - -bool BasicHIDBlock::compare(hid_device_info* info) -{ - return ( (vid == info->vendor_id) - && (pid == info->product_id) -#ifdef USE_HID_USAGE - && ( (usage_page == HID_USAGE_PAGE_ANY) - || (usage_page == info->usage_page) ) - && ( (usage == HID_USAGE_ANY) - || (usage == info->usage) ) - && ( (interface == HID_INTERFACE_ANY) - || (interface == info->interface_number ) ) -#else - && ( (interface == HID_INTERFACE_ANY) - || (interface == info->interface_number ) ) -#endif - ); -} - -ResourceManager* ResourceManager::instance; using namespace std::chrono_literals; -ResourceManager *ResourceManager::get() +/*---------------------------------------------------------*\ +| ResourceManager Callback Functions | +\*---------------------------------------------------------*/ +static void ResourceManagerDetectionCallback(void * this_ptr, unsigned int update_reason) { - /*-----------------------------------------------------*\ - | If ResourceManager does not exist yet, create it | - \*-----------------------------------------------------*/ - if(!instance) - { - instance = new ResourceManager(); - } + ResourceManager* this_obj = (ResourceManager *)this_ptr; - return instance; + switch(update_reason) + { + case DETECTIONMANAGER_UPDATE_REASON_I2C_BUS_REGISTERED: + this_obj->SignalResourceManagerUpdate(RESOURCEMANAGER_UPDATE_REASON_I2C_BUS_LIST_UPDATED); + break; + + case DETECTIONMANAGER_UPDATE_REASON_DETECTION_STARTED: + this_obj->SignalResourceManagerUpdate(RESOURCEMANAGER_UPDATE_REASON_DETECTION_STARTED); + this_obj->ClearLocalDevices(); + break; + + case DETECTIONMANAGER_UPDATE_REASON_RGBCONTROLLER_REGISTERED: + case DETECTIONMANAGER_UPDATE_REASON_RGBCONTROLLER_UNREGISTERED: + this_obj->UpdateDeviceList(); + break; + + case DETECTIONMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED: + this_obj->SignalResourceManagerUpdate(RESOURCEMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED); + break; + + case DETECTIONMANAGER_UPDATE_REASON_DETECTION_COMPLETE: + this_obj->SignalResourceManagerUpdate(RESOURCEMANAGER_UPDATE_REASON_DETECTION_COMPLETE); + this_obj->UpdateDeviceList(); + break; + } } +static void ResourceManagerNetworkClientInfoChangeCallback(void* this_ptr) +{ + ResourceManager* this_obj = (ResourceManager*)this_ptr; + + this_obj->SignalResourceManagerUpdate(RESOURCEMANAGER_UPDATE_REASON_CLIENT_INFO_UPDATED); + this_obj->UpdateDeviceList(); +} + +/*---------------------------------------------------------*\ +| ResourceManager name for log entries | +\*---------------------------------------------------------*/ +const char* RESOURCEMANAGER = "ResourceManager"; + +/*---------------------------------------------------------*\ +| ResourceManager Global Instance Pointer | +\*---------------------------------------------------------*/ +ResourceManager* ResourceManager::instance; + ResourceManager::ResourceManager() { /*-----------------------------------------------------*\ @@ -141,21 +109,9 @@ ResourceManager::ResourceManager() auto_connection_client = NULL; auto_connection_active = false; detection_enabled = true; - detection_percent = 100; - detection_string = ""; - detection_is_required = false; - dynamic_detectors_processed = false; init_finished = false; - initial_detection = true; - background_thread_running = true; plugin_manager = NULL; - /*-----------------------------------------------------*\ - | Start the background detection thread in advance; it | - | will be suspended until necessary | - \*-----------------------------------------------------*/ - DetectDevicesThread = new std::thread(&ResourceManager::BackgroundThreadFunction, this); - SetupConfigurationDirectory(); /*-----------------------------------------------------*\ @@ -191,7 +147,7 @@ ResourceManager::ResourceManager() } else { - server = new NetworkServer(rgb_controllers_hw); + server = new NetworkServer(DetectionManager::get()->GetRGBControllers()); } /*-----------------------------------------------------*\ @@ -221,112 +177,55 @@ ResourceManager::ResourceManager() \*-----------------------------------------------------*/ profile_manager = new ProfileManager(GetConfigurationDirectory()); server->SetProfileManager(profile_manager); - rgb_controllers_sizes = profile_manager->GetControllerListFromSizes(); } ResourceManager::~ResourceManager() { - Cleanup(); - /*-----------------------------------------------------*\ - | Mark the background detection thread as not running | - | and then wake it up so it knows that it has to stop | - \*-----------------------------------------------------*/ - background_thread_running = false; - BackgroundFunctionStartTrigger.notify_one(); - - /*-----------------------------------------------------*\ - | Stop the background thread | - \*-----------------------------------------------------*/ - if(DetectDevicesThread) - { - DetectDevicesThread->join(); - delete DetectDevicesThread; - DetectDevicesThread = nullptr; - } } -void ResourceManager::RegisterI2CBus(i2c_smbus_interface *bus) +/*---------------------------------------------------------*\ +| ResourceManager Global Instance Accessor | +\*---------------------------------------------------------*/ +ResourceManager* ResourceManager::get() { - LOG_INFO("[ResourceManager] Registering I2C interface: %s Device %04X:%04X Subsystem: %04X:%04X", bus->device_name, bus->pci_vendor, bus->pci_device,bus->pci_subsystem_vendor,bus->pci_subsystem_device); - busses.push_back(bus); + /*-----------------------------------------------------*\ + | If ResourceManager does not exist yet, create it | + \*-----------------------------------------------------*/ + if(!instance) + { + instance = new ResourceManager(); + } + + return instance; +} + +/*---------------------------------------------------------*\ +| Resource Accessors | +\*---------------------------------------------------------*/ +std::vector& ResourceManager::GetClients() +{ + return(clients); +} + +filesystem::path ResourceManager::GetConfigurationDirectory() +{ + return(config_dir); } std::vector & ResourceManager::GetI2CBusses() { - return busses; + return DetectionManager::get()->GetI2CBuses(); } -void ResourceManager::RegisterRGBController(RGBController *rgb_controller) +PluginManagerInterface* ResourceManager::GetPluginManager() { - /*-----------------------------------------------------*\ - | Mark this controller as locally owned | - \*-----------------------------------------------------*/ - rgb_controller->flags &= ~CONTROLLER_FLAG_REMOTE; - rgb_controller->flags |= CONTROLLER_FLAG_LOCAL; - - LOG_INFO("[%s] Registering RGB controller", rgb_controller->GetName().c_str()); - rgb_controllers_hw.push_back(rgb_controller); - - /*-----------------------------------------------------*\ - | If the device list size has changed, call the device | - | list changed callbacks | - | | - | TODO: If all detection is reworked to use | - | RegisterRGBController, tracking of previous list size | - | can be removed and profile can be loaded per | - | controller before adding to list | - \*-----------------------------------------------------*/ - if(rgb_controllers_hw.size() != detection_prev_size) - { - /*-------------------------------------------------*\ - | First, load sizes for the new controllers | - \*-------------------------------------------------*/ - for(unsigned int controller_size_idx = detection_prev_size; controller_size_idx < rgb_controllers_hw.size(); controller_size_idx++) - { - profile_manager->LoadControllerFromListWithOptions(rgb_controllers_sizes, detection_size_entry_used, rgb_controllers_hw[controller_size_idx], true, false); - } - - UpdateDeviceList(); - } - - detection_prev_size = (unsigned int)rgb_controllers_hw.size(); - - UpdateDeviceList(); + return(plugin_manager); } -void ResourceManager::UnregisterRGBController(RGBController* rgb_controller) +ProfileManager* ResourceManager::GetProfileManager() { - LOG_INFO("[%s] Unregistering RGB controller", rgb_controller->GetName().c_str()); - - /*-----------------------------------------------------*\ - | Clear callbacks from the controller before removal | - \*-----------------------------------------------------*/ - rgb_controller->ClearCallbacks(); - - /*-----------------------------------------------------*\ - | Find the controller to remove and remove it from the | - | hardware list | - \*-----------------------------------------------------*/ - std::vector::iterator hw_it = std::find(rgb_controllers_hw.begin(), rgb_controllers_hw.end(), rgb_controller); - - if (hw_it != rgb_controllers_hw.end()) - { - rgb_controllers_hw.erase(hw_it); - } - - /*-----------------------------------------------------*\ - | Find the controller to remove and remove it from the | - | master list | - \*-----------------------------------------------------*/ - std::vector::iterator rgb_it = std::find(rgb_controllers.begin(), rgb_controllers.end(), rgb_controller); - - if (rgb_it != rgb_controllers.end()) - { - rgb_controllers.erase(rgb_it); - } - - UpdateDeviceList(); + return(profile_manager); } std::vector & ResourceManager::GetRGBControllers() @@ -334,221 +233,224 @@ std::vector & ResourceManager::GetRGBControllers() return rgb_controllers; } -void ResourceManager::RegisterI2CBusDetector(I2CBusDetectorFunction detector) +NetworkServer* ResourceManager::GetServer() { - i2c_bus_detectors.push_back(detector); + return(server); } -void ResourceManager::RegisterI2CDeviceDetector(std::string name, I2CDeviceDetectorFunction detector) +SettingsManager* ResourceManager::GetSettingsManager() { - i2c_device_detector_strings.push_back(name); - i2c_device_detectors.push_back(detector); + return(settings_manager); } -void ResourceManager::RegisterI2CDIMMDeviceDetector(std::string name, I2CDIMMDeviceDetectorFunction detector, uint16_t jedec_id, uint8_t dimm_type) +void ResourceManager::SetConfigurationDirectory(const filesystem::path &directory) { - I2CDIMMDeviceDetectorBlock block; - - block.name = name; - block.function = detector; - block.jedec_id = jedec_id; - block.dimm_type = dimm_type; - - i2c_dimm_device_detectors.push_back(block); + config_dir = directory; + settings_manager->LoadSettings(directory / "OpenRGB.json"); + profile_manager->SetConfigurationDirectory(directory); } -void ResourceManager::RegisterI2CPCIDeviceDetector(std::string name, I2CPCIDeviceDetectorFunction detector, uint16_t ven_id, uint16_t dev_id, uint16_t subven_id, uint16_t subdev_id, uint8_t i2c_addr) +void ResourceManager::SetPluginManager(PluginManagerInterface* plugin_manager_ptr) { - I2CPCIDeviceDetectorBlock block; - - block.name = name; - block.function = detector; - block.ven_id = ven_id; - block.dev_id = dev_id; - block.subven_id = subven_id; - block.subdev_id = subdev_id; - block.i2c_addr = i2c_addr; - - i2c_pci_device_detectors.push_back(block); + plugin_manager = plugin_manager_ptr; + server->SetPluginManager(plugin_manager); } -void ResourceManager::RegisterDeviceDetector(std::string name, DeviceDetectorFunction detector) +/*---------------------------------------------------------*\ +| Network Client Registration | +\*---------------------------------------------------------*/ +void ResourceManager::RegisterNetworkClient(NetworkClient* new_client) { - device_detector_strings.push_back(name); - device_detectors.push_back(detector); + new_client->RegisterClientInfoChangeCallback(ResourceManagerNetworkClientInfoChangeCallback, this); + + clients.push_back(new_client); } -void ResourceManager::RegisterHIDDeviceDetector(std::string name, - HIDDeviceDetectorFunction detector, - uint16_t vid, - uint16_t pid, - int interface, - int usage_page, - int usage) +void ResourceManager::UnregisterNetworkClient(NetworkClient* network_client) { - HIDDeviceDetectorBlock block; + /*-----------------------------------------------------*\ + | Stop the disconnecting client | + \*-----------------------------------------------------*/ + network_client->StopClient(); - block.name = name; - block.vid = vid; - block.pid = pid; - block.function = detector; - block.interface = interface; - block.usage_page = usage_page; - block.usage = usage; + /*-----------------------------------------------------*\ + | Clear callbacks from the client before removal | + \*-----------------------------------------------------*/ + network_client->ClearCallbacks(); - hid_device_detectors.push_back(block); -} + /*-----------------------------------------------------*\ + | Find the client to remove and remove it from the | + | clients list | + \*-----------------------------------------------------*/ + std::vector::iterator client_it = std::find(clients.begin(), clients.end(), network_client); -void ResourceManager::RegisterHIDWrappedDeviceDetector(std::string name, - HIDWrappedDeviceDetectorFunction detector, - uint16_t vid, - uint16_t pid, - int interface, - int usage_page, - int usage) -{ - HIDWrappedDeviceDetectorBlock block; - - block.name = name; - block.vid = vid; - block.pid = pid; - block.function = detector; - block.interface = interface; - block.usage_page = usage_page; - block.usage = usage; - - hid_wrapped_device_detectors.push_back(block); -} - -void ResourceManager::RegisterDynamicDetector(std::string name, DynamicDetectorFunction detector) -{ - dynamic_detector_strings.push_back(name); - dynamic_detectors.push_back(detector); -} - -void ResourceManager::RegisterPreDetectionHook(PreDetectionHookFunction hook) -{ - pre_detection_hooks.push_back(hook); -} - -void ResourceManager::RegisterClientInfoChangeCallback(ClientInfoChangeCallback new_callback, void * new_callback_arg) -{ - ClientInfoChangeCallbacks.push_back(new_callback); - ClientInfoChangeCallbackArgs.push_back(new_callback_arg); - - LOG_TRACE("[ResourceManager] Registered client info change callback. Total callbacks registered: %d", ClientInfoChangeCallbacks.size()); -} - -void ResourceManager::UnregisterClientInfoChangeCallback(ClientInfoChangeCallback callback, void * callback_arg) -{ - for(size_t idx = 0; idx < ClientInfoChangeCallbacks.size(); idx++) + if(client_it != clients.end()) { - if(ClientInfoChangeCallbacks[idx] == callback && ClientInfoChangeCallbackArgs[idx] == callback_arg) + clients.erase(client_it); + } + + /*-----------------------------------------------------*\ + | Delete the client | + \*-----------------------------------------------------*/ + delete network_client; + + UpdateDeviceList(); +} + +/*---------------------------------------------------------*\ +| Local Client Accessors | +\*---------------------------------------------------------*/ +NetworkClient* ResourceManager::GetLocalClient() +{ + return(auto_connection_client); +} + +unsigned int ResourceManager::GetLocalClientProtocolVersion() +{ + return(auto_connection_client->GetProtocolVersion()); +} + +bool ResourceManager::IsLocalClient() +{ + return(auto_connection_active); +} + +/*---------------------------------------------------------*\ +| Callback Registration Functions | +\*---------------------------------------------------------*/ +void ResourceManager::RegisterResourceManagerCallback(ResourceManagerCallback new_callback, void * new_callback_arg) +{ + ResourceManagerCallbackMutex.lock(); + + for(size_t idx = 0; idx < ResourceManagerCallbacks.size(); idx++) + { + if(ResourceManagerCallbacks[idx] == new_callback && ResourceManagerCallbackArgs[idx] == new_callback_arg) { - ClientInfoChangeCallbacks.erase(ClientInfoChangeCallbacks.begin() + idx); - ClientInfoChangeCallbackArgs.erase(ClientInfoChangeCallbackArgs.begin() + idx); + ResourceManagerCallbackMutex.unlock(); + + LOG_TRACE("[%s] Tried to register an already registered ResourceManager callback, skipping. Total callbacks registered: %d", RESOURCEMANAGER, ResourceManagerCallbacks.size()); + + return; } } - LOG_TRACE("[ResourceManager] Unregistered client info change callback. Total callbacks registered: %d", ClientInfoChangeCallbacks.size()); + ResourceManagerCallbacks.push_back(new_callback); + ResourceManagerCallbackArgs.push_back(new_callback_arg); + + ResourceManagerCallbackMutex.unlock(); + + LOG_TRACE("[%s] Registered ResourceManager callback. Total callbacks registered: %d", RESOURCEMANAGER, ResourceManagerCallbacks.size()); } -void ResourceManager::RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg) +void ResourceManager::UnregisterResourceManagerCallback(ResourceManagerCallback callback, void * callback_arg) { - DeviceListChangeCallbacks.push_back(new_callback); - DeviceListChangeCallbackArgs.push_back(new_callback_arg); + ResourceManagerCallbackMutex.lock(); - LOG_TRACE("[ResourceManager] Registered device list change callback. Total callbacks registered: %d", DeviceListChangeCallbacks.size()); -} - -void ResourceManager::UnregisterDeviceListChangeCallback(DeviceListChangeCallback callback, void * callback_arg) -{ - for(size_t idx = 0; idx < DeviceListChangeCallbacks.size(); idx++) + for(size_t idx = 0; idx < ResourceManagerCallbacks.size(); idx++) { - if(DeviceListChangeCallbacks[idx] == callback && DeviceListChangeCallbackArgs[idx] == callback_arg) + if(ResourceManagerCallbacks[idx] == callback && ResourceManagerCallbackArgs[idx] == callback_arg) { - DeviceListChangeCallbacks.erase(DeviceListChangeCallbacks.begin() + idx); - DeviceListChangeCallbackArgs.erase(DeviceListChangeCallbackArgs.begin() + idx); + ResourceManagerCallbacks.erase(ResourceManagerCallbacks.begin() + idx); + ResourceManagerCallbackArgs.erase(ResourceManagerCallbackArgs.begin() + idx); } } - LOG_TRACE("[ResourceManager] Unregistered device list change callback. Total callbacks registered: %d", DeviceListChangeCallbacks.size()); + ResourceManagerCallbackMutex.unlock(); + + LOG_TRACE("[%s] Unregistered ResourceManager callback. Total callbacks registered: %d", RESOURCEMANAGER, ResourceManagerCallbackArgs.size()); } -void ResourceManager::RegisterI2CBusListChangeCallback(I2CBusListChangeCallback new_callback, void * new_callback_arg) +/*---------------------------------------------------------*\ +| Functions to manage detection | +\*---------------------------------------------------------*/ + +bool ResourceManager::GetDetectionEnabled() { - I2CBusListChangeCallbacks.push_back(new_callback); - I2CBusListChangeCallbackArgs.push_back(new_callback_arg); + return(detection_enabled); } -void ResourceManager::UnregisterI2CBusListChangeCallback(I2CBusListChangeCallback callback, void * callback_arg) +unsigned int ResourceManager::GetDetectionPercent() { - for(size_t idx = 0; idx < I2CBusListChangeCallbacks.size(); idx++) + //TODO: get from DetectionManager or client + return DetectionManager::get()->GetDetectionPercent(); +} + +std::string ResourceManager::GetDetectionString() +{ + //TODO: get from DetectionManager or client + return DetectionManager::get()->GetDetectionString(); +} + +void ResourceManager::RescanDevices() +{ + /*-----------------------------------------------------*\ + | If automatic local connection is active, the primary | + | instance is the local server, so send rescan requests | + | to the automatic local connection client | + \*-----------------------------------------------------*/ + if(auto_connection_active && auto_connection_client != NULL) { - if(I2CBusListChangeCallbacks[idx] == callback && I2CBusListChangeCallbackArgs[idx] == callback_arg) - { - I2CBusListChangeCallbacks.erase(I2CBusListChangeCallbacks.begin() + idx); - I2CBusListChangeCallbackArgs.erase(I2CBusListChangeCallbackArgs.begin() + idx); - } + auto_connection_client->SendRequest_RescanDevices(); + } + + /*-----------------------------------------------------*\ + | If detection is disabled and there is exactly one | + | client, the primary instance is the connected server, | + | so send rescan requests to the first (and only) | + | client | + \*-----------------------------------------------------*/ + else if(!detection_enabled && clients.size() == 1) + { + clients[0]->SendRequest_RescanDevices(); + } + + /*-----------------------------------------------------*\ + | If detection is enabled, start detection | + \*-----------------------------------------------------*/ + if(detection_enabled) + { + DetectionManager::get()->BeginDetection(); } } -void ResourceManager::RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void *new_callback_arg) +void ResourceManager::StopDeviceDetection() { - DetectionProgressCallbacks.push_back(new_callback); - DetectionProgressCallbackArgs.push_back(new_callback_arg); - - LOG_TRACE("[ResourceManager] Registered detection progress callback. Total callbacks registered: %d", DetectionProgressCallbacks.size()); + //TODO: Call DetectionManager::AbortDetection() or send SDK command if local client } -void ResourceManager::UnregisterDetectionProgressCallback(DetectionProgressCallback callback, void *callback_arg) +void ResourceManager::ClearLocalDevices() { - for(size_t idx = 0; idx < DetectionProgressCallbacks.size(); idx++) + DeviceListChangeMutex.lock(); + + /*-----------------------------------------------------*\ + | Remove hardware controllers from controller list | + \*-----------------------------------------------------*/ + std::vector& rgb_controllers_hw = DetectionManager::get()->GetRGBControllers(); + + for(std::size_t hw_controller_idx = 0; hw_controller_idx < rgb_controllers_hw.size(); hw_controller_idx++) { - if(DetectionProgressCallbacks[idx] == callback && DetectionProgressCallbackArgs[idx] == callback_arg) + for(std::size_t controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++) { - DetectionProgressCallbacks.erase(DetectionProgressCallbacks.begin() + idx); - DetectionProgressCallbackArgs.erase(DetectionProgressCallbackArgs.begin() + idx); + if(rgb_controllers[controller_idx] == rgb_controllers_hw[hw_controller_idx]) + { + rgb_controllers.erase(rgb_controllers.begin() + controller_idx); + break; + } } } - LOG_TRACE("[ResourceManager] Unregistered detection progress callback. Total callbacks registered: %d", DetectionProgressCallbacks.size()); -} + DeviceListChangeMutex.unlock(); -void ResourceManager::RegisterDetectionStartCallback(DetectionStartCallback new_callback, void *new_callback_arg) -{ - DetectionStartCallbacks.push_back(new_callback); - DetectionStartCallbackArgs.push_back(new_callback_arg); -} + /*-----------------------------------------------------*\ + | Signal device list update | + \*-----------------------------------------------------*/ + SignalResourceManagerUpdate(RESOURCEMANAGER_UPDATE_REASON_DEVICE_LIST_UPDATED); -void ResourceManager::UnregisterDetectionStartCallback(DetectionStartCallback callback, void *callback_arg) -{ - for(size_t idx = 0; idx < DetectionStartCallbacks.size(); idx++) - { - if(DetectionStartCallbacks[idx] == callback && DetectionStartCallbackArgs[idx] == callback_arg) - { - DetectionStartCallbacks.erase(DetectionStartCallbacks.begin() + idx); - DetectionStartCallbackArgs.erase(DetectionStartCallbackArgs.begin() + idx); - } - } -} - -void ResourceManager::RegisterDetectionEndCallback(DetectionEndCallback new_callback, void *new_callback_arg) -{ - DetectionEndCallbacks.push_back(new_callback); - DetectionEndCallbackArgs.push_back(new_callback_arg); -} - -void ResourceManager::UnregisterDetectionEndCallback(DetectionEndCallback callback, void *callback_arg) -{ - for(size_t idx = 0; idx < DetectionEndCallbacks.size(); idx++) - { - if(DetectionEndCallbacks[idx] == callback && DetectionEndCallbackArgs[idx] == callback_arg) - { - DetectionEndCallbacks.erase(DetectionEndCallbacks.begin() + idx); - DetectionEndCallbackArgs.erase(DetectionEndCallbackArgs.begin() + idx); - } - } + /*-----------------------------------------------------*\ + | Device list has changed, inform all clients connected | + | to this server | + \*-----------------------------------------------------*/ + server->DeviceListChanged(); } void ResourceManager::UpdateDeviceList() @@ -558,7 +460,9 @@ void ResourceManager::UpdateDeviceList() /*-----------------------------------------------------*\ | Insert hardware controllers into controller list | \*-----------------------------------------------------*/ - for(unsigned int hw_controller_idx = 0; hw_controller_idx < rgb_controllers_hw.size(); hw_controller_idx++) + std::vector& rgb_controllers_hw = DetectionManager::get()->GetRGBControllers(); + + for(std::size_t hw_controller_idx = 0; hw_controller_idx < rgb_controllers_hw.size(); hw_controller_idx++) { /*-------------------------------------------------*\ | Check if the controller is already in the list | @@ -576,7 +480,7 @@ void ResourceManager::UpdateDeviceList() | If not, check if the controller is already in the | | list at a different index | \*-------------------------------------------------*/ - for(unsigned int controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++) + for(std::size_t controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++) { if(rgb_controllers[controller_idx] == rgb_controllers_hw[hw_controller_idx]) { @@ -592,76 +496,40 @@ void ResourceManager::UpdateDeviceList() rgb_controllers.insert(rgb_controllers.begin() + hw_controller_idx, rgb_controllers_hw[hw_controller_idx]); } + DeviceListChangeMutex.unlock(); + /*-----------------------------------------------------*\ - | Device list has changed, call the callbacks | + | Signal device list update | \*-----------------------------------------------------*/ - DeviceListChanged(); + SignalResourceManagerUpdate(RESOURCEMANAGER_UPDATE_REASON_DEVICE_LIST_UPDATED); /*-----------------------------------------------------*\ | Device list has changed, inform all clients connected | | to this server | \*-----------------------------------------------------*/ server->DeviceListChanged(); - - DeviceListChangeMutex.unlock(); } -void ResourceManager::ClientInfoChanged() +void ResourceManager::WaitForDetection() { - /*-----------------------------------------------------*\ - | Client info has changed, call the callbacks | - \*-----------------------------------------------------*/ - LOG_TRACE("[ResourceManager] Calling client info change callbacks."); - - for(std::size_t callback_idx = 0; callback_idx < ClientInfoChangeCallbacks.size(); callback_idx++) - { - ResourceManager::ClientInfoChangeCallbacks[callback_idx](ClientInfoChangeCallbackArgs[callback_idx]); - } + DetectionManager::get()->WaitForDetection(); } -void ResourceManager::DeviceListChanged() +/*---------------------------------------------------------*\ +| Function to signal update callbacks | +\*---------------------------------------------------------*/ +void ResourceManager::SignalResourceManagerUpdate(unsigned int update_reason) { - /*-----------------------------------------------------*\ - | Device list has changed, call the callbacks | - \*-----------------------------------------------------*/ - LOG_TRACE("[ResourceManager] Calling device list change callbacks."); + ResourceManagerCallbackMutex.lock(); - for(std::size_t callback_idx = 0; callback_idx < DeviceListChangeCallbacks.size(); callback_idx++) + for(std::size_t callback_idx = 0; callback_idx < ResourceManagerCallbacks.size(); callback_idx++) { - ResourceManager::DeviceListChangeCallbacks[callback_idx](DeviceListChangeCallbackArgs[callback_idx]); - } -} - -void ResourceManager::DetectionProgressChanged() -{ - DetectionProgressMutex.lock(); - - /*-----------------------------------------------------*\ - | Detection progress has changed, call the callbacks | - \*-----------------------------------------------------*/ - LOG_TRACE("[ResourceManager] Calling detection progress callbacks."); - - for(std::size_t callback_idx = 0; callback_idx < (unsigned int)DetectionProgressCallbacks.size(); callback_idx++) - { - DetectionProgressCallbacks[callback_idx](DetectionProgressCallbackArgs[callback_idx]); + ResourceManagerCallbacks[callback_idx](ResourceManagerCallbackArgs[callback_idx], update_reason); } - DetectionProgressMutex.unlock(); -} + ResourceManagerCallbackMutex.unlock(); -void ResourceManager::I2CBusListChanged() -{ - I2CBusListChangeMutex.lock(); - - /*-----------------------------------------------------*\ - | Detection progress has changed, call the callbacks | - \*-----------------------------------------------------*/ - for(std::size_t callback_idx = 0; callback_idx < (unsigned int)I2CBusListChangeCallbacks.size(); callback_idx++) - { - I2CBusListChangeCallbacks[callback_idx](I2CBusListChangeCallbackArgs[callback_idx]); - } - - I2CBusListChangeMutex.unlock(); + LOG_TRACE("[%s] ResourceManager update signalled: %d", RESOURCEMANAGER, update_reason); } void ResourceManager::SetupConfigurationDirectory() @@ -711,88 +579,9 @@ void ResourceManager::SetupConfigurationDirectory() } } -filesystem::path ResourceManager::GetConfigurationDirectory() -{ - return(config_dir); -} - -void ResourceManager::SetConfigurationDirectory(const filesystem::path &directory) -{ - config_dir = directory; - settings_manager->LoadSettings(directory / "OpenRGB.json"); - profile_manager->SetConfigurationDirectory(directory); - - rgb_controllers_sizes.clear(); - rgb_controllers_sizes = profile_manager->GetControllerListFromSizes(); -} - -NetworkServer* ResourceManager::GetServer() -{ - return(server); -} - -static void NetworkClientInfoChangeCallback(void* this_ptr) -{ - ResourceManager* this_obj = (ResourceManager*)this_ptr; - - this_obj->ClientInfoChanged(); - this_obj->DeviceListChanged(); -} - -void ResourceManager::RegisterNetworkClient(NetworkClient* new_client) -{ - new_client->RegisterClientInfoChangeCallback(NetworkClientInfoChangeCallback, this); - - clients.push_back(new_client); -} - -void ResourceManager::UnregisterNetworkClient(NetworkClient* network_client) -{ - /*-----------------------------------------------------*\ - | Stop the disconnecting client | - \*-----------------------------------------------------*/ - network_client->StopClient(); - - /*-----------------------------------------------------*\ - | Clear callbacks from the client before removal | - \*-----------------------------------------------------*/ - network_client->ClearCallbacks(); - - /*-----------------------------------------------------*\ - | Find the client to remove and remove it from the | - | clients list | - \*-----------------------------------------------------*/ - std::vector::iterator client_it = std::find(clients.begin(), clients.end(), network_client); - - if(client_it != clients.end()) - { - clients.erase(client_it); - } - - /*-----------------------------------------------------*\ - | Delete the client | - \*-----------------------------------------------------*/ - delete network_client; - - UpdateDeviceList(); -} - - -/******************************************************************************************\ -* * -* AttemptLocalConnection * -* * -* Attempts an SDK connection to the local server. Returns true if success * -* * -\******************************************************************************************/ - bool ResourceManager::AttemptLocalConnection() { - detection_percent = 0; - detection_string = "Attempting local server connection..."; - DetectionProgressChanged(); - - LOG_DEBUG("[ResourceManager] Attempting local server connection..."); + LOG_DEBUG("[%s] Attempting local server connection...", RESOURCEMANAGER); bool success = false; @@ -815,9 +604,9 @@ bool ResourceManager::AttemptLocalConnection() if(!auto_connection_client->GetConnected()) { - LOG_TRACE("[ResourceManager] Client failed to connect"); + LOG_TRACE("[%s] Client failed to connect", RESOURCEMANAGER); auto_connection_client->StopClient(); - LOG_TRACE("[ResourceManager] Client stopped"); + LOG_TRACE("[%s] Client stopped", RESOURCEMANAGER); delete auto_connection_client; @@ -826,7 +615,7 @@ bool ResourceManager::AttemptLocalConnection() else { ResourceManager::get()->RegisterNetworkClient(auto_connection_client); - LOG_TRACE("[ResourceManager] Registered network client"); + LOG_TRACE("[%s] Registered network client", RESOURCEMANAGER); success = true; @@ -847,967 +636,38 @@ bool ResourceManager::AttemptLocalConnection() return success; } -std::vector& ResourceManager::GetClients() -{ - return(clients); -} - -PluginManagerInterface* ResourceManager::GetPluginManager() -{ - return(plugin_manager); -} - -ProfileManager* ResourceManager::GetProfileManager() -{ - return(profile_manager); -} - -SettingsManager* ResourceManager::GetSettingsManager() -{ - return(settings_manager); -} - -bool ResourceManager::GetDetectionEnabled() -{ - return(detection_enabled); -} - -unsigned int ResourceManager::GetDetectionPercent() -{ - return (detection_percent.load()); -} - -const char *ResourceManager::GetDetectionString() -{ - return (detection_string); -} - -void ResourceManager::Cleanup() -{ - ResourceManager::get()->WaitForDeviceDetection(); - - std::vector rgb_controllers_hw_copy = rgb_controllers_hw; - - for(std::size_t hw_controller_idx = 0; hw_controller_idx < rgb_controllers_hw.size(); hw_controller_idx++) - { - for(std::size_t controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++) - { - if(rgb_controllers[controller_idx] == rgb_controllers_hw[hw_controller_idx]) - { - rgb_controllers.erase(rgb_controllers.begin() + controller_idx); - break; - } - } - } - - /*-----------------------------------------------------*\ - | Clear the hardware controllers list and set the | - | previous hardware controllers list size to zero | - \*-----------------------------------------------------*/ - rgb_controllers_hw.clear(); - detection_prev_size = 0; - - for(RGBController* rgb_controller : rgb_controllers_hw_copy) - { - delete rgb_controller; - } - - std::vector busses_copy = busses; - - busses.clear(); - - for(i2c_smbus_interface* bus : busses_copy) - { - delete bus; - } - - RunInBackgroundThread(std::bind(&ResourceManager::HidExitCoroutine, this)); -} - -void ResourceManager::ProcessPreDetectionHooks() -{ - for(std::size_t hook_idx = 0; hook_idx < pre_detection_hooks.size(); hook_idx++) - { - pre_detection_hooks[hook_idx](); - } -} - -void ResourceManager::ProcessDynamicDetectors() -{ - for(std::size_t detector_idx = 0; detector_idx < dynamic_detectors.size(); detector_idx++) - { - dynamic_detectors[detector_idx](); - } - - dynamic_detectors_processed = true; -} - -/*---------------------------------------------------------*\ -| Handle ALL pre-detection routines | -| The system should be ready to start a detection thread | -| (returns false if detection can not proceed) | -\*---------------------------------------------------------*/ -bool ResourceManager::ProcessPreDetection() -{ - /*-----------------------------------------------------*\ - | Process pre-detection hooks | - \*-----------------------------------------------------*/ - ProcessPreDetectionHooks(); - - /*-----------------------------------------------------*\ - | Process Dynamic Detectors | - \*-----------------------------------------------------*/ - if(!dynamic_detectors_processed) - { - ProcessDynamicDetectors(); - } - - /*-----------------------------------------------------*\ - | Call detection start callbacks | - \*-----------------------------------------------------*/ - LOG_TRACE("[ResourceManager] Calling detection start callbacks."); - - for(std::size_t callback_idx = 0; callback_idx < DetectionStartCallbacks.size(); callback_idx++) - { - DetectionStartCallbacks[callback_idx](DetectionStartCallbackArgs[callback_idx]); - } - - /*-----------------------------------------------------*\ - | Update the detector settings | - \*-----------------------------------------------------*/ - UpdateDetectorSettings(); - if(detection_enabled) - { - /*-------------------------------------------------*\ - | Do nothing is it is already detecting devices | - \*-------------------------------------------------*/ - if(detection_is_required.load()) - { - return false; - } - - /*-------------------------------------------------*\ - | If there's anything left from the last time, | - | we shall remove it first | - \*-------------------------------------------------*/ - detection_percent = 0; - detection_string = ""; - - DetectionProgressChanged(); - - Cleanup(); - - UpdateDeviceList(); - - /*-------------------------------------------------*\ - | Initialize HID interface for detection | - \*-------------------------------------------------*/ - int hid_status = hid_init(); - - LOG_INFO("[ResourceManager] Initializing HID interfaces: %s", ((hid_status == 0) ? "Success" : "Failed")); - - /*-------------------------------------------------*\ - | Mark the detection as ongoing | - | So the detection thread may proceed | - \*-------------------------------------------------*/ - detection_is_required = true; - - return true; - } - return false; -} - -void ResourceManager::DetectDevices() -{ - if(ProcessPreDetection()) - { - // Run the detection coroutine - RunInBackgroundThread(std::bind(&ResourceManager::DetectDevicesCoroutine, this)); - } - - if(!detection_enabled) - { - ProcessPostDetection(); - } -} - -void ResourceManager::RescanDevices() -{ - /*-----------------------------------------------------*\ - | If automatic local connection is active, the primary | - | instance is the local server, so send rescan requests | - | to the automatic local connection client | - \*-----------------------------------------------------*/ - if(auto_connection_active && auto_connection_client != NULL) - { - auto_connection_client->SendRequest_RescanDevices(); - } - - /*-----------------------------------------------------*\ - | If detection is disabled and there is exactly one | - | client, the primary instance is the connected server, | - | so send rescan requests to the first (and only) | - | client | - \*-----------------------------------------------------*/ - else if(!detection_enabled && clients.size() == 1) - { - clients[0]->SendRequest_RescanDevices(); - } - - /*-----------------------------------------------------*\ - | Perform local rescan | - \*-----------------------------------------------------*/ - DetectDevices(); -} - -void ResourceManager::ProcessPostDetection() -{ - /*-----------------------------------------------------*\ - | Signal that detection is complete | - \*-----------------------------------------------------*/ - detection_percent = 100; - DetectionProgressChanged(); - - LOG_INFO("[ResourceManager] Calling Post-detection callbacks"); - /*-----------------------------------------------------*\ - | Call detection end callbacks | - \*-----------------------------------------------------*/ - for(std::size_t callback_idx = 0; callback_idx < DetectionEndCallbacks.size(); callback_idx++) - { - DetectionEndCallbacks[callback_idx](DetectionEndCallbackArgs[callback_idx]); - } - - detection_is_required = false; - - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Detection completed |"); - LOG_INFO("------------------------------------------------------"); -} - -void ResourceManager::DisableDetection() -{ - detection_enabled = false; -} - -void ResourceManager::DetectDevicesCoroutine() -{ - DetectDeviceMutex.lock(); - - hid_device_info* current_hid_device; - float percent = 0.0f; - float percent_denominator = 0.0f; - json detector_settings; - unsigned int hid_device_count = 0; - hid_device_info* hid_devices = NULL; - bool hid_safe_mode = false; - unsigned int initial_detection_delay_ms = 0; - - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Start device detection |"); - LOG_INFO("------------------------------------------------------"); - - /*-----------------------------------------------------*\ - | Open device disable list and read in disabled | - | device strings | - \*-----------------------------------------------------*/ - detector_settings = settings_manager->GetSettings("Detectors"); - - /*-----------------------------------------------------*\ - | Check HID safe mode setting | - \*-----------------------------------------------------*/ - if(detector_settings.contains("hid_safe_mode")) - { - hid_safe_mode = detector_settings["hid_safe_mode"]; - } - - /*-----------------------------------------------------*\ - | Check initial detection delay setting | - \*-----------------------------------------------------*/ - if(detector_settings.contains("initial_detection_delay_ms")) - { - initial_detection_delay_ms = detector_settings["initial_detection_delay_ms"]; - } - - /*-----------------------------------------------------*\ - | If configured, delay detection for the configured | - | time only on first detection | - \*-----------------------------------------------------*/ - if(initial_detection) - { - if(initial_detection_delay_ms != 0) - { - LOG_INFO("[ResourceManager] Delaying detection for %d ms", initial_detection_delay_ms); - std::this_thread::sleep_for(initial_detection_delay_ms * 1ms); - } - - initial_detection = false; - } - - /*-----------------------------------------------------*\ - | Reset the size entry used flags vector | - \*-----------------------------------------------------*/ - detection_size_entry_used.resize(rgb_controllers_sizes.size()); - - for(std::size_t size_idx = 0; size_idx < (unsigned int)detection_size_entry_used.size(); size_idx++) - { - detection_size_entry_used[size_idx] = false; - } - - /*-----------------------------------------------------*\ - | Calculate the percentage denominator by adding the | - | number of I2C and miscellaneous detectors and the | - | number of enumerated HID devices | - | | - | Start by iterating through all HID devices in list to | - | get a total count | - \*-----------------------------------------------------*/ - if(!hid_safe_mode) - { - hid_devices = hid_enumerate(0, 0); - } - - current_hid_device = hid_devices; - - while(current_hid_device) - { - hid_device_count++; - - current_hid_device = current_hid_device->next; - } - - percent_denominator = (float)(i2c_device_detectors.size() + i2c_dimm_device_detectors.size() + i2c_pci_device_detectors.size() + device_detectors.size()) + (float)hid_device_count; - - /*-----------------------------------------------------*\ - | Start at 0% detection progress | - \*-----------------------------------------------------*/ - detection_percent = 0; - -#ifdef __linux__ - /*-----------------------------------------------------*\ - | Check if the udev rules exist | - \*-----------------------------------------------------*/ - bool udev_not_exist = false; - bool udev_multiple = false; - - if(access("/etc/udev/rules.d/60-openrgb.rules", F_OK) != 0) - { - if(access("/usr/lib/udev/rules.d/60-openrgb.rules", F_OK) != 0) - { - udev_not_exist = true; - } - } - else - { - if(access("/usr/lib/udev/rules.d/60-openrgb.rules", F_OK) == 0) - { - udev_multiple = true; - } - } -#endif - - /*-----------------------------------------------------*\ - | Detect i2c interfaces | - \*-----------------------------------------------------*/ - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Detecting I2C interfaces |"); - LOG_INFO("------------------------------------------------------"); - - bool i2c_interface_fail = false; - - for(unsigned int i2c_bus_detector_idx = 0; i2c_bus_detector_idx < (unsigned int)i2c_bus_detectors.size() && detection_is_required.load(); i2c_bus_detector_idx++) - { - if(i2c_bus_detectors[i2c_bus_detector_idx]() == false) - { - i2c_interface_fail = true; - } - - I2CBusListChanged(); - } - - /*-----------------------------------------------------*\ - | Detect i2c devices | - \*-----------------------------------------------------*/ - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Detecting I2C devices |"); - LOG_INFO("------------------------------------------------------"); - for(unsigned int i2c_detector_idx = 0; i2c_detector_idx < (unsigned int)i2c_device_detectors.size() && detection_is_required.load(); i2c_detector_idx++) - { - std::size_t controller_size = rgb_controllers_hw.size(); - detection_string = i2c_device_detector_strings[i2c_detector_idx].c_str(); - - /*-------------------------------------------------*\ - | Check if this detector is enabled | - \*-------------------------------------------------*/ - bool this_device_enabled = true; - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) - { - this_device_enabled = detector_settings["detectors"][detection_string]; - } - - LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled")); - if(this_device_enabled) - { - DetectionProgressChanged(); - - i2c_device_detectors[i2c_detector_idx](busses); - } - - /*-------------------------------------------------*\ - | If the device list size has changed, call the | - | device list changed callbacks | - \*-------------------------------------------------*/ - if(rgb_controllers_hw.size() == controller_size) - { - LOG_DEBUG("[%s] no devices found", detection_string); - } - - LOG_TRACE("[%s] detection end", detection_string); - - /*-------------------------------------------------*\ - | Update detection percent | - \*-------------------------------------------------*/ - percent = ((float)i2c_detector_idx + 1.0f) / percent_denominator; - - detection_percent = (unsigned int)(percent * 100.0f); - } - - /*-----------------------------------------------------*\ - | Detect i2c DIMM modules | - \*-----------------------------------------------------*/ - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Detecting I2C DIMM modules |"); - LOG_INFO("------------------------------------------------------"); - - detection_string = "Reading DRAM SPD Information"; - DetectionProgressChanged(); - - for(unsigned int bus = 0; bus < busses.size() && IsAnyDimmDetectorEnabled(detector_settings); bus++) - { - IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device) - { - std::vector slots; - SPDMemoryType dimm_type = SPD_RESERVED; - - for(uint8_t spd_addr = 0x50; spd_addr < 0x58; spd_addr++) - { - SPDDetector spd(busses[bus], spd_addr, dimm_type); - if(spd.is_valid()) - { - SPDWrapper accessor(spd); - dimm_type = spd.memory_type(); - LOG_INFO("[ResourceManager] Detected occupied slot %d, bus %d, type %s", spd_addr - 0x50 + 1, bus, spd_memory_type_name[dimm_type]); - LOG_DEBUG("[ResourceManager] Jedec ID: 0x%04x", accessor.jedec_id()); - slots.push_back(accessor); - } - } - - for(unsigned int i2c_detector_idx = 0; i2c_detector_idx < i2c_dimm_device_detectors.size() && detection_is_required.load(); i2c_detector_idx++) - { - if((i2c_dimm_device_detectors[i2c_detector_idx].dimm_type == dimm_type) && is_jedec_in_slots(slots, i2c_dimm_device_detectors[i2c_detector_idx].jedec_id)) - { - detection_string = i2c_dimm_device_detectors[i2c_detector_idx].name.c_str(); - - /*-------------------------------------*\ - | Check if this detector is enabled | - \*-------------------------------------*/ - bool this_device_enabled = true; - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) - { - this_device_enabled = detector_settings["detectors"][detection_string]; - } - - LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled")); - if(this_device_enabled) - { - DetectionProgressChanged(); - - std::vector matching_slots = slots_with_jedec(slots, i2c_dimm_device_detectors[i2c_detector_idx].jedec_id); - i2c_dimm_device_detectors[i2c_detector_idx].function(busses[bus], matching_slots, i2c_dimm_device_detectors[i2c_detector_idx].name); - } - - LOG_TRACE("[%s] detection end", detection_string); - } - - /*-----------------------------------------*\ - | Update detection percent | - \*-----------------------------------------*/ - percent = (i2c_device_detectors.size() + i2c_detector_idx + 1.0f) / percent_denominator; - - detection_percent = (unsigned int)(percent * 100.0f); - } - } - } - - /*-----------------------------------------------------*\ - | Detect i2c PCI devices | - \*-----------------------------------------------------*/ - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Detecting I2C PCI devices |"); - LOG_INFO("------------------------------------------------------"); - for(unsigned int i2c_detector_idx = 0; i2c_detector_idx < (unsigned int)i2c_pci_device_detectors.size() && detection_is_required.load(); i2c_detector_idx++) - { - detection_string = i2c_pci_device_detectors[i2c_detector_idx].name.c_str(); - - /*-------------------------------------------------*\ - | Check if this detector is enabled | - \*-------------------------------------------------*/ - bool this_device_enabled = true; - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) - { - this_device_enabled = detector_settings["detectors"][detection_string]; - } - - LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled")); - if(this_device_enabled) - { - DetectionProgressChanged(); - - for(unsigned int bus = 0; bus < busses.size(); bus++) - { - if(busses[bus]->pci_vendor == i2c_pci_device_detectors[i2c_detector_idx].ven_id && - busses[bus]->pci_device == i2c_pci_device_detectors[i2c_detector_idx].dev_id && - busses[bus]->pci_subsystem_vendor == i2c_pci_device_detectors[i2c_detector_idx].subven_id && - busses[bus]->pci_subsystem_device == i2c_pci_device_detectors[i2c_detector_idx].subdev_id) - { - i2c_pci_device_detectors[i2c_detector_idx].function(busses[bus], i2c_pci_device_detectors[i2c_detector_idx].i2c_addr, i2c_pci_device_detectors[i2c_detector_idx].name); - } - } - } - - LOG_TRACE("[%s] detection end", detection_string); - - /*-------------------------------------------------*\ - | Update detection percent | - \*-------------------------------------------------*/ - percent = (i2c_device_detectors.size() + i2c_dimm_device_detectors.size() + i2c_detector_idx + 1.0f) / percent_denominator; - - detection_percent = (unsigned int)(percent * 100.0f); - } - - /*-----------------------------------------------------*\ - | Detect HID devices | - | | - | Reset current device pointer to first device | - \*-----------------------------------------------------*/ - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Detecting HID devices |"); - if (hid_safe_mode) - LOG_INFO("| with safe mode |"); - LOG_INFO("------------------------------------------------------"); - current_hid_device = hid_devices; - - if(hid_safe_mode) - { - /*-------------------------------------------------*\ - | Loop through all available detectors. If all | - | required information matches, run the detector | - \*-------------------------------------------------*/ - for(unsigned int hid_detector_idx = 0; hid_detector_idx < (unsigned int)hid_device_detectors.size() && detection_is_required.load(); hid_detector_idx++) - { - HIDDeviceDetectorBlock & detector = hid_device_detectors[hid_detector_idx]; - hid_devices = hid_enumerate(detector.vid, detector.pid); - - LOG_VERBOSE("[ResourceManager] Trying to run detector for [%s] (for %04x:%04x)", detector.name.c_str(), detector.vid, detector.pid); - - current_hid_device = hid_devices; - - while(current_hid_device) - { - - if(detector.compare(current_hid_device)) - { - detection_string = detector.name.c_str(); - - /*-------------------------------------*\ - | Check if this detector is enabled or | - | needs to be added to the settings list| - \*-------------------------------------*/ - bool this_device_enabled = true; - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) - { - this_device_enabled = detector_settings["detectors"][detection_string]; - } - - LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled")); - - if(this_device_enabled) - { - DetectionProgressChanged(); - - detector.function(current_hid_device, hid_device_detectors[hid_detector_idx].name); - - LOG_TRACE("[%s] detection end", detection_string); - } - } - - current_hid_device = current_hid_device->next; - } - - hid_free_enumeration(hid_devices); - } - } - else - { - /*-------------------------------------------------*\ - | Iterate through all devices in list and run | - | detectors | - \*-------------------------------------------------*/ - hid_device_count = 0; - - while(current_hid_device) - { - if(LogManager::get()->getLoglevel() >= LL_DEBUG) - { - const char* manu_name = StringUtils::wchar_to_char(current_hid_device->manufacturer_string); - const char* prod_name = StringUtils::wchar_to_char(current_hid_device->product_string); - LOG_DEBUG("[%04X:%04X U=%04X P=0x%04X I=%d] %-25s - %s", current_hid_device->vendor_id, current_hid_device->product_id, current_hid_device->usage, current_hid_device->usage_page, current_hid_device->interface_number, manu_name, prod_name); - } - detection_string = ""; - DetectionProgressChanged(); - - /*---------------------------------------------*\ - | Loop through all available detectors. If all | - | required information matches, run the detector| - \*---------------------------------------------*/ - for(unsigned int hid_detector_idx = 0; hid_detector_idx < (unsigned int)hid_device_detectors.size() && detection_is_required.load(); hid_detector_idx++) - { - HIDDeviceDetectorBlock & detector = hid_device_detectors[hid_detector_idx]; - if(detector.compare(current_hid_device)) - { - detection_string = detector.name.c_str(); - - /*-------------------------------------*\ - | Check if this detector is enabled or | - | needs to be added to the settings list| - \*-------------------------------------*/ - bool this_device_enabled = true; - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) - { - this_device_enabled = detector_settings["detectors"][detection_string]; - } - - LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled")); - - if(this_device_enabled) - { - DetectionProgressChanged(); - - detector.function(current_hid_device, hid_device_detectors[hid_detector_idx].name); - } - } - } - - /*---------------------------------------------*\ - | Loop through all available wrapped HID | - | detectors. If all required information | - | matches, run the detector | - \*---------------------------------------------*/ - for(unsigned int hid_detector_idx = 0; hid_detector_idx < (unsigned int)hid_wrapped_device_detectors.size() && detection_is_required.load(); hid_detector_idx++) - { - HIDWrappedDeviceDetectorBlock & detector = hid_wrapped_device_detectors[hid_detector_idx]; - if(detector.compare(current_hid_device)) - { - detection_string = detector.name.c_str(); - - /*-------------------------------------*\ - | Check if this detector is enabled or | - | needs to be added to the settings list| - \*-------------------------------------*/ - bool this_device_enabled = true; - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) - { - this_device_enabled = detector_settings["detectors"][detection_string]; - } - - LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled")); - - if(this_device_enabled) - { - DetectionProgressChanged(); - - detector.function(default_wrapper, current_hid_device, hid_wrapped_device_detectors[hid_detector_idx].name); - } - } - } - - /*---------------------------------------------*\ - | Update detection percent | - \*---------------------------------------------*/ - hid_device_count++; - - percent = (i2c_device_detectors.size() + i2c_dimm_device_detectors.size() + i2c_pci_device_detectors.size() + hid_device_count) / percent_denominator; - - detection_percent = (unsigned int)(percent * 100.0f); - - /*---------------------------------------------*\ - | Move on to the next HID device | - \*---------------------------------------------*/ - current_hid_device = current_hid_device->next; - } - - /*-------------------------------------------------*\ - | Done using the device list, free it | - \*-------------------------------------------------*/ - hid_free_enumeration(hid_devices); - } - - /*-----------------------------------------------------*\ - | Detect HID devices | - | | - | Reset current device pointer to first device | - \*-----------------------------------------------------*/ -#ifdef __linux__ -#ifdef __GLIBC__ - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Detecting libusb HID devices |"); - LOG_INFO("------------------------------------------------------"); - - void * dyn_handle = NULL; - hidapi_wrapper wrapper; - - /*-----------------------------------------------------*\ - | Load the libhidapi-libusb library | - \*-----------------------------------------------------*/ -#ifdef __GLIBC__ - if((dyn_handle = dlopen("libhidapi-libusb.so", RTLD_NOW | RTLD_NODELETE | RTLD_DEEPBIND))) -#else - if(dyn_handle = dlopen("libhidapi-libusb.so", RTLD_NOW | RTLD_NODELETE )) -#endif - { - /*-------------------------------------------------*\ - | Create a wrapper with the libusb functions | - \*-------------------------------------------------*/ - wrapper = - { - .dyn_handle = dyn_handle, - .hid_send_feature_report = (hidapi_wrapper_send_feature_report) dlsym(dyn_handle,"hid_send_feature_report"), - .hid_get_feature_report = (hidapi_wrapper_get_feature_report) dlsym(dyn_handle,"hid_get_feature_report"), - .hid_get_serial_number_string = (hidapi_wrapper_get_serial_number_string) dlsym(dyn_handle,"hid_get_serial_number_string"), - .hid_open_path = (hidapi_wrapper_open_path) dlsym(dyn_handle,"hid_open_path"), - .hid_enumerate = (hidapi_wrapper_enumerate) dlsym(dyn_handle,"hid_enumerate"), - .hid_free_enumeration = (hidapi_wrapper_free_enumeration) dlsym(dyn_handle,"hid_free_enumeration"), - .hid_close = (hidapi_wrapper_close) dlsym(dyn_handle,"hid_close"), - .hid_error = (hidapi_wrapper_error) dlsym(dyn_handle,"hid_free_enumeration") - }; - - hid_devices = wrapper.hid_enumerate(0, 0); - - current_hid_device = hid_devices; - - /*-------------------------------------------------*\ - | Iterate through all devices in list and run | - | detectors | - \*-------------------------------------------------*/ - hid_device_count = 0; - - while(current_hid_device) - { - if(LogManager::get()->getLoglevel() >= LL_DEBUG) - { - const char* manu_name = StringUtils::wchar_to_char(current_hid_device->manufacturer_string); - const char* prod_name = StringUtils::wchar_to_char(current_hid_device->product_string); - LOG_DEBUG("[%04X:%04X U=%04X P=0x%04X I=%d] %-25s - %s", current_hid_device->vendor_id, current_hid_device->product_id, current_hid_device->usage, current_hid_device->usage_page, current_hid_device->interface_number, manu_name, prod_name); - } - detection_string = ""; - DetectionProgressChanged(); - - /*---------------------------------------------*\ - | Loop through all available wrapped HID | - | detectors. If all required information | - | matches, run the detector | - \*---------------------------------------------*/ - for(unsigned int hid_detector_idx = 0; hid_detector_idx < (unsigned int)hid_wrapped_device_detectors.size() && detection_is_required.load(); hid_detector_idx++) - { - HIDWrappedDeviceDetectorBlock & detector = hid_wrapped_device_detectors[hid_detector_idx]; - if(detector.compare(current_hid_device)) - { - detection_string = detector.name.c_str(); - - /*-------------------------------------*\ - | Check if this detector is enabled or | - | needs to be added to the settings list| - \*-------------------------------------*/ - bool this_device_enabled = true; - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) - { - this_device_enabled = detector_settings["detectors"][detection_string]; - } - - LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled")); - - if(this_device_enabled) - { - DetectionProgressChanged(); - - detector.function(wrapper, current_hid_device, detector.name); - } - } - } - - /*---------------------------------------------*\ - | Update detection percent | - \*---------------------------------------------*/ - hid_device_count++; - - percent = (i2c_device_detectors.size() + i2c_dimm_device_detectors.size() + i2c_pci_device_detectors.size() + hid_device_count) / percent_denominator; - - detection_percent = percent * 100.0f; - - /*---------------------------------------------*\ - | Move on to the next HID device | - \*---------------------------------------------*/ - current_hid_device = current_hid_device->next; - } - - /*-------------------------------------------------*\ - | Done using the device list, free it | - \*-------------------------------------------------*/ - wrapper.hid_free_enumeration(hid_devices); - } -#endif -#endif - - /*-----------------------------------------------------*\ - | Detect other devices | - \*-----------------------------------------------------*/ - LOG_INFO("------------------------------------------------------"); - LOG_INFO("| Detecting other devices |"); - LOG_INFO("------------------------------------------------------"); - - for(unsigned int detector_idx = 0; detector_idx < (unsigned int)device_detectors.size() && detection_is_required.load(); detector_idx++) - { - detection_string = device_detector_strings[detector_idx].c_str(); - - /*-------------------------------------------------*\ - | Check if this detector is enabled | - \*-------------------------------------------------*/ - bool this_device_enabled = true; - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string)) - { - this_device_enabled = detector_settings["detectors"][detection_string]; - } - - LOG_DEBUG("[%s] is %s", detection_string, ((this_device_enabled == true) ? "enabled" : "disabled")); - - if(this_device_enabled) - { - DetectionProgressChanged(); - - device_detectors[detector_idx](); - } - - LOG_TRACE("[%s] detection end", detection_string); - - /*-------------------------------------------------*\ - | Update detection percent | - \*-------------------------------------------------*/ - percent = (i2c_device_detectors.size() + hid_device_count + detector_idx + 1.0f) / percent_denominator; - - detection_percent = (unsigned int)(percent * 100.0f); - } - - /*-----------------------------------------------------*\ - | Make sure that when the detection is done, progress | - | bar is set to 100% | - \*-----------------------------------------------------*/ - ProcessPostDetection(); - - DetectDeviceMutex.unlock(); - -#ifdef __linux__ - /*-----------------------------------------------------*\ - | If the udev rules file is not installed, show a dialog| - \*-----------------------------------------------------*/ - if(udev_not_exist) - { - LOG_DIALOG("%s", UDEV_MISSING); - - udev_multiple = false; - i2c_interface_fail = false; - } - - /*-----------------------------------------------------*\ - | If multiple udev rules files are installed, show a | - | dialog | - \*-----------------------------------------------------*/ - if(udev_multiple) - { - LOG_DIALOG("%s", UDEV_MUTLI); - - i2c_interface_fail = false; - } - -#endif - - /*-----------------------------------------------------*\ - | If any i2c interfaces failed to detect due to an | - | error condition, show a dialog | - \*-----------------------------------------------------*/ - if(i2c_interface_fail) - { -#ifdef _WIN32 - LOG_DIALOG("%s", I2C_ERR_WIN); -#endif -#ifdef __linux__ - LOG_DIALOG("%s", I2C_ERR_LINUX); -#endif - } -} - -void ResourceManager::SetPluginManager(PluginManagerInterface* plugin_manager_ptr) -{ - plugin_manager = plugin_manager_ptr; - server->SetPluginManager(plugin_manager); -} - -void ResourceManager::StopDeviceDetection() -{ - LOG_INFO("[ResourceManager] Detection abort requested"); - detection_is_required = false; - detection_percent = 100; - detection_string = "Stopping"; -} - void ResourceManager::Initialize(bool tryConnect, bool detectDevices, bool startServer, bool applyPostOptions) { /*-----------------------------------------------------*\ | Cache the parameters | | TODO: Possibly cache them in the CLI file somewhere | \*-----------------------------------------------------*/ - tryAutoConnect = tryConnect; - detection_enabled = detectDevices; - start_server = startServer; - apply_post_options = applyPostOptions; + tryAutoConnect = tryConnect; + detection_enabled = detectDevices; + start_server = startServer; + apply_post_options = applyPostOptions; - RunInBackgroundThread(std::bind(&ResourceManager::InitCoroutine, this)); -} - -void ResourceManager::InitCoroutine() -{ /*-----------------------------------------------------*\ | If enabled, try connecting to local server instead of | | detecting devices from this instance of OpenRGB | \*-----------------------------------------------------*/ if(tryAutoConnect) { - detection_percent = 0; - detection_string = "Attempting server connection..."; - DetectionProgressChanged(); - /*-------------------------------------------------*\ | Attempt connection to local server | \*-------------------------------------------------*/ if(AttemptLocalConnection()) { - LOG_DEBUG("[ResourceManager] Local OpenRGB server connected, running in client mode"); + LOG_DEBUG("[%s] Local OpenRGB server connected, running in client mode", RESOURCEMANAGER); /*---------------------------------------------*\ | Set auto connection active flag and disable | | detection if the local server was connected | \*---------------------------------------------*/ - auto_connection_active = true; + auto_connection_active = true; + detection_enabled = false; + profile_manager->UpdateProfileList(); - DisableDetection(); } tryAutoConnect = false; @@ -1816,7 +676,7 @@ void ResourceManager::InitCoroutine() /*-----------------------------------------------------*\ | Initialize Saved Client Connections | \*-----------------------------------------------------*/ - json client_settings = settings_manager->GetSettings("Client"); + json client_settings = settings_manager->GetSettings("Client"); if(client_settings.contains("clients")) { @@ -1854,37 +714,22 @@ void ResourceManager::InitCoroutine() \*-----------------------------------------------------*/ if(start_server) { - detection_percent = 0; - detection_string = "Starting server"; - DetectionProgressChanged(); - GetServer()->StartServer(); if(!GetServer()->GetOnline()) { - LOG_DEBUG("[ResourceManager] Server failed to start"); + LOG_DEBUG("[%s] Server failed to start", RESOURCEMANAGER); } } /*-----------------------------------------------------*\ | Perform actual detection if enabled | - | Done in the same thread (InitThread), as we need to | - | wait for completion anyway | \*-----------------------------------------------------*/ if(detection_enabled) { - LOG_DEBUG("[ResourceManager] Running standalone"); - if(ProcessPreDetection()) - { - /*---------------------------------------------*\ - | We are currently in a coroutine, so run | - | detection directly with no scheduling | - \*---------------------------------------------*/ - DetectDevicesCoroutine(); - } - } - else - { - ProcessPostDetection(); + LOG_DEBUG("[%s] Local OpenRGB server not found, running in standalone mode", RESOURCEMANAGER); + + DetectionManager::get()->RegisterDetectionCallback(ResourceManagerDetectionCallback, this); + DetectionManager::get()->BeginDetection(); } /*-----------------------------------------------------*\ @@ -1900,204 +745,6 @@ void ResourceManager::InitCoroutine() init_finished = true; } -void ResourceManager::HidExitCoroutine() -{ - /*-----------------------------------------------------*\ - | Cleanup HID interface | - | WARNING: may not be ran from any other thread!!! | - \*-----------------------------------------------------*/ - int hid_status = hid_exit(); - - LOG_DEBUG("[ResourceManager] Closing HID interfaces: %s", ((hid_status == 0) ? "Success" : "Failed")); -} - -void ResourceManager::RunInBackgroundThread(std::function coroutine) -{ - if(std::this_thread::get_id() == DetectDevicesThread->get_id()) - { - /*-------------------------------------------------*\ - | We are already in the background thread - don't | - | schedule the call, run it immediately | - \*-------------------------------------------------*/ - coroutine(); - } - else - { - BackgroundThreadStateMutex.lock(); - if(ScheduledBackgroundFunction != nullptr) - { - LOG_WARNING("[ResourceManager] Detection coroutine: assigned a new coroutine when one was already scheduled - probably two rescan events sent at once"); - } - ScheduledBackgroundFunction = coroutine; - BackgroundThreadStateMutex.unlock(); - BackgroundFunctionStartTrigger.notify_one(); - } -} - -void ResourceManager::BackgroundThreadFunction() -{ - /*-----------------------------------------------------*\ - | The background thread that runs scheduled coroutines | - | when applicable | - | Stays asleep if nothing is scheduled | - | NOTE: this thread owns the HIDAPI library internal | - | objects on MacOS | - | hid_init and hid_exit may not be called outside of | - | this thread. Calling hid_exit outside of this thread | - | WILL cause an immediate CRASH on MacOS. | - | BackgroundThreadStateMutex will be UNLOCKED as long | - | as the thread is suspended. It locks automatically | - | when any coroutine is running. However, it seems to | - | be necessary to be separate from the | - | DeviceDetectionMutex, even though their states are | - | nearly identical. | - \------------------------------------------------------*/ - - std::unique_lock lock(BackgroundThreadStateMutex); - while(background_thread_running) - { - if(ScheduledBackgroundFunction) - { - std::function coroutine = nullptr; - std::swap(ScheduledBackgroundFunction, coroutine); - try - { - coroutine(); - } - catch(std::exception& e) - { - LOG_ERROR("[ResourceManager] Unhandled exception in coroutine; e.what(): %s", e.what()); - } - catch(...) - { - LOG_ERROR("[ResourceManager] Unhandled exception in coroutine"); - } - } - /*-------------------------------------------------*\ - | This line will cause the thread to suspend until | - | the condition variable is triggered | - | NOTE: it may be subject to "spurious wakeups" | - \*-------------------------------------------------*/ - BackgroundFunctionStartTrigger.wait(lock); - } -} - -void ResourceManager::UpdateDetectorSettings() -{ - json detector_settings; - bool save_settings = false; - - /*-----------------------------------------------------*\ - | Open device disable list and read in disabled device | - | strings | - \*-----------------------------------------------------*/ - detector_settings = settings_manager->GetSettings("Detectors"); - - /*-----------------------------------------------------*\ - | Loop through all I2C detectors and see if any need to | - | be saved to the settings | - \*-----------------------------------------------------*/ - for(unsigned int i2c_detector_idx = 0; i2c_detector_idx < (unsigned int)i2c_device_detectors.size(); i2c_detector_idx++) - { - detection_string = i2c_device_detector_strings[i2c_detector_idx].c_str(); - - if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) - { - detector_settings["detectors"][detection_string] = true; - save_settings = true; - } - } - - /*-----------------------------------------------------*\ - | Loop through all I2C DIMM detectors and see if any | - | need to be saved to the settings | - \*-----------------------------------------------------*/ - for(unsigned int i2c_detector_idx = 0; i2c_detector_idx < (unsigned int)i2c_dimm_device_detectors.size(); i2c_detector_idx++) - { - detection_string = i2c_dimm_device_detectors[i2c_detector_idx].name.c_str(); - - if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) - { - detector_settings["detectors"][detection_string] = true; - save_settings = true; - } - } - - /*-----------------------------------------------------*\ - | Loop through all I2C PCI detectors and see if any | - | need to be saved to the settings | - \*-----------------------------------------------------*/ - for(unsigned int i2c_pci_detector_idx = 0; i2c_pci_detector_idx < (unsigned int)i2c_pci_device_detectors.size(); i2c_pci_detector_idx++) - { - detection_string = i2c_pci_device_detectors[i2c_pci_detector_idx].name.c_str(); - - if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) - { - detector_settings["detectors"][detection_string] = true; - save_settings = true; - } - } - - /*-----------------------------------------------------*\ - | Loop through all HID detectors and see if any need to | - | be saved to the settings | - \*-----------------------------------------------------*/ - for(unsigned int hid_detector_idx = 0; hid_detector_idx < (unsigned int)hid_device_detectors.size(); hid_detector_idx++) - { - detection_string = hid_device_detectors[hid_detector_idx].name.c_str(); - - if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) - { - detector_settings["detectors"][detection_string] = true; - save_settings = true; - } - } - - /*-----------------------------------------------------*\ - | Loop through all HID wrapped detectors and see if any | - | need to be saved to the settings | - \*-----------------------------------------------------*/ - for(unsigned int hid_wrapped_detector_idx = 0; hid_wrapped_detector_idx < (unsigned int)hid_wrapped_device_detectors.size(); hid_wrapped_detector_idx++) - { - detection_string = hid_wrapped_device_detectors[hid_wrapped_detector_idx].name.c_str(); - - if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) - { - detector_settings["detectors"][detection_string] = true; - save_settings = true; - } - } - - /*-----------------------------------------------------*\ - | Loop through remaining detectors and see if any need | - | to be saved to the settings | - \*-----------------------------------------------------*/ - for(unsigned int detector_idx = 0; detector_idx < (unsigned int)device_detectors.size(); detector_idx++) - { - detection_string = device_detector_strings[detector_idx].c_str(); - - if(!(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detection_string))) - { - detector_settings["detectors"][detection_string] = true; - save_settings = true; - } - } - - /*-----------------------------------------------------*\ - | If there were any setting changes that need to be | - | saved, set the settings in the settings manager and | - | save them. | - \*-----------------------------------------------------*/ - if(save_settings) - { - LOG_INFO("[ResourceManager] Saving detector settings"); - - settings_manager->SetSettings("Detectors", detector_settings); - - settings_manager->SaveSettings(); - } -} - void ResourceManager::WaitForInitialization() { /*-----------------------------------------------------*\ @@ -2110,41 +757,3 @@ void ResourceManager::WaitForInitialization() std::this_thread::sleep_for(1ms); }; } - -void ResourceManager::WaitForDeviceDetection() -{ - DetectDeviceMutex.lock(); - DetectDeviceMutex.unlock(); -} - -bool ResourceManager::IsAnyDimmDetectorEnabled(json &detector_settings) -{ - for(unsigned int i2c_detector_idx = 0; i2c_detector_idx < i2c_dimm_device_detectors.size() && detection_is_required.load(); i2c_detector_idx++) - { - std::string detector_name_string = i2c_dimm_device_detectors[i2c_detector_idx].name.c_str(); - /*-------------------------------------------------*\ - | Check if this detector is enabled | - \*-------------------------------------------------*/ - if(detector_settings.contains("detectors") && detector_settings["detectors"].contains(detector_name_string) && - detector_settings["detectors"][detector_name_string] == true) - { - return true; - } - } - return false; -} - -bool ResourceManager::IsLocalClient() -{ - return(auto_connection_active); -} - -NetworkClient* ResourceManager::GetLocalClient() -{ - return(auto_connection_client); -} - -unsigned int ResourceManager::GetLocalClientProtocolVersion() -{ - return(auto_connection_client->GetProtocolVersion()); -} diff --git a/ResourceManager.h b/ResourceManager.h index cf08b2999..347102f2d 100644 --- a/ResourceManager.h +++ b/ResourceManager.h @@ -20,7 +20,7 @@ #include #include #include -#include "SPDWrapper.h" +#include "DetectionManager.h" #include "hidapi_wrapper.h" #include "i2c_smbus.h" #include "ResourceManagerInterface.h" @@ -28,11 +28,6 @@ using json = nlohmann::json; -#define HID_INTERFACE_ANY -1 -#define HID_USAGE_ANY -1 -#define HID_USAGE_PAGE_ANY -1 - -struct hid_device_info; class NetworkClient; class NetworkServer; class PluginManagerInterface; @@ -40,187 +35,75 @@ class ProfileManager; class RGBController; class SettingsManager; -typedef std::function I2CBusDetectorFunction; -typedef std::function DeviceDetectorFunction; -typedef std::function&)> I2CDeviceDetectorFunction; -typedef std::function&, const std::string&)> I2CDIMMDeviceDetectorFunction; -typedef std::function I2CPCIDeviceDetectorFunction; -typedef std::function HIDDeviceDetectorFunction; -typedef std::function HIDWrappedDeviceDetectorFunction; -typedef std::function DynamicDetectorFunction; -typedef std::function PreDetectionHookFunction; - -class BasicHIDBlock -{ -public: - std::string name; - uint16_t vid; - uint16_t pid; - int interface; - int usage_page; - int usage; - - bool compare(hid_device_info* info); -}; - -class HIDDeviceDetectorBlock : public BasicHIDBlock -{ -public: - HIDDeviceDetectorFunction function; -}; - -class HIDWrappedDeviceDetectorBlock : public BasicHIDBlock -{ -public: - HIDWrappedDeviceDetectorFunction function; -}; - -typedef struct -{ - std::string name; - I2CPCIDeviceDetectorFunction function; - uint16_t ven_id; - uint16_t dev_id; - uint16_t subven_id; - uint16_t subdev_id; - uint8_t i2c_addr; -} I2CPCIDeviceDetectorBlock; - -typedef struct -{ - std::string name; - I2CDIMMDeviceDetectorFunction function; - uint16_t jedec_id; - uint8_t dimm_type; -} I2CDIMMDeviceDetectorBlock; - -/*---------------------------------------------------------*\ -| Define a macro for QT lupdate to parse | -\*---------------------------------------------------------*/ -#define QT_TRANSLATE_NOOP(scope, x) x - -extern const char* I2C_ERR_WIN; -extern const char* I2C_ERR_LINUX; -extern const char* UDEV_MISSING; -extern const char* UDEV_MULTI; - class ResourceManager: public ResourceManagerInterface { public: - static ResourceManager *get(); - ResourceManager(); ~ResourceManager(); - void RegisterI2CBus(i2c_smbus_interface *); - std::vector & GetI2CBusses(); - - void RegisterRGBController(RGBController *rgb_controller); - void UnregisterRGBController(RGBController *rgb_controller); - - std::vector & GetRGBControllers(); - - void RegisterI2CBusDetector (I2CBusDetectorFunction detector); - void RegisterDeviceDetector (std::string name, DeviceDetectorFunction detector); - void RegisterI2CDeviceDetector (std::string name, I2CDeviceDetectorFunction detector); - void RegisterI2CDIMMDeviceDetector (std::string name, I2CDIMMDeviceDetectorFunction detector, uint16_t jedec_id, uint8_t dimm_type); - void RegisterI2CPCIDeviceDetector (std::string name, I2CPCIDeviceDetectorFunction detector, uint16_t ven_id, uint16_t dev_id, uint16_t subven_id, uint16_t subdev_id, uint8_t i2c_addr); - void RegisterHIDDeviceDetector (std::string name, - HIDDeviceDetectorFunction detector, - uint16_t vid, - uint16_t pid, - int interface = HID_INTERFACE_ANY, - int usage_page = HID_USAGE_PAGE_ANY, - int usage = HID_USAGE_ANY); - void RegisterHIDWrappedDeviceDetector (std::string name, - HIDWrappedDeviceDetectorFunction detector, - uint16_t vid, - uint16_t pid, - int interface = HID_INTERFACE_ANY, - int usage_page = HID_USAGE_PAGE_ANY, - int usage = HID_USAGE_ANY); - void RegisterDynamicDetector (std::string name, DynamicDetectorFunction detector); - void RegisterPreDetectionHook (PreDetectionHookFunction hook); - - void RegisterClientInfoChangeCallback(ClientInfoChangeCallback new_callback, void * new_callback_arg); - void RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg); - void RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void * new_callback_arg); - void RegisterDetectionStartCallback(DetectionStartCallback new_callback, void * new_callback_arg); - void RegisterDetectionEndCallback(DetectionEndCallback new_callback, void * new_callback_arg); - void RegisterI2CBusListChangeCallback(I2CBusListChangeCallback new_callback, void * new_callback_arg); - - void UnregisterClientInfoChangeCallback(ClientInfoChangeCallback new_callback, void * new_callback_arg); - void UnregisterDeviceListChangeCallback(DeviceListChangeCallback callback, void * callback_arg); - void UnregisterDetectionProgressCallback(DetectionProgressCallback callback, void *callback_arg); - void UnregisterDetectionStartCallback(DetectionStartCallback callback, void *callback_arg); - void UnregisterDetectionEndCallback(DetectionEndCallback callback, void *callback_arg); - void UnregisterI2CBusListChangeCallback(I2CBusListChangeCallback callback, void * callback_arg); - - bool GetDetectionEnabled(); - unsigned int GetDetectionPercent(); - const char* GetDetectionString(); - - filesystem::path GetConfigurationDirectory(); - - void RegisterNetworkClient(NetworkClient* new_client); - void UnregisterNetworkClient(NetworkClient* network_client); - - std::vector& GetClients(); - NetworkServer* GetServer(); - - PluginManagerInterface* GetPluginManager(); - ProfileManager* GetProfileManager(); - SettingsManager* GetSettingsManager(); - - void SetConfigurationDirectory(const filesystem::path &directory); - - void ProcessPreDetectionHooks(); // Consider making private - void ProcessDynamicDetectors(); // Consider making private - void UpdateDeviceList(); - void ClientInfoChanged(); - void DeviceListChanged(); - void DetectionProgressChanged(); - void I2CBusListChanged(); - - void Initialize(bool tryConnect, bool detectDevices, bool startServer, bool applyPostOptions); - - void Cleanup(); - - void DetectDevices(); - - void DisableDetection(); - - void RescanDevices(); - - void SetPluginManager(PluginManagerInterface* plugin_manager_ptr); - - void StopDeviceDetection(); - - void WaitForInitialization(); - void WaitForDeviceDetection(); - - bool IsLocalClient(); - NetworkClient* GetLocalClient(); - unsigned int GetLocalClientProtocolVersion(); - -private: - void UpdateDetectorSettings(); - void SetupConfigurationDirectory(); - bool AttemptLocalConnection(); - bool ProcessPreDetection(); - void ProcessPostDetection(); - bool IsAnyDimmDetectorEnabled(json &detector_settings); - void RunInBackgroundThread(std::function); - void BackgroundThreadFunction(); + /*-----------------------------------------------------*\ + | ResourceManager Global Instance Accessor | + \*-----------------------------------------------------*/ + static ResourceManager* get(); /*-----------------------------------------------------*\ - | Functions that must be run in the background thread | - | These are not related to STL coroutines, yet this | - | name is the most convenient | + | Resource Accessors | \*-----------------------------------------------------*/ - void InitCoroutine(); - void DetectDevicesCoroutine(); - void HidExitCoroutine(); + std::vector& GetClients(); + filesystem::path GetConfigurationDirectory(); + std::vector& GetI2CBusses(); + PluginManagerInterface* GetPluginManager(); + ProfileManager* GetProfileManager(); + std::vector& GetRGBControllers(); + NetworkServer* GetServer(); + SettingsManager* GetSettingsManager(); + + void SetConfigurationDirectory(const filesystem::path &directory); + void SetPluginManager(PluginManagerInterface* plugin_manager_ptr); + + /*-----------------------------------------------------*\ + | Network Client Registration | + \*-----------------------------------------------------*/ + void RegisterNetworkClient(NetworkClient* new_client); + void UnregisterNetworkClient(NetworkClient* network_client); + + /*-----------------------------------------------------*\ + | Local Client Accessors | + \*-----------------------------------------------------*/ + NetworkClient* GetLocalClient(); + unsigned int GetLocalClientProtocolVersion(); + bool IsLocalClient(); + + /*-----------------------------------------------------*\ + | Callback Registration Functions | + \*-----------------------------------------------------*/ + void RegisterResourceManagerCallback(ResourceManagerCallback new_callback, void * new_callback_arg); + void UnregisterResourceManagerCallback(ResourceManagerCallback new_callback, void * new_callback_arg); + + /*-----------------------------------------------------*\ + | Functions to manage detection | + \*-----------------------------------------------------*/ + bool GetDetectionEnabled(); + unsigned int GetDetectionPercent(); + std::string GetDetectionString(); + void StopDeviceDetection(); + void RescanDevices(); + void ClearLocalDevices(); + void UpdateDeviceList(); + void WaitForDetection(); + + /*-----------------------------------------------------*\ + | Functions to signal update callbacks | + \*-----------------------------------------------------*/ + void SignalResourceManagerUpdate(unsigned int update_reason); + + void Initialize(bool tryConnect, bool detectDevices, bool startServer, bool applyPostOptions); + + void WaitForInitialization(); + +private: + bool AttemptLocalConnection(); + void SetupConfigurationDirectory(); /*-----------------------------------------------------*\ | Static pointer to shared instance of ResourceManager | @@ -262,11 +145,6 @@ private: \*-----------------------------------------------------*/ std::atomic init_finished; - /*-----------------------------------------------------*\ - | Initial detection flag | - \*-----------------------------------------------------*/ - bool initial_detection; - /*-----------------------------------------------------*\ | Plugin Manager | \*-----------------------------------------------------*/ @@ -282,16 +160,9 @@ private: \*-----------------------------------------------------*/ SettingsManager* settings_manager; - /*-----------------------------------------------------*\ - | I2C/SMBus Interfaces | - \*-----------------------------------------------------*/ - std::vector busses; - /*-----------------------------------------------------*\ | RGBControllers | \*-----------------------------------------------------*/ - std::vector rgb_controllers_sizes; - std::vector rgb_controllers_hw; std::vector rgb_controllers; /*-----------------------------------------------------*\ @@ -305,75 +176,16 @@ private: std::vector clients; /*-----------------------------------------------------*\ - | Detectors | - \*-----------------------------------------------------*/ - std::vector device_detectors; - std::vector device_detector_strings; - std::vector i2c_bus_detectors; - std::vector i2c_device_detectors; - std::vector i2c_device_detector_strings; - std::vector i2c_dimm_device_detectors; - std::vector i2c_pci_device_detectors; - std::vector hid_device_detectors; - std::vector hid_wrapped_device_detectors; - std::vector dynamic_detectors; - std::vector dynamic_detector_strings; - std::vector pre_detection_hooks; - - bool dynamic_detectors_processed; - - /*-----------------------------------------------------*\ - | Detection Thread and Detection State | - \*-----------------------------------------------------*/ - std::thread * DetectDevicesThread; - std::mutex DetectDeviceMutex; - std::function ScheduledBackgroundFunction; - std::mutex BackgroundThreadStateMutex; - - /*-----------------------------------------------------*\ - | NOTE: wakes up the background detection thread | - \*-----------------------------------------------------*/ - std::condition_variable BackgroundFunctionStartTrigger; - - std::atomic background_thread_running; - std::atomic detection_is_required; - std::atomic detection_percent; - std::atomic detection_prev_size; - std::vector detection_size_entry_used; - const char* detection_string; - - /*-----------------------------------------------------*\ - | Client Info Changed Callback | - \*-----------------------------------------------------*/ - std::vector ClientInfoChangeCallbacks; - std::vector ClientInfoChangeCallbackArgs; - - /*-----------------------------------------------------*\ - | Device List Changed Callback | + | Device List Mutex | \*-----------------------------------------------------*/ std::mutex DeviceListChangeMutex; - std::vector DeviceListChangeCallbacks; - std::vector DeviceListChangeCallbackArgs; /*-----------------------------------------------------*\ - | Detection Progress, Start, and End Callbacks | + | ResourceManager Callbacks | \*-----------------------------------------------------*/ - std::mutex DetectionProgressMutex; - std::vector DetectionProgressCallbacks; - std::vector DetectionProgressCallbackArgs; - - std::vector DetectionStartCallbacks; - std::vector DetectionStartCallbackArgs; - - std::vector DetectionEndCallbacks; - std::vector DetectionEndCallbackArgs; - - /*-----------------------------------------------------*\ - | I2C/SMBus Adapter List Changed Callback | - \*-----------------------------------------------------*/ - std::mutex I2CBusListChangeMutex; - std::vector I2CBusListChangeCallbacks; - std::vector I2CBusListChangeCallbackArgs; + std::vector ResourceManagerCallbacks; + std::vector ResourceManagerCallbackArgs; + std::mutex ResourceManagerCallbackMutex; /*-----------------------------------------------------*\ | OpenRGB configuration directory path | diff --git a/ResourceManagerInterface.h b/ResourceManagerInterface.h index e7f6d359b..940977834 100644 --- a/ResourceManagerInterface.h +++ b/ResourceManagerInterface.h @@ -20,45 +20,50 @@ class ProfileManager; class RGBController; class SettingsManager; -typedef void (*ClientInfoChangeCallback)(void *); -typedef void (*DeviceListChangeCallback)(void *); -typedef void (*DetectionProgressCallback)(void *); -typedef void (*DetectionStartCallback)(void *); -typedef void (*DetectionEndCallback)(void *); -typedef void (*I2CBusListChangeCallback)(void *); +/*---------------------------------------------------------*\ +| Callback Types | +\*---------------------------------------------------------*/ +typedef void (*ResourceManagerCallback)(void *, unsigned int); + +/*---------------------------------------------------------*\ +| ResourceManager Update Reason Codes | +\*---------------------------------------------------------*/ +enum +{ + RESOURCEMANAGER_UPDATE_REASON_DETECTION_STARTED, /* Detection started */ + RESOURCEMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED, /* Detection progress changed */ + RESOURCEMANAGER_UPDATE_REASON_DETECTION_COMPLETE, /* Detection completed */ + RESOURCEMANAGER_UPDATE_REASON_CLIENT_INFO_UPDATED, /* NetworkClient info updated */ + RESOURCEMANAGER_UPDATE_REASON_I2C_BUS_LIST_UPDATED, /* I2C bus list updated */ + RESOURCEMANAGER_UPDATE_REASON_DEVICE_LIST_UPDATED, /* Device list updated */ +}; class ResourceManagerInterface { public: - virtual std::vector & GetI2CBusses() = 0; - - virtual void RegisterRGBController(RGBController *rgb_controller) = 0; - virtual void UnregisterRGBController(RGBController *rgb_controller) = 0; - - virtual void RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg) = 0; - virtual void RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void * new_callback_arg) = 0; - virtual void RegisterDetectionStartCallback(DetectionStartCallback new_callback, void * new_callback_arg) = 0; - virtual void RegisterDetectionEndCallback(DetectionEndCallback new_callback, void * new_callback_arg) = 0; - virtual void RegisterI2CBusListChangeCallback(I2CBusListChangeCallback new_callback, void * new_callback_arg) = 0; - - virtual void UnregisterDeviceListChangeCallback(DeviceListChangeCallback callback, void * callback_arg) = 0; - virtual void UnregisterDetectionProgressCallback(DetectionProgressCallback callback, void *callback_arg) = 0; - virtual void UnregisterDetectionStartCallback(DetectionStartCallback callback, void *callback_arg) = 0; - virtual void UnregisterDetectionEndCallback(DetectionEndCallback callback, void *callback_arg) = 0; - virtual void UnregisterI2CBusListChangeCallback(I2CBusListChangeCallback callback, void * callback_arg) = 0; - - virtual std::vector & GetRGBControllers() = 0; - - virtual unsigned int GetDetectionPercent() = 0; - + /*-----------------------------------------------------*\ + | Resource Accessors | + \*-----------------------------------------------------*/ virtual filesystem::path GetConfigurationDirectory() = 0; - + virtual std::vector & GetI2CBusses() = 0; virtual PluginManagerInterface* GetPluginManager() = 0; virtual ProfileManager* GetProfileManager() = 0; + virtual std::vector & GetRGBControllers() = 0; virtual SettingsManager* GetSettingsManager() = 0; - virtual void UpdateDeviceList() = 0; - virtual void WaitForDeviceDetection() = 0; + /*-----------------------------------------------------*\ + | Callback Registration Functions | + \*-----------------------------------------------------*/ + virtual void RegisterResourceManagerCallback(ResourceManagerCallback new_callback, void * new_callback_arg) = 0; + virtual void UnregisterResourceManagerCallback(ResourceManagerCallback new_callback, void * new_callback_arg) = 0; + + /*-----------------------------------------------------*\ + | Functions to manage detection | + \*-----------------------------------------------------*/ + virtual bool GetDetectionEnabled() = 0; + virtual unsigned int GetDetectionPercent() = 0; + virtual std::string GetDetectionString() = 0; + virtual void WaitForDetection() = 0; protected: virtual ~ResourceManagerInterface() {}; diff --git a/cli.cpp b/cli.cpp index 514ba1f01..4542cd9f7 100644 --- a/cli.cpp +++ b/cli.cpp @@ -458,7 +458,7 @@ void OptionVersion() void OptionListDevices(std::vector& rgb_controllers) { - ResourceManager::get()->WaitForDeviceDetection(); + ResourceManager::get()->WaitForDetection(); for(std::size_t controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++) { @@ -562,7 +562,7 @@ void OptionListDevices(std::vector& rgb_controllers) bool OptionDevice(std::vector* current_devices, std::string argument, Options* options, std::vector& rgb_controllers) { bool found = false; - ResourceManager::get()->WaitForDeviceDetection(); + ResourceManager::get()->WaitForDetection(); try { @@ -640,7 +640,7 @@ bool OptionDevice(std::vector* current_devices, std::string argum bool OptionZone(std::vector* current_devices, std::string argument, Options* /*options*/, std::vector& rgb_controllers) { bool found = false; - ResourceManager::get()->WaitForDeviceDetection(); + ResourceManager::get()->WaitForDetection(); try { @@ -832,7 +832,7 @@ bool OptionSize(std::vector* current_devices, std::string argumen { const unsigned int new_size = std::stoi(argument); - ResourceManager::get()->WaitForDeviceDetection(); + ResourceManager::get()->WaitForDetection(); for(size_t i = 0; i < current_devices->size(); i++) { @@ -873,7 +873,7 @@ bool OptionSize(std::vector* current_devices, std::string argumen bool OptionProfile(std::string argument, std::vector& rgb_controllers) { - ResourceManager::get()->WaitForDeviceDetection(); + ResourceManager::get()->WaitForDetection(); /*---------------------------------------------------------*\ | Attempt to load profile | @@ -1713,7 +1713,7 @@ unsigned int cli_post_detection() /*---------------------------------------------------------*\ | Wait for device detection | \*---------------------------------------------------------*/ - ResourceManager::get()->WaitForDeviceDetection(); + ResourceManager::get()->WaitForDetection(); /*---------------------------------------------------------*\ | Get controller list from resource manager | diff --git a/i2c_smbus/Linux/i2c_smbus_linux.cpp b/i2c_smbus/Linux/i2c_smbus_linux.cpp index a887fd0c5..3a09dedd7 100644 --- a/i2c_smbus/Linux/i2c_smbus_linux.cpp +++ b/i2c_smbus/Linux/i2c_smbus_linux.cpp @@ -64,7 +64,7 @@ s32 i2c_smbus_linux::i2c_xfer(u8 addr, char read_write, int* size, u8* data) return ret_val; } -#include "Detector.h" +#include "DetectionManager.h" #include #include #include @@ -240,7 +240,7 @@ bool i2c_smbus_linux_detect() bus->pci_subsystem_vendor = pci_subsystem_vendor; bus->port_id = port_id; bus->bus_id = bus_id; - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); } else { diff --git a/i2c_smbus/MacOS/i2c_smbus_i801.cpp b/i2c_smbus/MacOS/i2c_smbus_i801.cpp index 4b3de493b..1ea45535a 100644 --- a/i2c_smbus/MacOS/i2c_smbus_i801.cpp +++ b/i2c_smbus/MacOS/i2c_smbus_i801.cpp @@ -12,7 +12,7 @@ #include "macUSPCIOAccess.h" -#include "Detector.h" +#include "DetectionManager.h" #include "i2c_smbus_i801.h" #include "LogManager.h" #include "ResourceManager.h" @@ -534,7 +534,7 @@ bool i2c_smbus_i801_detect() snprintf(bus->device_name, 512, "Intel(R) SMBus - %X", bus->pci_device); ((i2c_smbus_i801 *)bus)->i801_smba = ReadConfigPortWord(0x20) & 0xFFFE; - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); return(true); } diff --git a/i2c_smbus/MacOS/i2c_smbus_nct6775.cpp b/i2c_smbus/MacOS/i2c_smbus_nct6775.cpp index 80dd8756c..a9609b975 100644 --- a/i2c_smbus/MacOS/i2c_smbus_nct6775.cpp +++ b/i2c_smbus/MacOS/i2c_smbus_nct6775.cpp @@ -11,7 +11,7 @@ #include "macUSPCIOAccess.h" -#include "Detector.h" +#include "DetectionManager.h" #include "i2c_smbus_nct6775.h" #include "LogManager.h" #include "ResourceManager.h" @@ -266,7 +266,7 @@ bool i2c_smbus_nct6775_detect() break; } - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); } return(true); diff --git a/i2c_smbus/MacOS/i2c_smbus_piix4.cpp b/i2c_smbus/MacOS/i2c_smbus_piix4.cpp index bcd83e383..48034e90d 100644 --- a/i2c_smbus/MacOS/i2c_smbus_piix4.cpp +++ b/i2c_smbus/MacOS/i2c_smbus_piix4.cpp @@ -13,7 +13,7 @@ #include #include "macUSPCIOAccess.h" -#include "Detector.h" +#include "DetectionManager.h" #include "i2c_smbus_piix4.h" #include "LogManager.h" #include "pci_ids.h" @@ -271,7 +271,7 @@ bool i2c_smbus_piix4_detect() bus->pci_subsystem_device = subsystem_device_id; strcpy(bus->device_name, "Advanced Micro Devices, Inc PIIX4 SMBus at 0x0B00"); ((i2c_smbus_piix4 *)bus)->piix4_smba = 0x0B00; - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); bus = new i2c_smbus_piix4(); bus->pci_vendor = vendor_id; @@ -280,7 +280,7 @@ bool i2c_smbus_piix4_detect() bus->pci_subsystem_device = subsystem_device_id; ((i2c_smbus_piix4 *)bus)->piix4_smba = 0x0B20; strcpy(bus->device_name, "Advanced Micro Devices, Inc PIIX4 SMBus at 0x0B20"); - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); return(true); } diff --git a/i2c_smbus/Windows/i2c_smbus_amdadl.cpp b/i2c_smbus/Windows/i2c_smbus_amdadl.cpp index e35c373c1..e781d08b2 100644 --- a/i2c_smbus/Windows/i2c_smbus_amdadl.cpp +++ b/i2c_smbus/Windows/i2c_smbus_amdadl.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "i2c_smbus_amdadl.h" #include "LogManager.h" #include "pci_ids.h" @@ -297,7 +297,7 @@ bool i2c_smbus_amdadl_detect() } LOG_INFO("ADL GPU Device %04X:%04X Subsystem: %04X:%04X", adl_bus->pci_vendor, adl_bus->pci_device,adl_bus->pci_subsystem_vendor,adl_bus->pci_subsystem_device); - ResourceManager::get()->RegisterI2CBus(adl_bus); + DetectionManager::get()->RegisterI2CBus(adl_bus); } } } diff --git a/i2c_smbus/Windows/i2c_smbus_nvapi.cpp b/i2c_smbus/Windows/i2c_smbus_nvapi.cpp index eeb188097..6bff1c66e 100644 --- a/i2c_smbus/Windows/i2c_smbus_nvapi.cpp +++ b/i2c_smbus/Windows/i2c_smbus_nvapi.cpp @@ -162,7 +162,7 @@ s32 i2c_smbus_nvapi::i2c_xfer(u8 addr, char read_write, int* size, u8* data) return(ret); } -#include "Detector.h" +#include "DetectionManager.h" bool i2c_smbus_nvapi_detect() { @@ -195,7 +195,7 @@ bool i2c_smbus_nvapi_detect() nvapi_bus->port_id = 1; } - ResourceManager::get()->RegisterI2CBus(nvapi_bus); + DetectionManager::get()->RegisterI2CBus(nvapi_bus); } return(true); diff --git a/i2c_smbus/Windows/i2c_smbus_pawnio.cpp b/i2c_smbus/Windows/i2c_smbus_pawnio.cpp index e1469063d..ac6d204c0 100644 --- a/i2c_smbus/Windows/i2c_smbus_pawnio.cpp +++ b/i2c_smbus/Windows/i2c_smbus_pawnio.cpp @@ -10,7 +10,7 @@ \*---------------------------------------------------------*/ #include -#include "Detector.h" +#include "DetectionManager.h" #include "i2c_smbus_pawnio.h" #include "LogManager.h" #include "PawnIOLib.h" @@ -309,7 +309,7 @@ bool i2c_smbus_pawnio_detect() if(i2c_smbus_pawnio::start_pawnio("SmbusI801.bin", &pawnio_handle) == S_OK) { bus = new i2c_smbus_pawnio(pawnio_handle, "i801"); - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); } /*-----------------------------------------------------*\ @@ -323,7 +323,7 @@ bool i2c_smbus_pawnio_detect() piix4_port_sel(pawnio_handle, 0); bus = new i2c_smbus_pawnio(pawnio_handle, "piix4"); - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); } /*-----------------------------------------------------*\ @@ -337,7 +337,7 @@ bool i2c_smbus_pawnio_detect() piix4_port_sel(pawnio_handle, 1); bus = new i2c_smbus_pawnio(pawnio_handle, "piix4"); - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); } /*-----------------------------------------------------*\ @@ -346,7 +346,7 @@ bool i2c_smbus_pawnio_detect() if(i2c_smbus_pawnio::start_pawnio("SmbusNCT6793.bin", &pawnio_handle) == S_OK) { bus = new i2c_smbus_pawnio(pawnio_handle, "NCT6793"); - ResourceManager::get()->RegisterI2CBus(bus); + DetectionManager::get()->RegisterI2CBus(bus); } return(true); diff --git a/qt/ManualDevicesSettingsPage/ManualDevicesSettingsPage.cpp b/qt/ManualDevicesSettingsPage/ManualDevicesSettingsPage.cpp index 27499ae2b..2237fdbcc 100644 --- a/qt/ManualDevicesSettingsPage/ManualDevicesSettingsPage.cpp +++ b/qt/ManualDevicesSettingsPage/ManualDevicesSettingsPage.cpp @@ -17,11 +17,16 @@ #include -static void ManualDevicesPageReloadCallback(void* this_ptr) +static void ManualDevicesPageResourceManagerCallback(void* this_ptr, unsigned int update_reason) { ManualDevicesSettingsPage * this_obj = (ManualDevicesSettingsPage *)this_ptr; - QMetaObject::invokeMethod(this_obj, "reloadList", Qt::QueuedConnection); + switch(update_reason) + { + case RESOURCEMANAGER_UPDATE_REASON_DETECTION_COMPLETE: + QMetaObject::invokeMethod(this_obj, "reloadList", Qt::QueuedConnection); + break; + } } ManualDevicesSettingsPage::ManualDevicesSettingsPage(QWidget *parent) : @@ -29,7 +34,7 @@ ManualDevicesSettingsPage::ManualDevicesSettingsPage(QWidget *parent) : ui(new Ui::ManualDevicesSettingsPage) { ui->setupUi(this); - ResourceManager::get()->RegisterDetectionEndCallback(&ManualDevicesPageReloadCallback, this); + ResourceManager::get()->RegisterResourceManagerCallback(&ManualDevicesPageResourceManagerCallback, this); addDeviceMenu = new QMenu(this); ui->addDeviceButton->setMenu(addDeviceMenu); @@ -46,7 +51,7 @@ ManualDevicesSettingsPage::ManualDevicesSettingsPage(QWidget *parent) : ManualDevicesSettingsPage::~ManualDevicesSettingsPage() { - ResourceManager::get()->UnregisterDetectionEndCallback(&ManualDevicesPageReloadCallback, this); + ResourceManager::get()->UnregisterResourceManagerCallback(&ManualDevicesPageResourceManagerCallback, this); clearList(); delete ui; } diff --git a/qt/OpenRGBClientInfoPage/OpenRGBClientInfoPage.cpp b/qt/OpenRGBClientInfoPage/OpenRGBClientInfoPage.cpp index d1e66e5a1..a4aae76a5 100644 --- a/qt/OpenRGBClientInfoPage/OpenRGBClientInfoPage.cpp +++ b/qt/OpenRGBClientInfoPage/OpenRGBClientInfoPage.cpp @@ -15,11 +15,16 @@ #include "SettingsManager.h" #include "ui_OpenRGBClientInfoPage.h" -static void UpdateInfoCallback(void * this_ptr) +static void OpenRGBClientInfoPageResourceManagerCallback(void * this_ptr, unsigned int update_reason) { OpenRGBClientInfoPage * this_obj = (OpenRGBClientInfoPage *)this_ptr; - QMetaObject::invokeMethod(this_obj, "UpdateInfo", Qt::QueuedConnection); + switch(update_reason) + { + case RESOURCEMANAGER_UPDATE_REASON_CLIENT_INFO_UPDATED: + QMetaObject::invokeMethod(this_obj, "UpdateInfo", Qt::QueuedConnection); + break; + } } class NetworkClientPointer : public QObject @@ -43,7 +48,7 @@ OpenRGBClientInfoPage::OpenRGBClientInfoPage(QWidget *parent) : /*-----------------------------------------------------*\ | Register callbacks with resource manager | \*-----------------------------------------------------*/ - ResourceManager::get()->RegisterClientInfoChangeCallback(UpdateInfoCallback, this); + ResourceManager::get()->RegisterResourceManagerCallback(OpenRGBClientInfoPageResourceManagerCallback, this); /*-----------------------------------------------------*\ | Update the information view | @@ -53,7 +58,10 @@ OpenRGBClientInfoPage::OpenRGBClientInfoPage(QWidget *parent) : OpenRGBClientInfoPage::~OpenRGBClientInfoPage() { - + /*-----------------------------------------------------*\ + | Unregister callbacks with resource manager | + \*-----------------------------------------------------*/ + ResourceManager::get()->UnregisterResourceManagerCallback(OpenRGBClientInfoPageResourceManagerCallback, this); } void OpenRGBClientInfoPage::changeEvent(QEvent *event) @@ -279,8 +287,6 @@ void OpenRGBClientInfoPage::on_ClientConnectButton_clicked() | Add new client to list and register update callback | \*-----------------------------------------------------*/ ResourceManager::get()->RegisterNetworkClient(rgb_client); - - rgb_client->RegisterClientInfoChangeCallback(UpdateInfoCallback, this); } void OpenRGBClientInfoPage::onClientDisconnectButton_clicked(QObject * arg) diff --git a/qt/OpenRGBDialog/OpenRGBDialog.cpp b/qt/OpenRGBDialog/OpenRGBDialog.cpp index e431b9788..d279901ff 100644 --- a/qt/OpenRGBDialog/OpenRGBDialog.cpp +++ b/qt/OpenRGBDialog/OpenRGBDialog.cpp @@ -122,18 +122,28 @@ static int GetIcon(device_type type) return icon; } -static void UpdateDeviceListCallback(void * this_ptr) +static void OpenRGBDialogResourceManagerCallback(void * this_ptr, unsigned int update_reason) { OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; - QMetaObject::invokeMethod(this_obj, "onDeviceListUpdated", Qt::QueuedConnection); -} + switch(update_reason) + { + case RESOURCEMANAGER_UPDATE_REASON_DETECTION_STARTED: + QMetaObject::invokeMethod(this_obj, "onDetectionStarted", Qt::QueuedConnection); + break; -static void UpdateDetectionProgressCallback(void * this_ptr) -{ - OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; + case RESOURCEMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED: + QMetaObject::invokeMethod(this_obj, "onDetectionProgressUpdated", Qt::QueuedConnection); + break; - QMetaObject::invokeMethod(this_obj, "onDetectionProgressUpdated", Qt::QueuedConnection); + case RESOURCEMANAGER_UPDATE_REASON_DETECTION_COMPLETE: + QMetaObject::invokeMethod(this_obj, "onDetectionEnded", Qt::QueuedConnection); + break; + + case RESOURCEMANAGER_UPDATE_REASON_DEVICE_LIST_UPDATED: + QMetaObject::invokeMethod(this_obj, "onDeviceListUpdated", Qt::QueuedConnection); + break; + } } static void CreatePluginCallback(void * this_ptr, OpenRGBPluginEntry* plugin) @@ -150,20 +160,6 @@ static void DeletePluginCallback(void * this_ptr, OpenRGBPluginEntry* plugin) this_obj->RemovePlugin(plugin); } -static void DetectionStartedCallback(void * this_ptr) -{ - OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; - - QMetaObject::invokeMethod(this_obj, "onDetectionStarted", Qt::QueuedConnection); -} - -static void DetectionEndedCallback(void * this_ptr) -{ - OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; - - QMetaObject::invokeMethod(this_obj, "onDetectionEnded", Qt::QueuedConnection); -} - static void DialogShowCallback(void * this_ptr, PLogMessage msg) { OpenRGBDialog * this_obj = (OpenRGBDialog *)this_ptr; @@ -264,13 +260,9 @@ OpenRGBDialog::OpenRGBDialog(QWidget *parent) : QMainWindow(parent), ui(new Ui:: } /*-----------------------------------------------------*\ - | Register detection progress callback with resource | - | manager | + | Register resource manager callbacks | \*-----------------------------------------------------*/ - ResourceManager::get()->RegisterDetectionProgressCallback(UpdateDetectionProgressCallback, this); - ResourceManager::get()->RegisterDeviceListChangeCallback(UpdateDeviceListCallback, this); - ResourceManager::get()->RegisterDetectionStartCallback(DetectionStartedCallback, this); - ResourceManager::get()->RegisterDetectionEndCallback(DetectionEndedCallback, this); + ResourceManager::get()->RegisterResourceManagerCallback(OpenRGBDialogResourceManagerCallback, this); /*-----------------------------------------------------*\ | Register dialog show callback with log manager | @@ -573,7 +565,7 @@ void OpenRGBDialog::changeEvent(QEvent *event) void OpenRGBDialog::closeEvent(QCloseEvent *event) { - ResourceManager::get()->WaitForDeviceDetection(); + ResourceManager::get()->WaitForDetection(); if (IsMinimizeOnClose() && !this->isHidden() && event->spontaneous()) { diff --git a/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.cpp b/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.cpp index 682c6dc8e..445706f93 100644 --- a/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.cpp +++ b/qt/OpenRGBSystemInfoPage/OpenRGBSystemInfoPage.cpp @@ -12,11 +12,16 @@ #include "ResourceManager.h" #include "i2c_tools.h" -static void UpdateBusListCallback(void * this_ptr) +static void OpenRGBSystemInfoPageResourceManagerCallback(void * this_ptr, unsigned int update_reason) { OpenRGBSystemInfoPage * this_obj = (OpenRGBSystemInfoPage *)this_ptr; - QMetaObject::invokeMethod(this_obj, "UpdateBusList", Qt::QueuedConnection); + switch(update_reason) + { + case RESOURCEMANAGER_UPDATE_REASON_I2C_BUS_LIST_UPDATED: + QMetaObject::invokeMethod(this_obj, "UpdateBusList", Qt::QueuedConnection); + break; + } } OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector& bus, QWidget *parent) : @@ -36,7 +41,7 @@ OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector& /*-----------------------------------------------------*\ | Register I2C bus list change callback | \*-----------------------------------------------------*/ - ResourceManager::get()->RegisterI2CBusListChangeCallback(UpdateBusListCallback, this); + ResourceManager::get()->RegisterResourceManagerCallback(OpenRGBSystemInfoPageResourceManagerCallback, this); /*-----------------------------------------------------*\ | Update the bus list | @@ -53,6 +58,11 @@ OpenRGBSystemInfoPage::OpenRGBSystemInfoPage(std::vector& OpenRGBSystemInfoPage::~OpenRGBSystemInfoPage() { + /*-----------------------------------------------------*\ + | Unregister I2C bus list change callback | + \*-----------------------------------------------------*/ + ResourceManager::get()->UnregisterResourceManagerCallback(OpenRGBSystemInfoPageResourceManagerCallback, this); + delete ui; } diff --git a/startup/main_FreeBSD_Linux_MacOS.cpp b/startup/main_FreeBSD_Linux_MacOS.cpp index 8263f4544..82326cb6c 100644 --- a/startup/main_FreeBSD_Linux_MacOS.cpp +++ b/startup/main_FreeBSD_Linux_MacOS.cpp @@ -87,11 +87,6 @@ int main(int argc, char* argv[]) } } - /*-----------------------------------------------------*\ - | Perform ResourceManager cleanup before exiting | - \*-----------------------------------------------------*/ - ResourceManager::get()->Cleanup(); - LOG_TRACE("OpenRGB finishing with exit code %d", exitval); /*-----------------------------------------------------*\ diff --git a/startup/main_Windows.cpp b/startup/main_Windows.cpp index a7560a910..ea1bb4ebd 100644 --- a/startup/main_Windows.cpp +++ b/startup/main_Windows.cpp @@ -51,43 +51,50 @@ static int detection_pass; static unsigned int lastpercent = 101; /*---------------------------------------------------------*\ -| ServiceStartupProgress | +| ServiceResourceManagerCallback | | | | Report detection progress when running as a service | \*---------------------------------------------------------*/ -static void ServiceStartupProgress(void*) +static void ServiceResourceManagerCallback(void *, unsigned int update_reason) { - unsigned int percent = ResourceManager::get()->GetDetectionPercent(); - unsigned int estimate; - - percent = std::clamp(percent, 0u, 100u); - - if(lastpercent > percent) + switch(update_reason) { - detection_pass += 1; - } + case RESOURCEMANAGER_UPDATE_REASON_DETECTION_PROGRESS_CHANGED: + { + unsigned int percent = ResourceManager::get()->GetDetectionPercent(); + unsigned int estimate; - lastpercent = percent; + percent = std::clamp(percent, 0u, 100u); - switch(detection_pass) - { - case 0: - percent = 0; - break; - case 1: - percent = percent * 4 / 5; - break; - case 2: - percent = percent / 5 + 80; - break; - default: - percent = 100; + if(lastpercent > percent) + { + detection_pass += 1; + } + + lastpercent = percent; + + switch(detection_pass) + { + case 0: + percent = 0; + break; + case 1: + percent = percent * 4 / 5; + break; + case 2: + percent = percent / 5 + 80; + break; + default: + percent = 100; + break; + } + + estimate = (100 - percent) / 5 + 10; + + ReportServiceStatus(SERVICE_START_PENDING, NO_ERROR, estimate * 1000); + } break; } - - estimate = (100 - percent) / 5 + 10; - - ReportServiceStatus(SERVICE_START_PENDING, NO_ERROR, estimate * 1000); } /*---------------------------------------------------------*\ @@ -588,7 +595,7 @@ static int common_main(int argc, char* argv[]) \*-----------------------------------------------------*/ if(started_as_service) { - ResourceManager::get()->RegisterDetectionProgressCallback(ServiceStartupProgress, NULL); + ResourceManager::get()->RegisterResourceManagerCallback(ServiceResourceManagerCallback, NULL); } /*-----------------------------------------------------*\ @@ -604,7 +611,7 @@ static int common_main(int argc, char* argv[]) \*-----------------------------------------------------*/ if(started_as_service) { - ResourceManager::get()->UnregisterDetectionProgressCallback(ServiceStartupProgress, NULL); + ResourceManager::get()->UnregisterResourceManagerCallback(ServiceResourceManagerCallback, NULL); } /*-----------------------------------------------------*\ @@ -624,11 +631,6 @@ static int common_main(int argc, char* argv[]) } } - /*-----------------------------------------------------*\ - | Perform ResourceManager cleanup before exiting | - \*-----------------------------------------------------*/ - ResourceManager::get()->Cleanup(); - LOG_TRACE("OpenRGB finishing with exit code %d", exitval); return exitval;