Store name in DarkProjectrKeyboardController to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-06 11:27:37 -05:00
parent ea206235c5
commit 13e8f70438
4 changed files with 17 additions and 23 deletions

View file

@ -28,9 +28,9 @@ void DetectDarkProjectKeyboardControllers(hid_device_info* info, const std::stri
if(dev)
{
DarkProjectKeyboardController* controller = new DarkProjectKeyboardController(dev, info->path);
DarkProjectKeyboardController* controller = new DarkProjectKeyboardController(dev, info->path, name);
RGBController_DarkProjectKeyboard* rgb_controller = new RGBController_DarkProjectKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -45,10 +45,11 @@ static uint8_t packet_map[88] =
/* Missing Indexes 9, 22, 28, 40, 46, 70, 74, 75, 82, 86, 87, 92, 98, 99, 101 */
};
DarkProjectKeyboardController::DarkProjectKeyboardController(hid_device* dev_handle, const char* path)
DarkProjectKeyboardController::DarkProjectKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
DarkProjectKeyboardController::~DarkProjectKeyboardController()
@ -56,17 +57,14 @@ DarkProjectKeyboardController::~DarkProjectKeyboardController()
hid_close(dev);
}
std::string DarkProjectKeyboardController::GetDeviceName()
std::string DarkProjectKeyboardController::GetLocation()
{
wchar_t name_string[128];
int ret = hid_get_manufacturer_string(dev, name_string, 128);
if(ret != 0)
{
return("");
return("HID: " + location);
}
return(StringUtils::wstring_to_string(name_string));
std::string DarkProjectKeyboardController::GetName()
{
return(name);
}
std::string DarkProjectKeyboardController::GetSerial()
@ -82,11 +80,6 @@ std::string DarkProjectKeyboardController::GetSerial()
return(StringUtils::wstring_to_string(serial_string));
}
std::string DarkProjectKeyboardController::GetLocation()
{
return("HID: " + location);
}
void DarkProjectKeyboardController::SetLedsDirect(std::vector<RGBColor> colors)
{
uint8_t RGbuffer[DARKPROJECTKEYBOARD_PACKET_SIZE] = { 0x08, 0x07, 0x00, 0x00, 0x00 };

View file

@ -37,15 +37,16 @@ enum
class DarkProjectKeyboardController
{
public:
DarkProjectKeyboardController(hid_device* dev_handle, const char* path);
DarkProjectKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name);
~DarkProjectKeyboardController();
std::string GetDeviceName();
std::string GetSerial();
std::string GetLocation();
std::string GetName();
std::string GetSerial();
void SetLedsDirect(std::vector<RGBColor> colors);
private:
std::string location;
hid_device* dev;
std::string location;
std::string name;
};

View file

@ -134,10 +134,10 @@ RGBController_DarkProjectKeyboard::RGBController_DarkProjectKeyboard(DarkProject
{
controller = controller_ptr;
name = "Dark Project Keyboard";
name = controller->GetName();
vendor = "Dark Project";
type = DEVICE_TYPE_KEYBOARD;
description = controller->GetDeviceName();
description = "Dark Project Keyboard Device";
serial = controller->GetSerial();
location = controller->GetLocation();