Store name in CorsairPeripheralV2Controllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-15 12:19:05 -05:00
parent fa74b64d6d
commit 4036a9e414
4 changed files with 9 additions and 25 deletions

View file

@ -14,21 +14,11 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
CorsairPeripheralV2Controller::CorsairPeripheralV2Controller(hid_device* dev_handle, const char* path, std::string /*name*/) CorsairPeripheralV2Controller::CorsairPeripheralV2Controller(hid_device* dev_handle, const char* path, std::string name)
{ {
dev = dev_handle; dev = dev_handle;
location = path; location = path;
device_name = name;
/*---------------------------------------------------------*\
| Get device name from HID manufacturer and product strings |
\*---------------------------------------------------------*/
wchar_t name_string[HID_MAX_STR];
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
device_name = StringUtils::wstring_to_string(name_string);
hid_get_product_string(dev, name_string, HID_MAX_STR);
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
/*---------------------------------------------------------*\ /*---------------------------------------------------------*\
| Get PID | | Get PID |

View file

@ -35,15 +35,7 @@ void DetectCorsairV2HardwareControllers(hid_device_info* info, const std::string
{ {
CorsairPeripheralV2HWController* controller = new CorsairPeripheralV2HWController(dev, info->path, name); CorsairPeripheralV2HWController* controller = new CorsairPeripheralV2HWController(dev, info->path, name);
RGBController_CorsairV2HW* rgb_controller = new RGBController_CorsairV2HW(controller); RGBController_CorsairV2HW* rgb_controller = new RGBController_CorsairV2HW(controller);
if(info->product_id == CORSAIR_SLIPSTREAM_WIRELESS_PID1
|| info->product_id == CORSAIR_SLIPSTREAM_WIRELESS_PID2)
{
rgb_controller->name = controller->GetName();
}
else
{
rgb_controller->name = name;
}
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} /* DetectCorsairV2HardwareControllers() */ } /* DetectCorsairV2HardwareControllers() */
@ -56,12 +48,11 @@ void DetectCorsairV2SoftwareControllers(hid_device_info* info, const std::string
{ {
CorsairPeripheralV2SWController* controller = new CorsairPeripheralV2SWController(dev, info->path, name); CorsairPeripheralV2SWController* controller = new CorsairPeripheralV2SWController(dev, info->path, name);
RGBController_CorsairV2SW* rgb_controller = new RGBController_CorsairV2SW(controller); RGBController_CorsairV2SW* rgb_controller = new RGBController_CorsairV2SW(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} /* DetectCorsairV2SoftwareControllers() */ } /* DetectCorsairV2SoftwareControllers() */
/*-----------------------------------------------------------------------------------------------------*\ /*-----------------------------------------------------------------------------------------------------*\
| Keyboards | | Keyboards |
\*-----------------------------------------------------------------------------------------------------*/ \*-----------------------------------------------------------------------------------------------------*/
@ -95,6 +86,7 @@ REGISTER_HID_DETECTOR_IP("Corsair M65 RGB Ultra Wired", DetectCorsai
REGISTER_HID_DETECTOR_IP("Corsair M65 RGB Ultra Wireless (Wired)", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_M65_RGB_ULTRA_WIRELESS_PID, 1, 0xFF42); REGISTER_HID_DETECTOR_IP("Corsair M65 RGB Ultra Wireless (Wired)", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_M65_RGB_ULTRA_WIRELESS_PID, 1, 0xFF42);
REGISTER_HID_DETECTOR_IP("Corsair Slipstream Wireless Receiver HW", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_SLIPSTREAM_WIRELESS_PID1, 1, 0xFF42); REGISTER_HID_DETECTOR_IP("Corsair Slipstream Wireless Receiver HW", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_SLIPSTREAM_WIRELESS_PID1, 1, 0xFF42);
REGISTER_HID_DETECTOR_IP("Corsair Slipstream Wireless Receiver SW", DetectCorsairV2SoftwareControllers, CORSAIR_VID, CORSAIR_SLIPSTREAM_WIRELESS_PID2, 1, 0xFF42); REGISTER_HID_DETECTOR_IP("Corsair Slipstream Wireless Receiver SW", DetectCorsairV2SoftwareControllers, CORSAIR_VID, CORSAIR_SLIPSTREAM_WIRELESS_PID2, 1, 0xFF42);
/*-----------------------------------------------------------------------------------------------------*\ /*-----------------------------------------------------------------------------------------------------*\
| Mousemat | | Mousemat |
\*-----------------------------------------------------------------------------------------------------*/ \*-----------------------------------------------------------------------------------------------------*/

View file

@ -31,8 +31,9 @@ RGBController_CorsairV2HW::RGBController_CorsairV2HW(CorsairPeripheralV2Controll
controller = controller_ptr; controller = controller_ptr;
const corsair_v2_device* corsair = controller->GetDeviceData(); const corsair_v2_device* corsair = controller->GetDeviceData();
name = controller->GetName();
vendor = "Corsair"; vendor = "Corsair";
description = controller->GetName(); description = "Corsair Peripheral V2 HW Device";
type = corsair->type; type = corsair->type;
version = controller->GetFirmwareString(); version = controller->GetFirmwareString();
location = controller->GetDeviceLocation(); location = controller->GetDeviceLocation();

View file

@ -31,8 +31,9 @@ RGBController_CorsairV2SW::RGBController_CorsairV2SW(CorsairPeripheralV2Controll
controller = controller_ptr; controller = controller_ptr;
const corsair_v2_device* corsair = controller->GetDeviceData(); const corsair_v2_device* corsair = controller->GetDeviceData();
name = controller->GetName();
vendor = "Corsair"; vendor = "Corsair";
description = controller->GetName(); description = "Corsair Peripheral V2 SW Device";
type = corsair->type; type = corsair->type;
version = controller->GetFirmwareString(); version = controller->GetFirmwareString();
location = controller->GetDeviceLocation(); location = controller->GetDeviceLocation();