Skip to content

Commit c761661

Browse files
Store name in AsusLegacyUSBControllers to avoid setting it in detectors
1 parent 142e7fc commit c761661

10 files changed

+46
-22
lines changed

Controllers/AsusLegacyUSBController/AsusCerberusKeyboardController/AsusCerberusKeyboardController.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121

2222
#define ASUS_CERBERUS_KB_PACKET_SIZE 8
2323

24-
AsusCerberusKeyboardController::AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version)
24+
AsusCerberusKeyboardController::AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name)
2525
{
2626
dev = dev_handle;
2727
location = path;
28+
name = dev_name;
2829
version = rev_version;
2930
}
3031

@@ -38,6 +39,11 @@ std::string AsusCerberusKeyboardController::GetDeviceLocation()
3839
return("HID: " + location);
3940
}
4041

42+
std::string AsusCerberusKeyboardController::GetDeviceName()
43+
{
44+
return(name);
45+
}
46+
4147
std::string AsusCerberusKeyboardController::GetSerialString()
4248
{
4349
wchar_t serial_string[128];

Controllers/AsusLegacyUSBController/AsusCerberusKeyboardController/AsusCerberusKeyboardController.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ enum
3030
class AsusCerberusKeyboardController
3131
{
3232
public:
33-
AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version);
33+
AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name);
3434
~AsusCerberusKeyboardController();
3535

3636
std::string GetDeviceLocation();
37+
std::string GetDeviceName();
3738
std::string GetSerialString();
3839
std::string GetVersion();
3940

@@ -47,5 +48,6 @@ class AsusCerberusKeyboardController
4748
private:
4849
hid_device* dev;
4950
std::string location;
51+
std::string name;
5052
unsigned short version;
5153
};

Controllers/AsusLegacyUSBController/AsusCerberusKeyboardController/RGBController_AsusCerberusKeyboard.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static const std::vector<led_value> led_names =
176176

