Store name in CougarControllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-06 00:48:01 -05:00
parent 17a58b4c22
commit 31ec06b576
7 changed files with 22 additions and 25 deletions

View file

@ -29,9 +29,9 @@ void DetectCougarRevengerSTControllers(hid_device_info* info, const std::string&
if(dev)
{
CougarRevengerSTController* controller = new CougarRevengerSTController(dev, *info);
CougarRevengerSTController* controller = new CougarRevengerSTController(dev, *info, name);
RGBController_CougarRevengerST* rgb_controller = new RGBController_CougarRevengerST(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -42,9 +42,8 @@ void DetectCougar700kEvo(hid_device_info* info, const std::string& name)
if (dev)
{
CougarKeyboardController* controller = new CougarKeyboardController(dev, info->path);
CougarKeyboardController* controller = new CougarKeyboardController(dev, info->path, name);
RGBController_CougarKeyboard* rgb_controller = new RGBController_CougarKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}

View file

@ -54,21 +54,11 @@ static uint8_t keyvalue_map[113] =
149, 150, 151
};
CougarKeyboardController::CougarKeyboardController(hid_device* dev_handle, const char* path)
CougarKeyboardController::CougarKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
/*---------------------------------------------------------*\
| Get device name from HID manufacturer and product strings |
\*---------------------------------------------------------*/
wchar_t name_string[HID_MAX_STR];
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
device_name = StringUtils::wstring_to_string(name_string);
hid_get_product_string(dev, name_string, HID_MAX_STR);
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
name = dev_name;
}
CougarKeyboardController::~CougarKeyboardController()
@ -78,7 +68,7 @@ CougarKeyboardController::~CougarKeyboardController()
std::string CougarKeyboardController::GetDeviceName()
{
return device_name;
return(name);
}
std::string CougarKeyboardController::GetSerial()

View file

@ -66,7 +66,7 @@ enum Cougar_Keyboard_Controller_Speeds
class CougarKeyboardController
{
public:
CougarKeyboardController(hid_device* dev_handle, const char* path);
CougarKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name);
~CougarKeyboardController();
std::string GetDeviceName();
@ -78,8 +78,8 @@ public:
void Save(uint8_t flag);
void SendProfile(uint8_t profile, uint8_t light);
private:
std::string device_name;
std::string serial;
std::string location;
std::string name;
hid_device* dev;
};

View file

@ -170,10 +170,10 @@ RGBController_CougarKeyboard::RGBController_CougarKeyboard(CougarKeyboardControl
{
controller = controller_ptr;
name = "CougarKeyboard";
name = controller->GetDeviceName();
vendor = "Cougar";
type = DEVICE_TYPE_KEYBOARD;
description = controller->GetDeviceName();
description = "Cougar Keyboard Device";
serial = controller->GetSerial();
location = controller->GetLocation();

View file

@ -13,10 +13,11 @@
#include "CougarRevengerSTController.h"
#include "StringUtils.h"
CougarRevengerSTController::CougarRevengerSTController(hid_device* dev_handle, const hid_device_info& info)
CougarRevengerSTController::CougarRevengerSTController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
{
dev = dev_handle;
location = info.path;
name = dev_name;
version = "";
ActivateMode(0, DIRECT_MODE_VALUE);
@ -34,6 +35,11 @@ std::string CougarRevengerSTController::GetDeviceLocation()
return("HID: " + location);
}
std::string CougarRevengerSTController::GetNameString()
{
return(name);
}
std::string CougarRevengerSTController::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -228,12 +228,13 @@ static const std::map<unsigned char, cougar_mode> modes_mapping =
class CougarRevengerSTController
{
public:
CougarRevengerSTController(hid_device* dev_handle, const hid_device_info& info);
CougarRevengerSTController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
~CougarRevengerSTController();
std::string GetSerialString();
std::string GetDeviceLocation();
std::string GetFirmwareVersion();
std::string GetNameString();
void ActivateMode(unsigned char zone, unsigned char mode_value);
void SetDirect(unsigned char zone, RGBColor color, unsigned char brightness);
@ -242,6 +243,7 @@ public:
private:
hid_device* dev;
std::string location;
std::string name;
std::string version;
void Apply();

View file

@ -28,10 +28,10 @@ RGBController_CougarRevengerST::RGBController_CougarRevengerST(CougarRevengerSTC
{
controller = controller_ptr;
name = "Cougar Revenger ST USB Device";
name = controller->GetNameString();
vendor = "Cougar";
type = DEVICE_TYPE_MOUSE;
description = name;
description = "Cougar Revenger ST Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
version = controller->GetFirmwareVersion();