Store name in HoltekControllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-14 23:33:43 -05:00
parent ce64dbc686
commit 2a6ad477e6
7 changed files with 27 additions and 11 deletions

View file

@ -13,10 +13,11 @@
#include "HoltekA070Controller.h"
#include "StringUtils.h"
HoltekA070Controller::HoltekA070Controller(hid_device* dev_handle, const char* path)
HoltekA070Controller::HoltekA070Controller(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
HoltekA070Controller::~HoltekA070Controller()
@ -29,6 +30,11 @@ std::string HoltekA070Controller::GetDeviceLocation()
return("HID: " + location);
}
std::string HoltekA070Controller::GetNameString()
{
return(name);
}
std::string HoltekA070Controller::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -25,10 +25,11 @@ enum
class HoltekA070Controller
{
public:
HoltekA070Controller(hid_device* dev_handle, const char* path);
HoltekA070Controller(hid_device* dev_handle, const char* path, std::string dev_name);
~HoltekA070Controller();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void SendCustomColor
@ -46,4 +47,5 @@ public:
private:
hid_device* dev;
std::string location;
std::string name;
};

View file

@ -26,7 +26,7 @@ RGBController_HoltekA070::RGBController_HoltekA070(HoltekA070Controller* control
{
controller = controller_ptr;
name = "Holtek USB Gaming Mouse";
name = controller->GetNameString();
vendor = "Holtek";
type = DEVICE_TYPE_MOUSE;
description = "Holtek USB Gaming Mouse Device";

View file

@ -13,10 +13,11 @@
#include "HoltekA1FAController.h"
#include "StringUtils.h"
HoltekA1FAController::HoltekA1FAController(hid_device *dev_handle, const char *path)
HoltekA1FAController::HoltekA1FAController(hid_device *dev_handle, const char *path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
HoltekA1FAController::~HoltekA1FAController()
@ -26,7 +27,12 @@ HoltekA1FAController::~HoltekA1FAController()
std::string HoltekA1FAController::GetDeviceLocation()
{
return ("HID: " + location);
return("HID: " + location);
}
std::string HoltekA1FAController::GetNameString()
{
return(name);
}
std::string HoltekA1FAController::GetSerialString()

View file

@ -49,10 +49,11 @@ enum
class HoltekA1FAController
{
public:
HoltekA1FAController(hid_device *dev_handle, const char *path);
HoltekA1FAController(hid_device *dev_handle, const char *path, std::string dev_name);
~HoltekA1FAController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void SendData(unsigned char mode, unsigned char brightness, unsigned char speed, unsigned char preset, unsigned char red, unsigned char green, unsigned char blue);
@ -60,4 +61,5 @@ public:
private:
hid_device *dev;
std::string location;
std::string name;
};

View file

@ -26,7 +26,7 @@ RGBController_HoltekA1FA::RGBController_HoltekA1FA(HoltekA1FAController* control
{
controller = controller_ptr;
name = "Holtek Mousemat";
name = controller->GetNameString();
vendor = "Holtek";
type = DEVICE_TYPE_MOUSEMAT;
description = "Holtek Mousemat Device";

View file

@ -33,7 +33,7 @@ void DetectHoltekControllers(hid_device_info* info, const std::string& name)
if(dev)
{
HoltekA070Controller* controller = new HoltekA070Controller(dev, info->path);
HoltekA070Controller* controller = new HoltekA070Controller(dev, info->path, name);
RGBController_HoltekA070* rgb_controller = new RGBController_HoltekA070(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
@ -46,7 +46,7 @@ void DetectHoltekMousemats(hid_device_info *info, const std::string &name)
if(dev)
{
HoltekA1FAController* controller = new HoltekA1FAController(dev, info->path);
HoltekA1FAController* controller = new HoltekA1FAController(dev, info->path, name);
RGBController_HoltekA1FA* rgb_controller = new RGBController_HoltekA1FA(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);