Store name in AsusLegacyUSBControllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-04 13:37:21 -05:00
parent 142e7fcc02
commit c761661386
10 changed files with 46 additions and 22 deletions

View file

@ -21,10 +21,11 @@
#define ASUS_CERBERUS_KB_PACKET_SIZE 8 #define ASUS_CERBERUS_KB_PACKET_SIZE 8
AsusCerberusKeyboardController::AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version) AsusCerberusKeyboardController::AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name)
{ {
dev = dev_handle; dev = dev_handle;
location = path; location = path;
name = dev_name;
version = rev_version; version = rev_version;
} }
@ -38,6 +39,11 @@ std::string AsusCerberusKeyboardController::GetDeviceLocation()
return("HID: " + location); return("HID: " + location);
} }
std::string AsusCerberusKeyboardController::GetDeviceName()
{
return(name);
}
std::string AsusCerberusKeyboardController::GetSerialString() std::string AsusCerberusKeyboardController::GetSerialString()
{ {
wchar_t serial_string[128]; wchar_t serial_string[128];

View file

@ -30,10 +30,11 @@ enum
class AsusCerberusKeyboardController class AsusCerberusKeyboardController
{ {
public: public:
AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version); AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name);
~AsusCerberusKeyboardController(); ~AsusCerberusKeyboardController();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString(); std::string GetSerialString();
std::string GetVersion(); std::string GetVersion();
@ -47,5 +48,6 @@ public:
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
unsigned short version; unsigned short version;
}; };

View file

