Store name in KeychronKeyboardController to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-11 18:29:59 -05:00
parent ca73941e5d
commit a1f144daf2
4 changed files with 15 additions and 14 deletions

View file

@ -15,11 +15,11 @@
using namespace std::chrono_literals;
KeychronKeyboardController::KeychronKeyboardController(hid_device* dev_handle, const hid_device_info& info)
KeychronKeyboardController::KeychronKeyboardController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
{
dev = dev_handle;
version = "";
location = info.path;
name = dev_name;
}
KeychronKeyboardController::~KeychronKeyboardController()
@ -32,6 +32,11 @@ std::string KeychronKeyboardController::GetDeviceLocation()
return("HID: " + location);
}
std::string KeychronKeyboardController::GetNameString()
{
return(name);
}
std::string KeychronKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
@ -45,11 +50,6 @@ std::string KeychronKeyboardController::GetSerialString()
return(StringUtils::wstring_to_string(serial_string));
}
std::string KeychronKeyboardController::GetFirmwareVersion()
{
return(version);
}
void KeychronKeyboardController:: SetLedSequencePositions(std::vector<unsigned int> positions)
{
led_sequence_positions = positions;

View file

@ -91,12 +91,12 @@ enum
class KeychronKeyboardController
{
public:
KeychronKeyboardController(hid_device* dev_handle, const hid_device_info& info);
KeychronKeyboardController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
~KeychronKeyboardController();
std::string GetSerialString();
std::string GetDeviceLocation();
std::string GetFirmwareVersion();
std::string GetNameString();
std::string GetSerialString();
void SetLedSequencePositions(std::vector<unsigned int> positions);
void SetMode(std::vector<mode> modes, int active_mode, std::vector<RGBColor> colors);
@ -106,6 +106,7 @@ protected:
private:
std::string location;
std::string name;
std::string version;
std::vector<unsigned int> led_sequence_positions;

View file

@ -29,9 +29,9 @@ void DetectKeychronKeyboardControllers(hid_device_info* info, const std::string&
if(dev)
{
KeychronKeyboardController* controller = new KeychronKeyboardController(dev, *info);
KeychronKeyboardController* controller = new KeychronKeyboardController(dev, *info, name);
RGBController_KeychronKeyboard* rgb_controller = new RGBController_KeychronKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -430,13 +430,13 @@ typedef struct
RGBController_KeychronKeyboard::RGBController_KeychronKeyboard(KeychronKeyboardController* controller_ptr)
{
controller = controller_ptr;
name = "Keychron Keyboard";
name = controller->GetNameString();
vendor = "Keychron";
type = DEVICE_TYPE_KEYBOARD;
description = name;
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
version = controller->GetFirmwareVersion();
mode Custom;
Custom.name = "Custom";