From 49e4f00aff6dab0966d683e80fb9d12a6d2fceac Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Wed, 13 Aug 2025 11:49:45 -0500 Subject: [PATCH] Store name in MSIMysticLightControllers to avoid setting it in detectors --- .../MSIMysticLight112Controller.cpp | 36 ++------ .../MSIMysticLight112Controller.h | 29 ++++--- .../RGBController_MSIMysticLight112.cpp | 5 +- .../RGBController_MSIMysticLight112.h | 4 +- .../MSIMysticLight162Controller.cpp | 38 ++------ .../MSIMysticLight162Controller.h | 29 ++++--- .../RGBController_MSIMysticLight162.cpp | 2 +- .../MSIMysticLight185Controller.cpp | 40 ++------- .../MSIMysticLight185Controller.h | 35 ++++---- .../RGBController_MSIMysticLight185.cpp | 2 +- .../MSIMysticLight761Controller.cpp | 86 +++++++------------ .../MSIMysticLight761Controller.h | 30 +++---- .../RGBController_MSIMysticLight761.cpp | 4 +- .../MSIMysticLightControllerDetect.cpp | 38 ++++---- 14 files changed, 138 insertions(+), 240 deletions(-) diff --git a/Controllers/MSIMysticLightController/MSIMysticLight112Controller/MSIMysticLight112Controller.cpp b/Controllers/MSIMysticLightController/MSIMysticLight112Controller/MSIMysticLight112Controller.cpp index a80b5169..699567df 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight112Controller/MSIMysticLight112Controller.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight112Controller/MSIMysticLight112Controller.cpp @@ -32,20 +32,19 @@ const std::vector zones_set = MSI_ZONE_ON_BOARD_LED_0 }; - MSIMysticLight112Controller::MSIMysticLight112Controller ( hid_device* handle, - const char *path + const char* path, + std::string dev_name ) { - dev = handle; + dev = handle; + location = path; + name = dev_name; if(dev) { - location = path; - - ReadName(); ReadFwVersion(); ReadSettings(); } @@ -385,31 +384,6 @@ bool MSIMysticLight112Controller::ReadFwVersion() return(ret_val > 0); } -void MSIMysticLight112Controller::ReadName() -{ - wchar_t tname[256]; - - /*-----------------------------------------------------*\ - | Get the manufacturer string from HID | - \*-----------------------------------------------------*/ - hid_get_manufacturer_string(dev, tname, 256); - - /*-----------------------------------------------------*\ - | Convert to std::string | - \*-----------------------------------------------------*/ - name = StringUtils::wstring_to_string(tname); - - /*-----------------------------------------------------*\ - | Get the product string from HID | - \*-----------------------------------------------------*/ - hid_get_product_string(dev, tname, 256); - - /*-----------------------------------------------------*\ - | Append the product string to the manufacturer string | - \*-----------------------------------------------------*/ - name.append(" ").append(StringUtils::wstring_to_string(tname)); -} - MSI_MODE MSIMysticLight112Controller::GetMode() { return (MSI_MODE)data.on_board_led.effect; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight112Controller/MSIMysticLight112Controller.h b/Controllers/MSIMysticLightController/MSIMysticLight112Controller/MSIMysticLight112Controller.h index abd5de21..3e5e1ca7 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight112Controller/MSIMysticLight112Controller.h +++ b/Controllers/MSIMysticLightController/MSIMysticLight112Controller/MSIMysticLight112Controller.h @@ -21,10 +21,12 @@ class MSIMysticLight112Controller { public: MSIMysticLight112Controller - ( - hid_device* handle, - const char *path - ); + ( + hid_device* handle, + const char* path, + std::string dev_name + ); + ~MSIMysticLight112Controller(); void SetMode @@ -77,26 +79,17 @@ public: std::string GetFWVersion(); std::string GetSerial(); - void SetDirectMode ( bool mode ); + bool IsDirectModeActive() { return direct_mode; } size_t GetMaxOnboardLeds(); const std::vector* GetSupportedZones() { return supported_zones; } private: - bool ReadSettings(); - bool ReadFwVersion(); - void ReadName(); - ZoneData* GetZoneData - ( - FeaturePacket_112& dataPacket, - MSI_ZONE zone - ); - hid_device* dev; std::string name; std::string location; @@ -108,4 +101,12 @@ private: bool direct_mode; size_t numof_onboard_leds; const std::vector* supported_zones; + + bool ReadSettings(); + bool ReadFwVersion(); + ZoneData* GetZoneData + ( + FeaturePacket_112& dataPacket, + MSI_ZONE zone + ); }; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight112Controller/RGBController_MSIMysticLight112.cpp b/Controllers/MSIMysticLightController/MSIMysticLight112Controller/RGBController_MSIMysticLight112.cpp index 7f64ef81..90424690 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight112Controller/RGBController_MSIMysticLight112.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight112Controller/RGBController_MSIMysticLight112.cpp @@ -27,11 +27,8 @@ const ZoneDescription led_zones[] = ZoneDescription{ "Onboard LEDs", MSI_ZONE_ON_BOARD_LED_0 } }; - static std::vector zone_description; - - /**------------------------------------------------------------------*\ @name MSI Mystic Light (112 Byte) @category Motherboard @@ -48,7 +45,7 @@ RGBController_MSIMysticLight112::RGBController_MSIMysticLight112 MSIMysticLight112Controller* controller_ptr ) { - controller = controller_ptr; + controller = controller_ptr; name = controller->GetDeviceName(); vendor = "MSI"; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight112Controller/RGBController_MSIMysticLight112.h b/Controllers/MSIMysticLightController/MSIMysticLight112Controller/RGBController_MSIMysticLight112.h index 3f359126..c8cac39a 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight112Controller/RGBController_MSIMysticLight112.h +++ b/Controllers/MSIMysticLightController/MSIMysticLight112Controller/RGBController_MSIMysticLight112.h @@ -31,6 +31,8 @@ public: void DeviceSaveMode(); private: + MSIMysticLight112Controller* controller; + void SetupModes(); void UpdateLed ( @@ -45,6 +47,4 @@ private: ); int GetDeviceMode(); void GetDeviceConfig(); - - MSIMysticLight112Controller* controller; }; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight162Controller/MSIMysticLight162Controller.cpp b/Controllers/MSIMysticLightController/MSIMysticLight162Controller/MSIMysticLight162Controller.cpp index ce2cee37..82bfb566 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight162Controller/MSIMysticLight162Controller.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight162Controller/MSIMysticLight162Controller.cpp @@ -57,7 +57,6 @@ const std::vector zones_set3 = MSI_ZONE_ON_BOARD_LED_0 }; - /*-----------------------------------------------------------------------------------------------------------------------------*\ | Definition of the board sepcific configurations (number of onboard LEDs and supported zones). | | | @@ -83,17 +82,17 @@ static const mystic_light_162_config board_configs[] = MSIMysticLight162Controller::MSIMysticLight162Controller ( hid_device* handle, - const char *path, - unsigned short pid + const char* path, + unsigned short pid, + std::string dev_name ) { - dev = handle; + dev = handle; + location = path; + name = dev_name; if(dev) { - location = path; - - ReadName(); ReadFwVersion(); ReadSettings(); } @@ -408,31 +407,6 @@ bool MSIMysticLight162Controller::ReadFwVersion() return(ret_val > 0); } -void MSIMysticLight162Controller::ReadName() -{ - wchar_t tname[256]; - - /*-----------------------------------------------------*\ - | Get the manufacturer string from HID | - \*-----------------------------------------------------*/ - hid_get_manufacturer_string(dev, tname, 256); - - /*-----------------------------------------------------*\ - | Convert to std::string | - \*-----------------------------------------------------*/ - name = StringUtils::wstring_to_string(tname); - - /*-----------------------------------------------------*\ - | Get the product string from HID | - \*-----------------------------------------------------*/ - hid_get_product_string(dev, tname, 256); - - /*-----------------------------------------------------*\ - | Append the product string to the manufacturer string | - \*-----------------------------------------------------*/ - name.append(" ").append(StringUtils::wstring_to_string(tname)); -} - MSI_MODE MSIMysticLight162Controller::GetMode() { return (MSI_MODE)data.on_board_led.effect; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight162Controller/MSIMysticLight162Controller.h b/Controllers/MSIMysticLightController/MSIMysticLight162Controller/MSIMysticLight162Controller.h index aa26907d..67df42a6 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight162Controller/MSIMysticLight162Controller.h +++ b/Controllers/MSIMysticLightController/MSIMysticLight162Controller/MSIMysticLight162Controller.h @@ -22,11 +22,13 @@ class MSIMysticLight162Controller { public: MSIMysticLight162Controller - ( - hid_device* handle, - const char *path, - unsigned short pid - ); + ( + hid_device* handle, + const char* path, + unsigned short pid, + std::string dev_name + ); + ~MSIMysticLight162Controller(); void SetMode @@ -76,15 +78,6 @@ public: GetSupportedZones() { return supported_zones; } private: - bool ReadSettings(); - bool ReadFwVersion(); - void ReadName(); - ZoneData* GetZoneData - ( - FeaturePacket_162& dataPacket, - MSI_ZONE zone - ); - hid_device* dev; std::string name; std::string location; @@ -94,4 +87,12 @@ private: FeaturePacket_162 data; size_t numof_onboard_leds; const std::vector* supported_zones; + + bool ReadSettings(); + bool ReadFwVersion(); + ZoneData* GetZoneData + ( + FeaturePacket_162& dataPacket, + MSI_ZONE zone + ); }; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight162Controller/RGBController_MSIMysticLight162.cpp b/Controllers/MSIMysticLightController/MSIMysticLight162Controller/RGBController_MSIMysticLight162.cpp index 1fe7a652..ebe17417 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight162Controller/RGBController_MSIMysticLight162.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight162Controller/RGBController_MSIMysticLight162.cpp @@ -48,7 +48,7 @@ RGBController_MSIMysticLight162::RGBController_MSIMysticLight162 MSIMysticLight162Controller* controller_ptr ) { - controller = controller_ptr; + controller = controller_ptr; name = controller->GetDeviceName(); vendor = "MSI"; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/MSIMysticLight185Controller.cpp b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/MSIMysticLight185Controller.cpp index 1d653e80..6b2b402a 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/MSIMysticLight185Controller.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/MSIMysticLight185Controller.cpp @@ -220,8 +220,6 @@ const std::vector zones_set18 = MSI_ZONE_J_PIPE_1 }; - - /*---------------------------------------------------------------------------------------------------------------------------------*\ | Definition of the board sepcific configurations (number of onboard LEDs and supported zones). | | | @@ -335,21 +333,20 @@ Color* per_led_jrainbow1_sync; Color* per_led_jrainbow2_sync; Color* per_led_jcorsair_sync; - MSIMysticLight185Controller::MSIMysticLight185Controller ( hid_device* handle, - const char *path, - unsigned short pid + const char* path, + unsigned short pid, + std::string dev_name ) { - dev = handle; + dev = handle; + location = path; + name = dev_name; if(dev) { - location = path; - - ReadName(); ReadFwVersion(); ReadSettings(); } @@ -1048,31 +1045,6 @@ bool MSIMysticLight185Controller::ReadFwVersion() return (ret_val > 0); } -void MSIMysticLight185Controller::ReadName() -{ - wchar_t tname[256]; - - /*-----------------------------------------------------*\ - | Get the manufacturer string from HID | - \*-----------------------------------------------------*/ - hid_get_manufacturer_string(dev, tname, 256); - - /*-----------------------------------------------------*\ - | Convert to std::string | - \*-----------------------------------------------------*/ - name = StringUtils::wstring_to_string(tname); - - /*-----------------------------------------------------*\ - | Get the product string from HID | - \*-----------------------------------------------------*/ - hid_get_product_string(dev, tname, 256); - - /*-----------------------------------------------------*\ - | Append the product string to the manufacturer string | - \*-----------------------------------------------------*/ - name.append(" ").append(StringUtils::wstring_to_string(tname)); -} - MSI_MODE MSIMysticLight185Controller::GetMode() { if(data.on_board_led.effect == MSI_DIRECT_MODE) diff --git a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/MSIMysticLight185Controller.h b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/MSIMysticLight185Controller.h index 25a10b23..d8d9cea8 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/MSIMysticLight185Controller.h +++ b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/MSIMysticLight185Controller.h @@ -29,9 +29,11 @@ public: MSIMysticLight185Controller ( hid_device* handle, - const char *path, - unsigned short pid + const char* path, + unsigned short pid, + std::string dev_name ); + ~MSIMysticLight185Controller(); void SetMode @@ -113,21 +115,6 @@ public: DIRECT_MODE GetSupportedDirectMode() { return per_led_mode; } private: - bool ReadSettings(); - bool ReadFwVersion(); - void ReadName(); - ZoneData* GetZoneData - ( - FeaturePacket_185& data_packet, - MSI_ZONE zone - ); - RainbowZoneData* GetRainbowZoneData(MSI_ZONE zone); - Color* GetPerLedZoneData - ( - MSI_ZONE zone - ); - void SelectPerLedProtocol(); - hid_device* dev; std::string name; std::string location; @@ -153,4 +140,18 @@ private: int numof_JRGBs; const std::vector* supported_zones; DIRECT_MODE per_led_mode; + + bool ReadSettings(); + bool ReadFwVersion(); + ZoneData* GetZoneData + ( + FeaturePacket_185& data_packet, + MSI_ZONE zone + ); + RainbowZoneData* GetRainbowZoneData(MSI_ZONE zone); + Color* GetPerLedZoneData + ( + MSI_ZONE zone + ); + void SelectPerLedProtocol(); }; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.cpp b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.cpp index 91084a92..9b7ef1ad 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight185Controller/RGBController_MSIMysticLight185.cpp @@ -69,7 +69,7 @@ RGBController_MSIMysticLight185::RGBController_MSIMysticLight185 MSIMysticLight185Controller* controller_ptr ) { - controller = controller_ptr; + controller = controller_ptr; name = controller->GetDeviceName(); vendor = "MSI"; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/MSIMysticLight761Controller.cpp b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/MSIMysticLight761Controller.cpp index 13df59de..5c8623af 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/MSIMysticLight761Controller.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/MSIMysticLight761Controller.cpp @@ -67,14 +67,18 @@ void init_packet(FeaturePacket_Zone_761 * packet) MSIMysticLight761Controller::MSIMysticLight761Controller ( hid_device* handle, - const char *path, - unsigned short pid + const char* path, + unsigned short pid, + std::string dev_name ) { - dev = handle; + dev = handle; + location = path; + name = dev_name; - supported_zones = new std::vector; - const mystic_light_761_config * board_config = nullptr; + supported_zones = new std::vector; + + const mystic_light_761_config * board_config = nullptr; for(std::size_t i = 0; i < NUM_CONFS; i++) { @@ -87,50 +91,51 @@ MSIMysticLight761Controller::MSIMysticLight761Controller if(board_config != nullptr) { - supported_zones = (std::vector*) board_config->supported_zones; - unsigned int max = 0; + supported_zones = (std::vector*) board_config->supported_zones; + unsigned int max = 0; + for(std::size_t i = 0; i < board_config->supported_zones[0].size(); i++) { unsigned int curr_val = (unsigned int) (board_config->supported_zones[0][i]); - if( (unsigned int) curr_val > max ) + + if((unsigned int) curr_val > max) { max = curr_val; } } } - for(MSI_ZONE supp_zone : *supported_zones ) + for(MSI_ZONE supp_zone : *supported_zones) { ZoneConfig conf; - conf.msi_zone = supp_zone; - ZoneData * dat = new ZoneData; - conf.zone_data = dat; + + conf.msi_zone = supp_zone; + ZoneData * dat = new ZoneData; + conf.zone_data = dat; + zone_configs.push_back(conf); } if(dev) { - location = path; - - ReadName(); ReadFwVersion(); ReadSettings(); - data = new FeaturePacket_761; + data = new FeaturePacket_761; - data->jaf.zone = MSI_ZONE_JAF; - data->jargb1.zone = MSI_ZONE_JARGB_1; - data->jargb2.zone = MSI_ZONE_JARGB_2; - data->jargb3.zone = MSI_ZONE_JARGB_3; + data->jaf.zone = MSI_ZONE_JAF; + data->jargb1.zone = MSI_ZONE_JARGB_1; + data->jargb2.zone = MSI_ZONE_JARGB_2; + data->jargb3.zone = MSI_ZONE_JARGB_3; - data->jaf.packet.hdr0 = 0x08; - data->jargb1.packet.hdr0 = 0x04; - data->jargb2.packet.hdr0 = 0x04; - data->jargb3.packet.hdr0 = 0x04; + data->jaf.packet.hdr0 = 0x08; + data->jargb1.packet.hdr0 = 0x04; + data->jargb2.packet.hdr0 = 0x04; + data->jargb3.packet.hdr0 = 0x04; - data->jaf.packet.hdr1 = 0x00; - data->jargb1.packet.hdr1 = 0x00; - data->jargb2.packet.hdr1 = 0x01; - data->jargb3.packet.hdr1 = 0x02; + data->jaf.packet.hdr1 = 0x00; + data->jargb1.packet.hdr1 = 0x00; + data->jargb2.packet.hdr1 = 0x01; + data->jargb3.packet.hdr1 = 0x02; init_packet(&data->jaf); init_packet(&data->jargb1); @@ -330,31 +335,6 @@ bool MSIMysticLight761Controller::ReadFwVersion() return true; } -void MSIMysticLight761Controller::ReadName() -{ - wchar_t tname[256]; - - /*-----------------------------------------------------*\ - | Get the manufacturer string from HID | - \*-----------------------------------------------------*/ - hid_get_manufacturer_string(dev, tname, 256); - - /*-----------------------------------------------------*\ - | Convert to std::string | - \*-----------------------------------------------------*/ - name = StringUtils::wstring_to_string(tname); - - /*-----------------------------------------------------*\ - | Get the product string from HID | - \*-----------------------------------------------------*/ - hid_get_product_string(dev, tname, 256); - - /*-----------------------------------------------------*\ - | Append the product string to the manufacturer string | - \*-----------------------------------------------------*/ - name.append(" ").append(StringUtils::wstring_to_string(tname)); -} - MSI_MODE MSIMysticLight761Controller::GetMode() { return MSI_MODE_DIRECT_DUMMY; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/MSIMysticLight761Controller.h b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/MSIMysticLight761Controller.h index 2dd30c0c..6cfa6cc8 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/MSIMysticLight761Controller.h +++ b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/MSIMysticLight761Controller.h @@ -27,9 +27,11 @@ public: MSIMysticLight761Controller ( hid_device* handle, - const char *path, - unsigned short pid + const char* path, + unsigned short pid, + std::string dev_name ); + ~MSIMysticLight761Controller(); void SetMode @@ -117,11 +119,17 @@ public: }; private: + std::string name; + std::vector zone_configs; + std::vector* supported_zones; + hid_device* dev; + std::string location; + std::string version_APROM; + std::string version_LDROM; + FeaturePacket_761* data; + bool ReadSettings(); bool ReadFwVersion(); - void ReadName(); - std::string name; - std::vector zone_configs; ZoneData* GetZoneData ( @@ -134,16 +142,4 @@ private: MSI_ZONE zone ); void SelectPerLedProtocol(); - - std::vector* supported_zones; - hid_device* dev; - std::string location; - std::string version_APROM; - std::string version_LDROM; - FeaturePacket_761* data; - - - - - }; diff --git a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.cpp b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.cpp index 3c87bf15..d860068f 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLight761Controller/RGBController_MSIMysticLight761.cpp @@ -47,9 +47,9 @@ static int IndexOfZoneForType(MSI_ZONE zone_type) RGBController_MSIMysticLight761::RGBController_MSIMysticLight761 ( MSIMysticLight761Controller* controller_ptr - ) + ) { - controller = controller_ptr; + controller = controller_ptr; name = controller->GetDeviceName(); vendor = "MSI"; diff --git a/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp b/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp index 90755816..f106cd5c 100644 --- a/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp +++ b/Controllers/MSIMysticLightController/MSIMysticLightControllerDetect.cpp @@ -50,35 +50,37 @@ void DetectMSIMysticLightControllers if(dev != nullptr) { unsigned char temp_buffer[200]; - temp_buffer[0] = 0x52; - size_t packet_length = hid_get_feature_report(dev, temp_buffer, 200); - DMIInfo dmi; + temp_buffer[0] = 0x52; - if((packet_length >= sizeof(FeaturePacket_185)) && (packet_length <= (sizeof(FeaturePacket_185) + 1))) //WHY r we doing this ? why not == + size_t packet_length = hid_get_feature_report(dev, temp_buffer, 200); + + DMIInfo dmi; + std::string dmi_name = "MSI " + dmi.getMainboard(); + + if((packet_length >= sizeof(FeaturePacket_185)) && (packet_length <= (sizeof(FeaturePacket_185) + 1))) //WHY r we doing this ? why not == { - MSIMysticLight185Controller* controller = new MSIMysticLight185Controller(dev, info->path, info->product_id); + MSIMysticLight185Controller* controller = new MSIMysticLight185Controller(dev, info->path, info->product_id, dmi_name); RGBController_MSIMysticLight185* rgb_controller = new RGBController_MSIMysticLight185(controller); - rgb_controller->name = "MSI " + dmi.getMainboard(); + ResourceManager::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); + MSIMysticLight162Controller* controller = new MSIMysticLight162Controller(dev, info->path, info->product_id, dmi_name); RGBController_MSIMysticLight162* rgb_controller = new RGBController_MSIMysticLight162(controller); - rgb_controller->name = "MSI " + dmi.getMainboard(); + ResourceManager::get()->RegisterRGBController(rgb_controller); } else if((packet_length >= sizeof(FeaturePacket_112)) && (packet_length <= (sizeof(FeaturePacket_112) + 1))) { - MSIMysticLight112Controller* controller = new MSIMysticLight112Controller(dev, info->path); + MSIMysticLight112Controller* controller = new MSIMysticLight112Controller(dev, info->path, dmi_name); RGBController_MSIMysticLight112* rgb_controller = new RGBController_MSIMysticLight112(controller); - rgb_controller->name = "MSI " + dmi.getMainboard(); + ResourceManager::get()->RegisterRGBController(rgb_controller); } else // no supported length returned { - - unsigned char second_buffer [1000]; + unsigned char second_buffer[1000]; second_buffer[0] = 0x51; for(int i = 1; i < 1000; i++) @@ -88,25 +90,23 @@ void DetectMSIMysticLightControllers size_t packet_length_new_attempt = hid_get_feature_report(dev, second_buffer, 1000); - if(packet_length_new_attempt >=290 && packet_length_new_attempt <= 291) + if(packet_length_new_attempt >=290 && packet_length_new_attempt <= 291) { - MSIMysticLight761Controller* controller = new MSIMysticLight761Controller(dev, info->path, info->product_id); + MSIMysticLight761Controller* controller = new MSIMysticLight761Controller(dev, info->path, info->product_id, dmi_name); RGBController_MSIMysticLight761* rgb_controller = new RGBController_MSIMysticLight761(controller); - rgb_controller->name = "MSI " + dmi.getMainboard(); + ResourceManager::get()->RegisterRGBController(rgb_controller); } else { - std::string name = "MSI " + dmi.getMainboard(); - LOG_INFO("No matching driver found for %s, packet length = %d", name.c_str(), packet_length); + LOG_INFO("No matching driver found for %s, packet length = %d", dmi_name.c_str(), packet_length); return; } } } } - void DetectMSIMysticLight64Controllers ( hid_device_info* info, @@ -114,10 +114,12 @@ void DetectMSIMysticLight64Controllers ) { hid_device* dev = hid_open_path(info->path); + if(dev != nullptr) { MSIMysticLight64Controller* controller = new MSIMysticLight64Controller(dev, info->path); RGBController_MSIMysticLight64* rgb_controller = new RGBController_MSIMysticLight64(controller); + ResourceManager::get()->RegisterRGBController(rgb_controller); } }