@ -176,7 +176,7 @@ static const std::vector<led_value> led_names =
RGBController_AsusCerberusKeyboard::RGBController_AsusCerberusKeyboard(AsusCerberusKeyboardController* controller_ptr) RGBController_AsusCerberusKeyboard::RGBController_AsusCerberusKeyboard(AsusCerberusKeyboardController* controller_ptr)
{ {
controller = controller_ptr; controller = controller_ptr;
/*------------------------------------------------------------------------------------------------------*\ /*------------------------------------------------------------------------------------------------------*\
| this device has 6 different profiles, but there is no way to fetch them from the device, | | this device has 6 different profiles, but there is no way to fetch them from the device, |
@ -185,13 +185,13 @@ RGBController_AsusCerberusKeyboard::RGBController_AsusCerberusKeyboard(AsusCerbe
controller->SetProfile(1); controller->SetProfile(1);
name = "ASUS Cerberus Keyboard"; name = controller->GetDeviceName();
vendor = "ASUS"; vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
description = "ASUS Cerberus Keyboard Device"; description = "ASUS Cerberus Keyboard Device";
location = controller->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = controller->GetSerialString(); serial = controller->GetSerialString();
version = controller->GetVersion(); version = controller->GetVersion();
mode Custom; mode Custom;
Custom.name = "Custom"; Custom.name = "Custom";

View file

@ -29,9 +29,9 @@ void DetectAsusCerberusMech(hid_device_info* info, const std::string& name)
if(dev) if(dev)
{ {
AsusCerberusKeyboardController* controller = new AsusCerberusKeyboardController(dev, info->path, info->release_number); AsusCerberusKeyboardController* controller = new AsusCerberusKeyboardController(dev, info->path, info->release_number, name);
RGBController_AsusCerberusKeyboard* rgb_controller = new RGBController_AsusCerberusKeyboard(controller); RGBController_AsusCerberusKeyboard* rgb_controller = new RGBController_AsusCerberusKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} }
@ -42,9 +42,9 @@ void DetectAsusSagarisKeyboard(hid_device_info* info, const std::string& name)
if(dev) if(dev)
{ {
AsusSagarisKeyboardController* controller = new AsusSagarisKeyboardController(dev, info->path, info->release_number); AsusSagarisKeyboardController* controller = new AsusSagarisKeyboardController(dev, info->path, info->release_number, name);
RGBController_AsusSagarisKeyboard* rgb_controller = new RGBController_AsusSagarisKeyboard(controller); RGBController_AsusSagarisKeyboard* rgb_controller = new RGBController_AsusSagarisKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} }
@ -55,9 +55,9 @@ void DetectAsusStrixClaw(hid_device_info* info, const std::string& name)
if(dev) if(dev)
{ {
StrixClawController* controller = new StrixClawController(dev, info->path); StrixClawController* controller = new StrixClawController(dev, info->path, name);
RGBController_StrixClaw* rgb_controller = new RGBController_StrixClaw(controller); RGBController_StrixClaw* rgb_controller = new RGBController_StrixClaw(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} }

View file

@ -20,10 +20,11 @@
#define ASUS_SAGARIS_KB_PACKET_SIZE 65 #define ASUS_SAGARIS_KB_PACKET_SIZE 65
AsusSagarisKeyboardController::AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version) AsusSagarisKeyboardController::AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name)
{ {
dev = dev_handle; dev = dev_handle;
location = path; location = path;
name = dev_name;
version = rev_version; version = rev_version;
} }
@ -42,6 +43,11 @@ std::string AsusSagarisKeyboardController::GetDeviceLocation()
return("HID: " + location); return("HID: " + location);
} }
std::string AsusSagarisKeyboardController::GetDeviceName()
{
return(name);
}
std::string AsusSagarisKeyboardController::GetSerialString() std::string AsusSagarisKeyboardController::GetSerialString()
{ {
wchar_t serial_string[128]; wchar_t serial_string[128];

View file

@ -54,11 +54,12 @@ typedef struct
class AsusSagarisKeyboardController class AsusSagarisKeyboardController
{ {
public: public:
AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version); AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name);
~AsusSagarisKeyboardController(); ~AsusSagarisKeyboardController();
std::string GetVersion(); std::string GetVersion();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString(); std::string GetSerialString();
sagaris_mode GetMode(); sagaris_mode GetMode();
@ -73,5 +74,6 @@ public:
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
unsigned short version; unsigned short version;
}; };

View file

@ -28,7 +28,7 @@ RGBController_AsusSagarisKeyboard::RGBController_AsusSagarisKeyboard(AsusSagaris
{ {
controller = controller_ptr; controller = controller_ptr;
name = "ASUS Sagaris Keyboard"; name = controller->GetDeviceName();
vendor = "ASUS"; vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
description = "ASUS Sagaris Keyboard Device"; description = "ASUS Sagaris Keyboard Device";

View file

@ -14,10 +14,11 @@
#include "AsusStrixClawController.h" #include "AsusStrixClawController.h"
#include "StringUtils.h" #include "StringUtils.h"
StrixClawController::StrixClawController(hid_device* dev_handle, const char* path) StrixClawController::StrixClawController(hid_device* dev_handle, const char* path, std::string dev_name)
{ {
dev = dev_handle; dev = dev_handle;
location = path; location = path;
name = dev_name;
} }
StrixClawController::~StrixClawController() StrixClawController::~StrixClawController()
@ -30,6 +31,11 @@ std::string StrixClawController::GetDeviceLocation()
return("HID: " + location); return("HID: " + location);
} }
std::string StrixClawController::GetDeviceName()
{
return(name);
}
std::string StrixClawController::GetSerialString() std::string StrixClawController::GetSerialString()
{ {
wchar_t serial_string[HID_MAX_STR]; wchar_t serial_string[HID_MAX_STR];

View file

@ -20,10 +20,11 @@
class StrixClawController class StrixClawController
{ {
public: public:
StrixClawController(hid_device* dev_handle, const char* path); StrixClawController(hid_device* dev_handle, const char* path, std::string dev_name);
virtual ~StrixClawController(); virtual ~StrixClawController();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString(); std::string GetSerialString();
std::string GetVersion(); std::string GetVersion();
@ -33,4 +34,5 @@ public:
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
}; };

View file

@ -26,7 +26,7 @@ RGBController_StrixClaw::RGBController_StrixClaw(StrixClawController* controller
{ {
controller = controller_ptr; controller = controller_ptr;
name = "ASUS ROG Strix Claw"; name = controller->GetDeviceName();
vendor = "ASUS"; vendor = "ASUS";
type = DEVICE_TYPE_MOUSE; type = DEVICE_TYPE_MOUSE;
description = "ASUS Legacy Mouse Device"; description = "ASUS Legacy Mouse Device";