From 84c24e70c06b62622aefa2deea267128bc6fbd59 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Thu, 14 Aug 2025 22:59:05 -0500 Subject: [PATCH] Store name in WushiController to avoid setting it in detector --- .../WushiController/WushiL50USBController.cpp | 49 ++++++++++--------- .../WushiController/WushiL50USBController.h | 8 +-- .../WushiController/WushiL50USBDetect.cpp | 3 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/Controllers/WushiController/WushiL50USBController.cpp b/Controllers/WushiController/WushiL50USBController.cpp index cc9cc3d4..008155bf 100644 --- a/Controllers/WushiController/WushiL50USBController.cpp +++ b/Controllers/WushiController/WushiL50USBController.cpp @@ -11,11 +11,12 @@ #include "StringUtils.h" #include "WushiL50USBController.h" -WushiL50USBController::WushiL50USBController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, const char* path) +WushiL50USBController::WushiL50USBController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, const char* path, std::string dev_name) { wrapper = hid_wrapper; dev = dev_handle; location = path; + name = dev_name; } WushiL50USBController::~WushiL50USBController() @@ -23,6 +24,29 @@ WushiL50USBController::~WushiL50USBController() wrapper.hid_close(dev); } +std::string WushiL50USBController::getName() +{ + return name; +} + +std::string WushiL50USBController::getLocation() +{ + return location; +} + +std::string WushiL50USBController::GetSerialString() +{ + wchar_t serial_string[128]; + int ret = wrapper.hid_get_serial_number_string(dev, serial_string, 128); + + if(ret != 0) + { + return(""); + } + + return(StringUtils::wstring_to_string(serial_string)); +} + void WushiL50USBController::setMode(WushiL50State * in_mode) { unsigned char usb_buf[WUSHI_L50_HID_PACKET_SIZE]; @@ -62,26 +86,3 @@ void WushiL50USBController::setMode(WushiL50State * in_mode) \*-----------------------------------------------------*/ wrapper.hid_send_feature_report(dev, usb_buf, WUSHI_L50_HID_PACKET_SIZE); } - -std::string WushiL50USBController::getName() -{ - return name; -} - -std::string WushiL50USBController::getLocation() -{ - return location; -} - -std::string WushiL50USBController::GetSerialString() -{ - wchar_t serial_string[128]; - int ret = wrapper.hid_get_serial_number_string(dev, serial_string, 128); - - if(ret != 0) - { - return(""); - } - - return(StringUtils::wstring_to_string(serial_string)); -} diff --git a/Controllers/WushiController/WushiL50USBController.h b/Controllers/WushiController/WushiL50USBController.h index f75fec1d..7355b61f 100644 --- a/Controllers/WushiController/WushiL50USBController.h +++ b/Controllers/WushiController/WushiL50USBController.h @@ -95,18 +95,18 @@ public: class WushiL50USBController { public: - WushiL50USBController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, const char* path); + WushiL50USBController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, const char* path, std::string dev_name); ~WushiL50USBController(); - void setMode(WushiL50State * in_mode); - std::string getName(); std::string getLocation(); std::string GetSerialString(); + void setMode(WushiL50State * in_mode); + private: - std::string name; hidapi_wrapper wrapper; hid_device * dev; std::string location; + std::string name; }; diff --git a/Controllers/WushiController/WushiL50USBDetect.cpp b/Controllers/WushiController/WushiL50USBDetect.cpp index 0c496c65..0d9554cd 100644 --- a/Controllers/WushiController/WushiL50USBDetect.cpp +++ b/Controllers/WushiController/WushiL50USBDetect.cpp @@ -28,9 +28,8 @@ void DetectWushiL50USBControllers(hidapi_wrapper wrapper, hid_device_info* info, if(dev) { - WushiL50USBController* controller = new WushiL50USBController(wrapper, dev, info->path); + WushiL50USBController* controller = new WushiL50USBController(wrapper, dev, info->path, name); RGBController_WushiL50USB* rgb_controller = new RGBController_WushiL50USB(controller); - rgb_controller->name = name; ResourceManager::get()->RegisterRGBController(rgb_controller); }