Store name in MSIMysticLightControllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-13 11:49:45 -05:00
parent 4c018421a2
commit 49e4f00aff
14 changed files with 138 additions and 240 deletions

View file

@ -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);
}
}