Store name in AlienwareKeyboardControllers to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-03 18:43:02 -05:00
parent 90c1e10cc5
commit 5e45480a0e
7 changed files with 26 additions and 10 deletions

View file

@ -14,10 +14,11 @@
#include "AlienwareAW410KController.h" #include "AlienwareAW410KController.h"
#include "StringUtils.h" #include "StringUtils.h"
AlienwareAW410KController::AlienwareAW410KController(hid_device* dev_handle, const char* path) AlienwareAW410KController::AlienwareAW410KController(hid_device* dev_handle, const char* path, std::string dev_name)
{ {
dev = dev_handle; dev = dev_handle;
location = path; location = path;
name = dev_name;
SendCommit(); SendCommit();
} }
@ -32,6 +33,11 @@ std::string AlienwareAW410KController::GetDeviceLocation()
return("HID: " + location); return("HID: " + location);
} }
std::string AlienwareAW410KController::GetDeviceName()
{
return(name);
}
std::string AlienwareAW410KController::GetSerialString() std::string AlienwareAW410KController::GetSerialString()
{ {
wchar_t serial_string[128]; wchar_t serial_string[128];

View file

@ -75,10 +75,11 @@ struct SelectedButtons
class AlienwareAW410KController class AlienwareAW410KController
{ {
public: public:
AlienwareAW410KController(hid_device* dev_handle, const char* path); AlienwareAW410KController(hid_device* dev_handle, const char* path, std::string dev_name);
~AlienwareAW410KController(); ~AlienwareAW410KController();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString(); std::string GetSerialString();
void SendInitialize(); void SendInitialize();
@ -140,6 +141,7 @@ public:
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
void SendMode void SendMode
( (

View file

@ -176,7 +176,7 @@ RGBController_AlienwareAW410K::RGBController_AlienwareAW410K(AlienwareAW410KCont
{ {
controller = controller_ptr; controller = controller_ptr;
name = "Alienware AW410K Keyboard Device"; name = controller->GetDeviceName();
vendor = "Alienware"; vendor = "Alienware";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
description = "Alienware AW410K Keyboard Device"; description = "Alienware AW410K Keyboard Device";

View file

@ -13,10 +13,11 @@
#include "AlienwareAW510KController.h" #include "AlienwareAW510KController.h"
#include "StringUtils.h" #include "StringUtils.h"
AlienwareAW510KController::AlienwareAW510KController(hid_device* dev_handle, const char* path) AlienwareAW510KController::AlienwareAW510KController(hid_device* dev_handle, const char* path, std::string dev_name)
{ {
dev = dev_handle; dev = dev_handle;
location = path; location = path;
name = dev_name;
SendCommit(); SendCommit();
} }
@ -31,6 +32,11 @@ std::string AlienwareAW510KController::GetDeviceLocation()
return("HID: " + location); return("HID: " + location);
} }
std::string AlienwareAW510KController::GetDeviceName()
{
return(name);
}
std::string AlienwareAW510KController::GetSerialString() std::string AlienwareAW510KController::GetSerialString()
{ {
wchar_t serial_string[128]; wchar_t serial_string[128];

View file

@ -77,10 +77,11 @@ struct SelectedKeys
class AlienwareAW510KController class AlienwareAW510KController
{ {
public: public:
AlienwareAW510KController(hid_device* dev_handle, const char* path); AlienwareAW510KController(hid_device* dev_handle, const char* path, std::string dev_name);
~AlienwareAW510KController(); ~AlienwareAW510KController();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString(); std::string GetSerialString();
void SendInitialize(); void SendInitialize();
@ -142,6 +143,7 @@ public:
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
void SendMode void SendMode
( (

View file

@ -175,7 +175,7 @@ RGBController_AlienwareAW510K::RGBController_AlienwareAW510K(AlienwareAW510KCont
{ {
controller = controller_ptr; controller = controller_ptr;
name = "Alienware AW510K Keyboard Device"; name = controller->GetDeviceName();
vendor = "Alienware"; vendor = "Alienware";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
description = "Alienware AW510K Keyboard Device"; description = "Alienware AW510K Keyboard Device";

View file

@ -38,9 +38,9 @@ void DetectAlienwareAW510KControllers(hid_device_info* info, const std::string&
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev ) if( dev )
{ {
AlienwareAW510KController* controller = new AlienwareAW510KController(dev, info->path); AlienwareAW510KController* controller = new AlienwareAW510KController(dev, info->path, name);
RGBController_AlienwareAW510K* rgb_controller = new RGBController_AlienwareAW510K(controller); RGBController_AlienwareAW510K* rgb_controller = new RGBController_AlienwareAW510K(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} }
@ -50,9 +50,9 @@ void DetectAlienwareAW410KControllers(hid_device_info* info, const std::string&
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev ) if( dev )
{ {
AlienwareAW410KController* controller = new AlienwareAW410KController(dev, info->path); AlienwareAW410KController* controller = new AlienwareAW410KController(dev, info->path, name);
RGBController_AlienwareAW410K* rgb_controller = new RGBController_AlienwareAW410K(controller); RGBController_AlienwareAW410K* rgb_controller = new RGBController_AlienwareAW410K(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
}/* DetectAlienwareKeyboardControllers() */ }/* DetectAlienwareKeyboardControllers() */