From 0c0ffe7f5cae5e8b770980bc6f51284db38a691c Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 10 Aug 2025 21:02:42 -0500 Subject: [PATCH] Store name in HyperXMicrophoneController to avoid setting it in detector --- .../HyperXMicrophoneController.cpp | 10 ++++++++-- .../HyperXMicrophoneController.h | 4 +++- .../HyperXMicrophoneControllerDetect.cpp | 3 +-- .../RGBController_HyperXMicrophone.cpp | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Controllers/HyperXMicrophoneController/HyperXMicrophoneController.cpp b/Controllers/HyperXMicrophoneController/HyperXMicrophoneController.cpp index c6c676be..a0a8345e 100644 --- a/Controllers/HyperXMicrophoneController/HyperXMicrophoneController.cpp +++ b/Controllers/HyperXMicrophoneController/HyperXMicrophoneController.cpp @@ -15,11 +15,12 @@ using namespace std::chrono_literals; -HyperXMicrophoneController::HyperXMicrophoneController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, std::string path) +HyperXMicrophoneController::HyperXMicrophoneController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, std::string path, std::string dev_name) { wrapper = hid_wrapper; dev = dev_handle; location = path; + name = dev_name; } HyperXMicrophoneController::~HyperXMicrophoneController() @@ -36,7 +37,12 @@ HyperXMicrophoneController::~HyperXMicrophoneController() std::string HyperXMicrophoneController::GetDeviceLocation() { - return location; + return(location); +} + +std::string HyperXMicrophoneController::GetNameString() +{ + return(name); } std::string HyperXMicrophoneController::GetSerialString() diff --git a/Controllers/HyperXMicrophoneController/HyperXMicrophoneController.h b/Controllers/HyperXMicrophoneController/HyperXMicrophoneController.h index 5e02b59f..22c4abb5 100644 --- a/Controllers/HyperXMicrophoneController/HyperXMicrophoneController.h +++ b/Controllers/HyperXMicrophoneController/HyperXMicrophoneController.h @@ -21,10 +21,11 @@ class HyperXMicrophoneController { public: - HyperXMicrophoneController(hidapi_wrapper hid_wrapper, hid_device* dev, std::string path); + HyperXMicrophoneController(hidapi_wrapper hid_wrapper, hid_device* dev, std::string path, std::string dev_name); ~HyperXMicrophoneController(); std::string GetDeviceLocation(); + std::string GetNameString(); std::string GetSerialString(); void SendDirect(std::vector color_data); @@ -35,6 +36,7 @@ private: hid_device* dev; std::string location; std::mutex lock; + std::string name; void SendEOT(uint8_t frame_count); void SendToRegister(uint8_t reg, uint8_t param1, uint8_t param2); diff --git a/Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp b/Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp index dafa295f..34f65332 100644 --- a/Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp +++ b/Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp @@ -37,9 +37,8 @@ void DetectHyperXMicrophoneControllers(hidapi_wrapper wrapper, hid_device_info* if(dev) { - HyperXMicrophoneController* controller = new HyperXMicrophoneController(wrapper, dev, info->path); + HyperXMicrophoneController* controller = new HyperXMicrophoneController(wrapper, dev, info->path, name); RGBController_HyperXMicrophone *rgb_controller = new RGBController_HyperXMicrophone(controller); - rgb_controller->name = name; ResourceManager::get()->RegisterRGBController(rgb_controller); } diff --git a/Controllers/HyperXMicrophoneController/RGBController_HyperXMicrophone.cpp b/Controllers/HyperXMicrophoneController/RGBController_HyperXMicrophone.cpp index ece66d41..40a51fef 100644 --- a/Controllers/HyperXMicrophoneController/RGBController_HyperXMicrophone.cpp +++ b/Controllers/HyperXMicrophoneController/RGBController_HyperXMicrophone.cpp @@ -57,6 +57,7 @@ RGBController_HyperXMicrophone::RGBController_HyperXMicrophone(HyperXMicrophoneC { controller = controller_ptr; + name = controller->GetNameString(); vendor = "HyperX"; type = DEVICE_TYPE_MICROPHONE; description = "HyperX Microphone Device";