177177
RGBController_AsusCerberusKeyboard::RGBController_AsusCerberusKeyboard(AsusCerberusKeyboardController* controller_ptr)
178178
{
179-
controller = controller_ptr;
179+
controller = controller_ptr;
180180

181181
/*------------------------------------------------------------------------------------------------------*\
182182
| 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
185185

186186
controller->SetProfile(1);
187187

188-
name = "ASUS Cerberus Keyboard";
189-
vendor = "ASUS";
190-
type = DEVICE_TYPE_KEYBOARD;
191-
description = "ASUS Cerberus Keyboard Device";
192-
location = controller->GetDeviceLocation();
193-
serial = controller->GetSerialString();
194-
version = controller->GetVersion();
188+
name = controller->GetDeviceName();
189+
vendor = "ASUS";
190+
type = DEVICE_TYPE_KEYBOARD;
191+
description = "ASUS Cerberus Keyboard Device";
192+
location = controller->GetDeviceLocation();
193+
serial = controller->GetSerialString();
194+
version = controller->GetVersion();
195195

196196
mode Custom;
197197
Custom.name = "Custom";

Controllers/AsusLegacyUSBController/AsusLegacyUSBControllerDetect.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ void DetectAsusCerberusMech(hid_device_info* info, const std::string& name)
2929

3030
if(dev)
3131
{
32-
AsusCerberusKeyboardController* controller = new AsusCerberusKeyboardController(dev, info->path, info->release_number);
32+
AsusCerberusKeyboardController* controller = new AsusCerberusKeyboardController(dev, info->path, info->release_number, name);
3333
RGBController_AsusCerberusKeyboard* rgb_controller = new RGBController_AsusCerberusKeyboard(controller);
34-
rgb_controller->name = name;
34+
3535
ResourceManager::get()->RegisterRGBController(rgb_controller);
3636
}
3737
}
@@ -42,9 +42,9 @@ void DetectAsusSagarisKeyboard(hid_device_info* info, const std::string& name)
4242

4343
if(dev)
4444
{
45-
AsusSagarisKeyboardController* controller = new AsusSagarisKeyboardController(dev, info->path, info->release_number);
45+
AsusSagarisKeyboardController* controller = new AsusSagarisKeyboardController(dev, info->path, info->release_number, name);
4646
RGBController_AsusSagarisKeyboard* rgb_controller = new RGBController_AsusSagarisKeyboard(controller);
47-
rgb_controller->name = name;
47+
4848
ResourceManager::get()->RegisterRGBController(rgb_controller);
4949
}
5050
}
@@ -55,9 +55,9 @@ void DetectAsusStrixClaw(hid_device_info* info, const std::string& name)
5555

5656
if(dev)
5757
{
58-
StrixClawController* controller = new StrixClawController(dev, info->path);
58+
StrixClawController* controller = new StrixClawController(dev, info->path, name);
5959
RGBController_StrixClaw* rgb_controller = new RGBController_StrixClaw(controller);
60-
rgb_controller->name = name;
60+
6161
ResourceManager::get()->RegisterRGBController(rgb_controller);
6262
}
6363
}

Controllers/AsusLegacyUSBController/AsusSagarisKeyboardController/AsusSagarisKeyboardController.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020

2121
#define ASUS_SAGARIS_KB_PACKET_SIZE 65
2222

23-
AsusSagarisKeyboardController::AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version)
23+
AsusSagarisKeyboardController::AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name)
2424
{
2525
dev = dev_handle;
2626
location = path;
27+
name = dev_name;
2728
version = rev_version;
2829
}
2930

@@ -42,6 +43,11 @@ std::string AsusSagarisKeyboardController::GetDeviceLocation()
4243
return("HID: " + location);
4344
}
4445

46+
std::string AsusSagarisKeyboardController::GetDeviceName()
47+
{
48+
return(name);
49+
}
50+
4551
std::string AsusSagarisKeyboardController::GetSerialString()
4652
{
4753
wchar_t serial_string[128];

Controllers/AsusLegacyUSBController/AsusSagarisKeyboardController/AsusSagarisKeyboardController.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ typedef struct
5454
class AsusSagarisKeyboardController
5555
{
5656
public:
57-
AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version);
57+
AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name);
5858
~AsusSagarisKeyboardController();
5959

6060
std::string GetVersion();
6161
std::string GetDeviceLocation();
62+
std::string GetDeviceName();
6263
std::string GetSerialString();
6364

6465
sagaris_mode GetMode();
@@ -73,5 +74,6 @@ class AsusSagarisKeyboardController
7374
private:
7475
hid_device* dev;
7576
std::string location;
77+
std::string name;
7678
unsigned short version;
7779
};

Controllers/AsusLegacyUSBController/AsusSagarisKeyboardController/RGBController_AsusSagarisKeyboard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ RGBController_AsusSagarisKeyboard::RGBController_AsusSagarisKeyboard(AsusSagaris
2828
{
2929
controller = controller_ptr;
3030

31-
name = "ASUS Sagaris Keyboard";
31+
name = controller->GetDeviceName();
3232
vendor = "ASUS";
3333
type = DEVICE_TYPE_KEYBOARD;
3434
description = "ASUS Sagaris Keyboard Device";

Controllers/AsusLegacyUSBController/AsusStrixClawController/AsusStrixClawController.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
#include "AsusStrixClawController.h"
1515
#include "StringUtils.h"
1616

17-
StrixClawController::StrixClawController(hid_device* dev_handle, const char* path)
17+
StrixClawController::StrixClawController(hid_device* dev_handle, const char* path, std::string dev_name)
1818
{
1919
dev = dev_handle;
2020
location = path;
21+
name = dev_name;
2122
}
2223

2324
StrixClawController::~StrixClawController()
@@ -30,6 +31,11 @@ std::string StrixClawController::GetDeviceLocation()
3031
return("HID: " + location);
3132
}
3233

34+
std::string StrixClawController::GetDeviceName()
35+
{
36+
return(name);
37+
}
38+
3339
std::string StrixClawController::GetSerialString()
3440
{
3541
wchar_t serial_string[HID_MAX_STR];

Controllers/AsusLegacyUSBController/AsusStrixClawController/AsusStrixClawController.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
class StrixClawController
2121
{
2222
public:
23-
StrixClawController(hid_device* dev_handle, const char* path);
23+
StrixClawController(hid_device* dev_handle, const char* path, std::string dev_name);
2424
virtual ~StrixClawController();
2525

2626
std::string GetDeviceLocation();
27+
std::string GetDeviceName();
2728
std::string GetSerialString();
2829
std::string GetVersion();
2930

@@ -33,4 +34,5 @@ class StrixClawController
3334
private:
3435
hid_device* dev;
3536
std::string location;
37+
std::string name;
3638
};

Controllers/AsusLegacyUSBController/AsusStrixClawController/RGBController_AsusStrixClaw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ RGBController_StrixClaw::RGBController_StrixClaw(StrixClawController* controller
2626
{
2727
controller = controller_ptr;
2828

29-
name = "ASUS ROG Strix Claw";
29+
name = controller->GetDeviceName();
3030
vendor = "ASUS";
3131
type = DEVICE_TYPE_MOUSE;
3232
description = "ASUS Legacy Mouse Device";

0 commit comments

Comments
 (0)