Store name in MSIRGBController to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-14 10:19:11 -05:00
parent b13ca818bb
commit 719d7b8801
4 changed files with 28 additions and 14 deletions

View file

@ -15,9 +15,10 @@
#include "dmiinfo.h" #include "dmiinfo.h"
#include "super_io.h" #include "super_io.h"
MSIRGBController::MSIRGBController(int sioaddr, bool invert) MSIRGBController::MSIRGBController(int sioaddr, bool invert, std::string dev_name)
{ {
msi_sioaddr = sioaddr; msi_sioaddr = sioaddr;
name = dev_name;
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| This setup step isn't well documented | | This setup step isn't well documented |
@ -74,6 +75,18 @@ MSIRGBController::~MSIRGBController()
} }
std::string MSIRGBController::GetDeviceLocation()
{
char hex[12];
snprintf(hex, sizeof(hex), "0x%X", msi_sioaddr);
return("SIO: " + std::string(hex));
}
std::string MSIRGBController::GetDeviceName()
{
return(name);
}
void MSIRGBController::SetColor(unsigned char red, unsigned char green, unsigned char blue) void MSIRGBController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{ {
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\

View file

@ -42,7 +42,7 @@ enum
class MSIRGBController class MSIRGBController
{ {
public: public:
MSIRGBController(int sioaddr, bool invert); MSIRGBController(int sioaddr, bool invert, std::string dev_name);
~MSIRGBController(); ~MSIRGBController();
std::string GetDeviceName(); std::string GetDeviceName();
@ -53,5 +53,6 @@ public:
void SetColor(unsigned char red, unsigned char green, unsigned char blue); void SetColor(unsigned char red, unsigned char green, unsigned char blue);
private: private:
int msi_sioaddr; int msi_sioaddr;
std::string name;
}; };

View file

@ -114,9 +114,8 @@ void DetectMSIRGBControllers()
{ {
if (board_dmi.find(std::string(compatible_devices[i].name)) != std::string::npos) if (board_dmi.find(std::string(compatible_devices[i].name)) != std::string::npos)
{ {
MSIRGBController* controller = new MSIRGBController(sioaddr, compatible_devices[i].invert); MSIRGBController* controller = new MSIRGBController(sioaddr, compatible_devices[i].invert, "MSI " + board_dmi);
RGBController_MSIRGB* rgb_controller = new RGBController_MSIRGB(controller); RGBController_MSIRGB* rgb_controller = new RGBController_MSIRGB(controller);
rgb_controller->name = "MSI " + board_dmi;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
break; break;

View file

@ -24,18 +24,19 @@
RGBController_MSIRGB::RGBController_MSIRGB(MSIRGBController* controller_ptr) RGBController_MSIRGB::RGBController_MSIRGB(MSIRGBController* controller_ptr)
{ {
controller = controller_ptr; controller = controller_ptr;
name = "MSI Motherboard"; name = controller->GetDeviceName();
vendor = "MSI"; vendor = "MSI";
type = DEVICE_TYPE_MOTHERBOARD; type = DEVICE_TYPE_MOTHERBOARD;
description = "MSI-RGB Device"; description = "MSI-RGB Device";
location = controller->GetDeviceLocation();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = 0; Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
SetupZones(); SetupZones();