Store name in MountainKeyboardController to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-12 18:57:10 -05:00
parent f9bfb951ca
commit c256b6246a
4 changed files with 28 additions and 20 deletions

View file

@ -17,10 +17,11 @@
using namespace std::chrono_literals;
MountainKeyboardController::MountainKeyboardController(hid_device* dev_handle, const char* path)
MountainKeyboardController::MountainKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
MountainKeyboardController::~MountainKeyboardController()
@ -33,6 +34,11 @@ std::string MountainKeyboardController::GetDeviceLocation()
return("HID: " + location);
}
std::string MountainKeyboardController::GetNameString()
{
return(name);
}
std::string MountainKeyboardController::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -145,10 +145,11 @@ typedef struct
class MountainKeyboardController
{
public:
MountainKeyboardController(hid_device* dev_handle, const char* path);
MountainKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name);
~MountainKeyboardController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void SendOffCmd();
@ -170,11 +171,12 @@ public:
void SelectMode(unsigned char mode_idx);
private:
hid_device* dev;
std::string location;
std::string name;
void SendColorStartPacketCmd(unsigned char brightness);
void SendColorPacketCmd(unsigned char pkt_no,unsigned char brightness, unsigned char *data, unsigned int data_size);
void SendColorEdgePacketCmd(unsigned char pkt_no, unsigned char *data, unsigned int data_size);
void SendColorPacketFinishCmd();
hid_device* dev;
std::string location;
};

View file

@ -28,9 +28,9 @@ void DetectMountainKeyboardControllers(hid_device_info* info, const std::string&
if(dev)
{
MountainKeyboardController* controller = new MountainKeyboardController(dev, info->path);
MountainKeyboardController* controller = new MountainKeyboardController(dev, info->path, name);
RGBController_MountainKeyboard* rgb_controller = new RGBController_MountainKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
} /* DetectMountainKeyboardControllers() */

View file

@ -536,13 +536,14 @@ RGBController_MountainKeyboard::RGBController_MountainKeyboard(MountainKeyboardC
wheel_config * wheel_conf = controller->GetWheelConfig();
if (wheel_conf != nullptr) {
if(wheel_conf != nullptr)
{
wheel_color[0] = wheel_conf->r;
wheel_color[1] = wheel_conf->g;
wheel_color[2] = wheel_conf->b;
}
name = "Mountain Everest Keyboard";
name = controller->GetNameString();
vendor = "Mountain";
type = DEVICE_TYPE_KEYBOARD;
description = "Mountain Everest Keyboard";
@ -680,7 +681,6 @@ RGBController_MountainKeyboard::RGBController_MountainKeyboard(MountainKeyboardC
modes.push_back(Matrix);
SetupZones();
}
RGBController_MountainKeyboard::~RGBController_MountainKeyboard()