Store name in OKSKeyboardController to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-14 19:06:29 -05:00
parent e418aa7f95
commit 2c630a5218
4 changed files with 54 additions and 47 deletions

View file

@ -13,10 +13,11 @@
#include "OKSKeyboardController.h" #include "OKSKeyboardController.h"
#include "StringUtils.h" #include "StringUtils.h"
OKSKeyboardController::OKSKeyboardController(hid_device* dev_handle, const char* path, const unsigned short pid) OKSKeyboardController::OKSKeyboardController(hid_device* dev_handle, const char* path, const unsigned short pid, std::string dev_name)
{ {
dev = dev_handle; dev = dev_handle;
location = path; location = path;
name = dev_name;
usb_pid = pid; usb_pid = pid;
SendInitialize(); SendInitialize();
@ -32,6 +33,11 @@ std::string OKSKeyboardController::GetDeviceLocation()
return("HID: " + location); return("HID: " + location);
} }
std::string OKSKeyboardController::GetNameString()
{
return(name);
}
std::string OKSKeyboardController::GetSerialString() std::string OKSKeyboardController::GetSerialString()
{ {
wchar_t serial_string[128]; wchar_t serial_string[128];

View file

@ -67,10 +67,11 @@ union uint32_kb2
class OKSKeyboardController class OKSKeyboardController
{ {
public: public:
OKSKeyboardController(hid_device* dev_handle, const char* path, const unsigned short pid); OKSKeyboardController(hid_device* dev_handle, const char* path, const unsigned short pid, std::string dev_name);
~OKSKeyboardController(); ~OKSKeyboardController();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString(); std::string GetSerialString();
unsigned short GetUSBPID(); unsigned short GetUSBPID();
@ -80,6 +81,7 @@ public:
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
unsigned short usb_pid; unsigned short usb_pid;
void Send(const uint8_t bin[64], const uint16_t len); void Send(const uint8_t bin[64], const uint16_t len);

View file

@ -27,9 +27,9 @@ void DetectOKSKeyboardControllers(hid_device_info* info, const std::string& name
if(dev) if(dev)
{ {
OKSKeyboardController* controller = new OKSKeyboardController(dev, info->path, info->product_id); OKSKeyboardController* controller = new OKSKeyboardController(dev, info->path, info->product_id, name);
RGBController_OKSKeyboard* rgb_controller = new RGBController_OKSKeyboard(controller); RGBController_OKSKeyboard* rgb_controller = new RGBController_OKSKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} /* DetectOKSKeyboardControllers() */ } /* DetectOKSKeyboardControllers() */

View file

@ -111,8 +111,7 @@ RGBController_OKSKeyboard::RGBController_OKSKeyboard(OKSKeyboardController* cont
{ {
controller = controller_ptr; controller = controller_ptr;
name = controller->GetNameString();
name = "OKS Keyboard Device";
vendor = "OKS"; vendor = "OKS";
type = DEVICE_TYPE_KEYBOARD; type = DEVICE_TYPE_KEYBOARD;
description = "OKS Keyboard Device"; description = "OKS Keyboard Device";