From 9680d072fa83b47e5dcf9c2df7deeac4870dfda0 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Thu, 14 Aug 2025 19:32:37 -0500 Subject: [PATCH] Store name in RedSquareControllers to avoid setting it in detectors --- .../RGBController_RedSquareKeyrox.cpp | 4 ++-- .../RedSquareKeyroxController.cpp | 8 +++++++- .../RedSquareKeyroxController.h | 4 +++- .../RedSquareKeyroxControllerDetect.cpp | 12 +++++------- .../RGBController_RedSquareKeyroxTKLClassic.cpp | 16 ++++++++-------- .../RedSquareKeyroxTKLClassicController.cpp | 8 +++++++- .../RedSquareKeyroxTKLClassicController.h | 4 +++- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RGBController_RedSquareKeyrox.cpp b/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RGBController_RedSquareKeyrox.cpp index 03778915..93c986ef 100644 --- a/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RGBController_RedSquareKeyrox.cpp +++ b/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RGBController_RedSquareKeyrox.cpp @@ -161,10 +161,10 @@ RGBController_RedSquareKeyrox::RGBController_RedSquareKeyrox(RedSquareKeyroxCont { controller = controller_ptr; - name = "Red Square Keyrox"; + name = controller->GetNameString(); vendor = "Red Square"; type = DEVICE_TYPE_KEYBOARD; - description = name; + description = "Red Square Keyrox Device"; location = controller->GetDeviceLocation(); serial = controller->GetSerialString(); diff --git a/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RedSquareKeyroxController.cpp b/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RedSquareKeyroxController.cpp index 052a5c7d..96c07e9a 100644 --- a/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RedSquareKeyroxController.cpp +++ b/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RedSquareKeyroxController.cpp @@ -15,10 +15,11 @@ using namespace std::chrono_literals; -RedSquareKeyroxController::RedSquareKeyroxController(hid_device *dev_handle, const hid_device_info &info, int variant) +RedSquareKeyroxController::RedSquareKeyroxController(hid_device *dev_handle, const hid_device_info &info, int variant, std::string dev_name) { dev = dev_handle; location = info.path; + name = dev_name; this->variant = variant; } @@ -37,6 +38,11 @@ std::string RedSquareKeyroxController::GetDeviceLocation() return("HID: " + location); } +std::string RedSquareKeyroxController::GetNameString() +{ + return(name); +} + std::string RedSquareKeyroxController::GetSerialString() { wchar_t serial_wchar[128]; diff --git a/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RedSquareKeyroxController.h b/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RedSquareKeyroxController.h index 2f1b9303..4bd659be 100644 --- a/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RedSquareKeyroxController.h +++ b/Controllers/RedSquareKeyroxController/RedSquareKeyroxController/RedSquareKeyroxController.h @@ -60,11 +60,12 @@ enum class RedSquareKeyroxController { public: - RedSquareKeyroxController(hid_device *dev_handle, const hid_device_info &info, int variant); + RedSquareKeyroxController(hid_device *dev_handle, const hid_device_info &info, int variant, std::string dev_name); ~RedSquareKeyroxController(); int GetVariant(); std::string GetDeviceLocation(); + std::string GetNameString(); std::string GetSerialString(); int GetDirectionLRUD(int direction); // Direction for Left-Right-Up-Down modes @@ -83,6 +84,7 @@ protected: private: int variant; std::string location; + std::string name; std::string serial_number; std::vector led_sequence_positions; }; diff --git a/Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp b/Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp index aefbd847..b9169e8c 100644 --- a/Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp +++ b/Controllers/RedSquareKeyroxController/RedSquareKeyroxControllerDetect.cpp @@ -35,9 +35,8 @@ void DetectRedSquareKeyroxTKL(hid_device_info* info, const std::string& name) if(dev) { - RedSquareKeyroxController* controller = new RedSquareKeyroxController(dev, *info, KEYROX_VARIANT_TKL); + RedSquareKeyroxController* controller = new RedSquareKeyroxController(dev, *info, KEYROX_VARIANT_TKL, name); RGBController_RedSquareKeyrox* rgb_controller = new RGBController_RedSquareKeyrox(controller); - rgb_controller->name = name; ResourceManager::get()->RegisterRGBController(rgb_controller); } @@ -48,14 +47,13 @@ void DetectRedSquareKeyroxTKLClassic(hid_device_info* info, const std::string& n if(dev) { - RedSquareKeyroxTKLClassicController* controller = new RedSquareKeyroxTKLClassicController(dev, *info); + RedSquareKeyroxTKLClassicController* controller = new RedSquareKeyroxTKLClassicController(dev, *info, name); RGBController_RedSquareKeyroxTKLClassic* rgb_controller = new RGBController_RedSquareKeyroxTKLClassic(controller); - rgb_controller->name = name; ResourceManager::get()->RegisterRGBController(rgb_controller); } } -REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_PID, 3, 0xFF00, 2); -REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL V2", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_V2_PID, 3, 0xFF00, 2); -REGISTER_HID_DETECTOR_I("Red Square Keyrox TKL Classic", DetectRedSquareKeyroxTKLClassic, RED_SQUARE_KEYROX_TKL_CLASSIC_VID, RED_SQUARE_KEYROX_TKL_CLASSIC_PID, 2); +REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_PID, 3, 0xFF00, 2); +REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL V2", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_V2_PID, 3, 0xFF00, 2); +REGISTER_HID_DETECTOR_I( "Red Square Keyrox TKL Classic", DetectRedSquareKeyroxTKLClassic, RED_SQUARE_KEYROX_TKL_CLASSIC_VID, RED_SQUARE_KEYROX_TKL_CLASSIC_PID, 2); diff --git a/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RGBController_RedSquareKeyroxTKLClassic.cpp b/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RGBController_RedSquareKeyroxTKLClassic.cpp index 9c3dd9f7..c19710ee 100644 --- a/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RGBController_RedSquareKeyroxTKLClassic.cpp +++ b/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RGBController_RedSquareKeyroxTKLClassic.cpp @@ -55,16 +55,16 @@ layout_values keyrox_tkl_offset_values = RGBController_RedSquareKeyroxTKLClassic::RGBController_RedSquareKeyroxTKLClassic(RedSquareKeyroxTKLClassicController* controller_ptr) { - controller = controller_ptr; + controller = controller_ptr; - name = "Red Square Keyrox TKL Classic"; - vendor = "Red Square"; - type = DEVICE_TYPE_KEYBOARD; - description = name; - location = controller->GetDeviceLocation(); - serial = controller->GetSerialString(); + name = controller->GetNameString(); + vendor = "Red Square"; + type = DEVICE_TYPE_KEYBOARD; + description = "Red Square Keyrox TKL Classic Device"; + location = controller->GetDeviceLocation(); + serial = controller->GetSerialString(); - int BASE_EFFECT_FLAGS = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; + int BASE_EFFECT_FLAGS = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR; const int EFFECTS_COUNT = 14; keyrox_effect keyrox_effects[EFFECTS_COUNT] = diff --git a/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RedSquareKeyroxTKLClassicController.cpp b/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RedSquareKeyroxTKLClassicController.cpp index 6403f658..40080cf6 100644 --- a/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RedSquareKeyroxTKLClassicController.cpp +++ b/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RedSquareKeyroxTKLClassicController.cpp @@ -14,10 +14,11 @@ using namespace std::chrono_literals; -RedSquareKeyroxTKLClassicController::RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info) +RedSquareKeyroxTKLClassicController::RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info, std::string dev_name) { dev = dev_handle; location = info.path; + name = dev_name; } RedSquareKeyroxTKLClassicController::~RedSquareKeyroxTKLClassicController() @@ -30,6 +31,11 @@ std::string RedSquareKeyroxTKLClassicController::GetDeviceLocation() return("HID: " + location); } +std::string RedSquareKeyroxTKLClassicController::GetNameString() +{ + return(name); +} + std::string RedSquareKeyroxTKLClassicController::GetSerialString() { wchar_t serial_wchar[128]; diff --git a/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RedSquareKeyroxTKLClassicController.h b/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RedSquareKeyroxTKLClassicController.h index 587848fc..a0e1d32d 100644 --- a/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RedSquareKeyroxTKLClassicController.h +++ b/Controllers/RedSquareKeyroxController/RedSquareKeyroxTKLClassicController/RedSquareKeyroxTKLClassicController.h @@ -54,10 +54,11 @@ enum class RedSquareKeyroxTKLClassicController { public: - RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info); + RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info, std::string dev_name); ~RedSquareKeyroxTKLClassicController(); std::string GetDeviceLocation(); + std::string GetNameString(); std::string GetSerialString(); int GetDirection(int direction); @@ -71,6 +72,7 @@ protected: private: std::string location; + std::string name; std::string serial_number; std::vector led_sequence_positions; };