Store name in CherryKeyboardController to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-04 14:04:27 -05:00
parent c761661386
commit 2ec68c29de
4 changed files with 13 additions and 5 deletions

View file

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

View file

@ -124,10 +124,11 @@ enum
class CherryKeyboardController class CherryKeyboardController
{ {
public: public:
CherryKeyboardController(hid_device* dev_handle, const char* path); CherryKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name);
~CherryKeyboardController(); ~CherryKeyboardController();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString(); std::string GetSerialString();
void SetKeyboardColors void SetKeyboardColors
@ -167,6 +168,7 @@ public:
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
void ComputeChecksum void ComputeChecksum
( (

View file

@ -33,9 +33,9 @@ void DetectCherryKeyboards(hid_device_info* info, const std::string& name)
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev ) if( dev )
{ {
CherryKeyboardController* controller = new CherryKeyboardController(dev, info->path); CherryKeyboardController* controller = new CherryKeyboardController(dev, info->path, name);
RGBController_CherryKeyboard* rgb_controller = new RGBController_CherryKeyboard(controller, info->product_id); RGBController_CherryKeyboard* rgb_controller = new RGBController_CherryKeyboard(controller, info->product_id);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} }

View file

@ -43,7 +43,7 @@ RGBController_CherryKeyboard::RGBController_CherryKeyboard(CherryKeyboardControl
{ {
controller = controller_ptr; controller = controller_ptr;
name = "Cherry Keyboard Device"; name = controller->GetDeviceName();
vendor = "Cherry"; vendor = "Cherry";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
description = "Cherry Keyboard Device"; description = "Cherry Keyboard Device";