Store name in RedragonMouseController to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-14 19:28:20 -05:00
parent ce86faabfe
commit 06413f2877
4 changed files with 50 additions and 41 deletions

View file

@ -24,48 +24,48 @@
RGBController_RedragonMouse::RGBController_RedragonMouse(RedragonMouseController* controller_ptr) RGBController_RedragonMouse::RGBController_RedragonMouse(RedragonMouseController* controller_ptr)
{ {
controller = controller_ptr; controller = controller_ptr;
name = "Redragon Mouse Device"; name = controller->GetNameString();
vendor = "Redragon"; vendor = "Redragon";
type = DEVICE_TYPE_MOUSE; type = DEVICE_TYPE_MOUSE;
description = "Redragon Mouse Device"; description = "Redragon Mouse Device";
location = controller->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = controller->GetSerialString(); serial = controller->GetSerialString();
mode Static; mode Static;
Static.name = "Static"; Static.name = "Static";
Static.value = REDRAGON_MOUSE_MODE_STATIC; Static.value = REDRAGON_MOUSE_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE; Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Static.color_mode = MODE_COLORS_PER_LED; Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static); modes.push_back(Static);
mode Wave; mode Wave;
Wave.name = "Wave"; Wave.name = "Wave";
Wave.value = REDRAGON_MOUSE_MODE_WAVE; Wave.value = REDRAGON_MOUSE_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE; Wave.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Wave.color_mode = MODE_COLORS_PER_LED; Wave.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Wave); modes.push_back(Wave);
mode Breathing; mode Breathing;
Breathing.name = "Breathing"; Breathing.name = "Breathing";
Breathing.value = REDRAGON_MOUSE_MODE_BREATHING; Breathing.value = REDRAGON_MOUSE_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_AUTOMATIC_SAVE; Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Breathing.color_mode = MODE_COLORS_PER_LED; Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing); modes.push_back(Breathing);
mode Rainbow; mode Rainbow;
Rainbow.name = "Rainbow"; Rainbow.name = "Rainbow";
Rainbow.value = REDRAGON_MOUSE_MODE_RAINBOW; Rainbow.value = REDRAGON_MOUSE_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_AUTOMATIC_SAVE; Rainbow.flags = MODE_FLAG_AUTOMATIC_SAVE;
Rainbow.color_mode = MODE_COLORS_NONE; Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow); modes.push_back(Rainbow);
mode Flashing; mode Flashing;
Flashing.name = "Flashing"; Flashing.name = "Flashing";
Flashing.value = REDRAGON_MOUSE_MODE_FLASHING; Flashing.value = REDRAGON_MOUSE_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE; Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Flashing.color_mode = MODE_COLORS_PER_LED; Flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flashing); modes.push_back(Flashing);
SetupZones(); SetupZones();
@ -79,16 +79,16 @@ RGBController_RedragonMouse::~RGBController_RedragonMouse()
void RGBController_RedragonMouse::SetupZones() void RGBController_RedragonMouse::SetupZones()
{ {
zone mouse_zone; zone mouse_zone;
mouse_zone.name = "Mouse"; mouse_zone.name = "Mouse";
mouse_zone.type = ZONE_TYPE_SINGLE; mouse_zone.type = ZONE_TYPE_SINGLE;
mouse_zone.leds_min = REDRAGON_MOUSE_LED_COUNT; mouse_zone.leds_min = REDRAGON_MOUSE_LED_COUNT;
mouse_zone.leds_max = REDRAGON_MOUSE_LED_COUNT; mouse_zone.leds_max = REDRAGON_MOUSE_LED_COUNT;
mouse_zone.leds_count = REDRAGON_MOUSE_LED_COUNT; mouse_zone.leds_count = REDRAGON_MOUSE_LED_COUNT;
mouse_zone.matrix_map = NULL; mouse_zone.matrix_map = NULL;
zones.push_back(mouse_zone); zones.push_back(mouse_zone);
led mouse_led; led mouse_led;
mouse_led.name = "Mouse"; mouse_led.name = "Mouse";
leds.push_back(mouse_led); leds.push_back(mouse_led);
SetupColors(); SetupColors();

View file

@ -39,11 +39,12 @@
void DetectRedragonMice(hid_device_info* info, const std::string& name) void DetectRedragonMice(hid_device_info* info, const std::string& name)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev )
if(dev)
{ {
RedragonMouseController* controller = new RedragonMouseController(dev, info->path); RedragonMouseController* controller = new RedragonMouseController(dev, info->path, name);
RGBController_RedragonMouse* rgb_controller = new RGBController_RedragonMouse(controller); RGBController_RedragonMouse* rgb_controller = new RGBController_RedragonMouse(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} }

View file

@ -13,10 +13,11 @@
#include "RedragonMouseController.h" #include "RedragonMouseController.h"
#include "StringUtils.h" #include "StringUtils.h"
RedragonMouseController::RedragonMouseController(hid_device* dev_handle, const char* path) RedragonMouseController::RedragonMouseController(hid_device* dev_handle, const char* path, std::string dev_name)
{ {
dev = dev_handle; dev = dev_handle;
location = path; location = path;
name = dev_name;
unsigned char active_profile = 0x00; unsigned char active_profile = 0x00;
@ -34,6 +35,11 @@ std::string RedragonMouseController::GetDeviceLocation()
return("HID: " + location); return("HID: " + location);
} }
std::string RedragonMouseController::GetNameString()
{
return(name);
}
std::string RedragonMouseController::GetSerialString() std::string RedragonMouseController::GetSerialString()
{ {
wchar_t serial_string[128]; wchar_t serial_string[128];

View file

@ -31,10 +31,11 @@ enum
class RedragonMouseController class RedragonMouseController
{ {
public: public:
RedragonMouseController(hid_device* dev_handle, const char* path); RedragonMouseController(hid_device* dev_handle, const char* path, std::string dev_name);
~RedragonMouseController(); ~RedragonMouseController();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString(); std::string GetSerialString();
void SendMouseApply(); void SendMouseApply();
@ -62,8 +63,9 @@ public:
); );
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
void SendWritePacket void SendWritePacket
( (