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

View file

@ -39,11 +39,12 @@
void DetectRedragonMice(hid_device_info* info, const std::string& name)
{
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);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -13,10 +13,11 @@
#include "RedragonMouseController.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;
location = path;
name = dev_name;
unsigned char active_profile = 0x00;
@ -34,6 +35,11 @@ std::string RedragonMouseController::GetDeviceLocation()
return("HID: " + location);
}
std::string RedragonMouseController::GetNameString()
{
return(name);
}
std::string RedragonMouseController::GetSerialString()
{
wchar_t serial_string[128];

View file

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