From 2ec68c29de1f32b0303ed99af680813cdbd71f23 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Mon, 4 Aug 2025 14:04:27 -0500 Subject: [PATCH] Store name in CherryKeyboardController to avoid setting it in detector --- .../CherryKeyboardController/CherryKeyboardController.cpp | 8 +++++++- .../CherryKeyboardController/CherryKeyboardController.h | 4 +++- .../CherryKeyboardControllerDetect.cpp | 4 ++-- .../RGBController_CherryKeyboard.cpp | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Controllers/CherryKeyboardController/CherryKeyboardController.cpp b/Controllers/CherryKeyboardController/CherryKeyboardController.cpp index e6125f47..1ffd3ba7 100644 --- a/Controllers/CherryKeyboardController/CherryKeyboardController.cpp +++ b/Controllers/CherryKeyboardController/CherryKeyboardController.cpp @@ -13,10 +13,11 @@ #include "CherryKeyboardController.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; location = path; + name = dev_name; } CherryKeyboardController::~CherryKeyboardController() @@ -29,6 +30,11 @@ std::string CherryKeyboardController::GetDeviceLocation() return("HID: " + location); } +std::string CherryKeyboardController::GetDeviceName() +{ + return(name); +} + std::string CherryKeyboardController::GetSerialString() { wchar_t serial_string[128]; diff --git a/Controllers/CherryKeyboardController/CherryKeyboardController.h b/Controllers/CherryKeyboardController/CherryKeyboardController.h index e5c56062..fe948ed8 100644 --- a/Controllers/CherryKeyboardController/CherryKeyboardController.h +++ b/Controllers/CherryKeyboardController/CherryKeyboardController.h @@ -124,10 +124,11 @@ enum class CherryKeyboardController { public: - CherryKeyboardController(hid_device* dev_handle, const char* path); + CherryKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name); ~CherryKeyboardController(); std::string GetDeviceLocation(); + std::string GetDeviceName(); std::string GetSerialString(); void SetKeyboardColors @@ -167,6 +168,7 @@ public: private: hid_device* dev; std::string location; + std::string name; void ComputeChecksum ( diff --git a/Controllers/CherryKeyboardController/CherryKeyboardControllerDetect.cpp b/Controllers/CherryKeyboardController/CherryKeyboardControllerDetect.cpp index a9c8c1d0..69167040 100644 --- a/Controllers/CherryKeyboardController/CherryKeyboardControllerDetect.cpp +++ b/Controllers/CherryKeyboardController/CherryKeyboardControllerDetect.cpp @@ -33,9 +33,9 @@ void DetectCherryKeyboards(hid_device_info* info, const std::string& name) hid_device* dev = hid_open_path(info->path); 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); - rgb_controller->name = name; + ResourceManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/CherryKeyboardController/RGBController_CherryKeyboard.cpp b/Controllers/CherryKeyboardController/RGBController_CherryKeyboard.cpp index e755a6fd..d55d5ba9 100644 --- a/Controllers/CherryKeyboardController/RGBController_CherryKeyboard.cpp +++ b/Controllers/CherryKeyboardController/RGBController_CherryKeyboard.cpp @@ -43,7 +43,7 @@ RGBController_CherryKeyboard::RGBController_CherryKeyboard(CherryKeyboardControl { controller = controller_ptr; - name = "Cherry Keyboard Device"; + name = controller->GetDeviceName(); vendor = "Cherry"; type = DEVICE_TYPE_KEYBOARD; description = "Cherry Keyboard Device";