From fcce668d666579694987c3ff05f3872f3504520d Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Thu, 14 Aug 2025 20:17:49 -0500 Subject: [PATCH] Store name in TrustControllers to avoid setting it in detectors --- .../TrustController/TrustControllerDetect.cpp | 8 ++++---- .../RGBController_TrustGXT114.cpp | 6 +++--- .../TrustGXT114Controller.cpp | 18 +++++++++--------- .../TrustGXT114Controller.h | 7 ++++--- .../RGBController_TrustGXT180.cpp | 6 +++--- .../TrustGXT180Controller.cpp | 14 +++++++------- .../TrustGXT180Controller.h | 9 +++++---- 7 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Controllers/TrustController/TrustControllerDetect.cpp b/Controllers/TrustController/TrustControllerDetect.cpp index 2a83c4d2..7c01990b 100644 --- a/Controllers/TrustController/TrustControllerDetect.cpp +++ b/Controllers/TrustController/TrustControllerDetect.cpp @@ -32,12 +32,12 @@ void DetectTrustGXT114Controllers(hid_device_info* info, const std::string& name if(dev) { - TrustGXT114Controller* controller = new TrustGXT114Controller(dev, *info); + TrustGXT114Controller* controller = new TrustGXT114Controller(dev, *info, name); if(controller->Test()) { RGBController_TrustGXT114* rgb_controller = new RGBController_TrustGXT114(controller); - rgb_controller->name = name; + ResourceManager::get()->RegisterRGBController(rgb_controller); } else @@ -53,9 +53,9 @@ void DetectTrustGXT180Controllers(hid_device_info* info, const std::string& name if(dev) { - TrustGXT180Controller* controller = new TrustGXT180Controller(dev, *info); + TrustGXT180Controller* controller = new TrustGXT180Controller(dev, *info, name); RGBController_TrustGXT180* rgb_controller = new RGBController_TrustGXT180(controller); - rgb_controller->name = name; + ResourceManager::get()->RegisterRGBController(rgb_controller); } } diff --git a/Controllers/TrustController/TrustGXT114Controller/RGBController_TrustGXT114.cpp b/Controllers/TrustController/TrustGXT114Controller/RGBController_TrustGXT114.cpp index 312e4006..061626ad 100644 --- a/Controllers/TrustController/TrustGXT114Controller/RGBController_TrustGXT114.cpp +++ b/Controllers/TrustController/TrustGXT114Controller/RGBController_TrustGXT114.cpp @@ -27,13 +27,13 @@ RGBController_TrustGXT114::RGBController_TrustGXT114(TrustGXT114Controller* controller_ptr) { controller = controller_ptr; - name = "Trust GXT 114"; + + name = controller->GetNameString(); vendor = "Trust"; type = DEVICE_TYPE_MOUSE; - description = name; + description = "Trust GXT 114 Device"; location = controller->GetDeviceLocation(); serial = controller->GetSerialString(); - version = controller->GetFirmwareVersion(); mode Static; Static.name = "Static"; diff --git a/Controllers/TrustController/TrustGXT114Controller/TrustGXT114Controller.cpp b/Controllers/TrustController/TrustGXT114Controller/TrustGXT114Controller.cpp index 8615d54d..3f40a502 100644 --- a/Controllers/TrustController/TrustGXT114Controller/TrustGXT114Controller.cpp +++ b/Controllers/TrustController/TrustGXT114Controller/TrustGXT114Controller.cpp @@ -13,11 +13,11 @@ #include "StringUtils.h" #include "TrustGXT114Controller.h" -TrustGXT114Controller::TrustGXT114Controller(hid_device* dev_handle, const hid_device_info& info) +TrustGXT114Controller::TrustGXT114Controller(hid_device* dev_handle, const hid_device_info& info, std::string dev_name) { - dev = dev_handle; - location = info.path; - version = ""; + dev = dev_handle; + location = info.path; + name = dev_name; } TrustGXT114Controller::~TrustGXT114Controller() @@ -30,6 +30,11 @@ std::string TrustGXT114Controller::GetDeviceLocation() return("HID: " + location); } +std::string TrustGXT114Controller::GetNameString() +{ + return(name); +} + std::string TrustGXT114Controller::GetSerialString() { wchar_t serial_string[128]; @@ -43,11 +48,6 @@ std::string TrustGXT114Controller::GetSerialString() return(StringUtils::wstring_to_string(serial_string)); } -std::string TrustGXT114Controller::GetFirmwareVersion() -{ - return(version); -} - bool TrustGXT114Controller::Test() { /*-----------------------------------------*\ diff --git a/Controllers/TrustController/TrustGXT114Controller/TrustGXT114Controller.h b/Controllers/TrustController/TrustGXT114Controller/TrustGXT114Controller.h index 059d5bec..b10bc1e4 100644 --- a/Controllers/TrustController/TrustGXT114Controller/TrustGXT114Controller.h +++ b/Controllers/TrustController/TrustGXT114Controller/TrustGXT114Controller.h @@ -41,12 +41,13 @@ enum class TrustGXT114Controller { public: - TrustGXT114Controller(hid_device* dev_handle, const hid_device_info& info); + TrustGXT114Controller(hid_device* dev_handle, const hid_device_info& info, std::string dev_name); ~TrustGXT114Controller(); std::string GetSerialString(); std::string GetDeviceLocation(); - std::string GetFirmwareVersion(); + std::string GetNameString(); + bool Test(); void SetMode(RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value); @@ -54,6 +55,6 @@ protected: hid_device* dev; private: + std::string name; std::string location; - std::string version; }; diff --git a/Controllers/TrustController/TrustGXT180Controller/RGBController_TrustGXT180.cpp b/Controllers/TrustController/TrustGXT180Controller/RGBController_TrustGXT180.cpp index 826881c8..30bf39d6 100644 --- a/Controllers/TrustController/TrustGXT180Controller/RGBController_TrustGXT180.cpp +++ b/Controllers/TrustController/TrustGXT180Controller/RGBController_TrustGXT180.cpp @@ -27,13 +27,13 @@ RGBController_TrustGXT180::RGBController_TrustGXT180(TrustGXT180Controller* controller_ptr) { controller = controller_ptr; - name = "Trust GXT 180"; + + name = controller->GetNameString(); vendor = "Trust"; type = DEVICE_TYPE_MOUSE; - description = name; + description = "Trust GXT 180 Device"; location = controller->GetDeviceLocation(); serial = controller->GetSerialString(); - version = controller->GetFirmwareVersion(); mode Static; Static.name = "Static"; diff --git a/Controllers/TrustController/TrustGXT180Controller/TrustGXT180Controller.cpp b/Controllers/TrustController/TrustGXT180Controller/TrustGXT180Controller.cpp index a05ecd28..fc6d6b16 100644 --- a/Controllers/TrustController/TrustGXT180Controller/TrustGXT180Controller.cpp +++ b/Controllers/TrustController/TrustGXT180Controller/TrustGXT180Controller.cpp @@ -13,11 +13,11 @@ #include "StringUtils.h" #include "TrustGXT180Controller.h" -TrustGXT180Controller::TrustGXT180Controller(hid_device* dev_handle, const hid_device_info& info) +TrustGXT180Controller::TrustGXT180Controller(hid_device* dev_handle, const hid_device_info& info, std::string dev_name) { dev = dev_handle; location = info.path; - version = ""; + name = dev_name; } TrustGXT180Controller::~TrustGXT180Controller() @@ -30,6 +30,11 @@ std::string TrustGXT180Controller::GetDeviceLocation() return("HID: " + location); } +std::string TrustGXT180Controller::GetNameString() +{ + return(name); +} + std::string TrustGXT180Controller::GetSerialString() { wchar_t serial_string[128]; @@ -43,11 +48,6 @@ std::string TrustGXT180Controller::GetSerialString() return(StringUtils::wstring_to_string(serial_string)); } -std::string TrustGXT180Controller::GetFirmwareVersion() -{ - return(version); -} - void TrustGXT180Controller::SetMode(RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value) { /*-----------------------------------------*\ diff --git a/Controllers/TrustController/TrustGXT180Controller/TrustGXT180Controller.h b/Controllers/TrustController/TrustGXT180Controller/TrustGXT180Controller.h index 9128c655..cc764f68 100644 --- a/Controllers/TrustController/TrustGXT180Controller/TrustGXT180Controller.h +++ b/Controllers/TrustController/TrustGXT180Controller/TrustGXT180Controller.h @@ -42,12 +42,13 @@ enum class TrustGXT180Controller { public: - TrustGXT180Controller(hid_device* dev_handle, const hid_device_info& info); + TrustGXT180Controller(hid_device* dev_handle, const hid_device_info& info, std::string dev_name); ~TrustGXT180Controller(); - std::string GetSerialString(); std::string GetDeviceLocation(); - std::string GetFirmwareVersion(); + std::string GetNameString(); + std::string GetSerialString(); + void SetMode(RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value); protected: @@ -55,5 +56,5 @@ protected: private: std::string location; - std::string version; + std::string name; };