Store name in RedSquareControllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-14 19:32:37 -05:00
parent 06413f2877
commit 9680d072fa
7 changed files with 35 additions and 21 deletions

View file

@ -161,10 +161,10 @@ RGBController_RedSquareKeyrox::RGBController_RedSquareKeyrox(RedSquareKeyroxCont
{
controller = controller_ptr;
name = "Red Square Keyrox";
name = controller->GetNameString();
vendor = "Red Square";
type = DEVICE_TYPE_KEYBOARD;
description = name;
description = "Red Square Keyrox Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();

View file

@ -15,10 +15,11 @@
using namespace std::chrono_literals;
RedSquareKeyroxController::RedSquareKeyroxController(hid_device *dev_handle, const hid_device_info &info, int variant)
RedSquareKeyroxController::RedSquareKeyroxController(hid_device *dev_handle, const hid_device_info &info, int variant, std::string dev_name)
{
dev = dev_handle;
location = info.path;
name = dev_name;
this->variant = variant;
}
@ -37,6 +38,11 @@ std::string RedSquareKeyroxController::GetDeviceLocation()
return("HID: " + location);
}
std::string RedSquareKeyroxController::GetNameString()
{
return(name);
}
std::string RedSquareKeyroxController::GetSerialString()
{
wchar_t serial_wchar[128];

View file

@ -60,11 +60,12 @@ enum
class RedSquareKeyroxController
{
public:
RedSquareKeyroxController(hid_device *dev_handle, const hid_device_info &info, int variant);
RedSquareKeyroxController(hid_device *dev_handle, const hid_device_info &info, int variant, std::string dev_name);
~RedSquareKeyroxController();
int GetVariant();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
int GetDirectionLRUD(int direction); // Direction for Left-Right-Up-Down modes
@ -83,6 +84,7 @@ protected:
private:
int variant;
std::string location;
std::string name;
std::string serial_number;
std::vector<unsigned int> led_sequence_positions;
};

View file

@ -35,9 +35,8 @@ void DetectRedSquareKeyroxTKL(hid_device_info* info, const std::string& name)
if(dev)
{
RedSquareKeyroxController* controller = new RedSquareKeyroxController(dev, *info, KEYROX_VARIANT_TKL);
RedSquareKeyroxController* controller = new RedSquareKeyroxController(dev, *info, KEYROX_VARIANT_TKL, name);
RGBController_RedSquareKeyrox* rgb_controller = new RGBController_RedSquareKeyrox(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -48,14 +47,13 @@ void DetectRedSquareKeyroxTKLClassic(hid_device_info* info, const std::string& n
if(dev)
{
RedSquareKeyroxTKLClassicController* controller = new RedSquareKeyroxTKLClassicController(dev, *info);
RedSquareKeyroxTKLClassicController* controller = new RedSquareKeyroxTKLClassicController(dev, *info, name);
RGBController_RedSquareKeyroxTKLClassic* rgb_controller = new RGBController_RedSquareKeyroxTKLClassic(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_PID, 3, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL V2", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_V2_PID, 3, 0xFF00, 2);
REGISTER_HID_DETECTOR_I("Red Square Keyrox TKL Classic", DetectRedSquareKeyroxTKLClassic, RED_SQUARE_KEYROX_TKL_CLASSIC_VID, RED_SQUARE_KEYROX_TKL_CLASSIC_PID, 2);
REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_PID, 3, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Red Square Keyrox TKL V2", DetectRedSquareKeyroxTKL, RED_SQUARE_VID, RED_SQUARE_KEYROX_TKL_V2_PID, 3, 0xFF00, 2);
REGISTER_HID_DETECTOR_I( "Red Square Keyrox TKL Classic", DetectRedSquareKeyroxTKLClassic, RED_SQUARE_KEYROX_TKL_CLASSIC_VID, RED_SQUARE_KEYROX_TKL_CLASSIC_PID, 2);

View file

@ -55,16 +55,16 @@ layout_values keyrox_tkl_offset_values =
RGBController_RedSquareKeyroxTKLClassic::RGBController_RedSquareKeyroxTKLClassic(RedSquareKeyroxTKLClassicController* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Red Square Keyrox TKL Classic";
vendor = "Red Square";
type = DEVICE_TYPE_KEYBOARD;
description = name;
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
name = controller->GetNameString();
vendor = "Red Square";
type = DEVICE_TYPE_KEYBOARD;
description = "Red Square Keyrox TKL Classic Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
int BASE_EFFECT_FLAGS = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
int BASE_EFFECT_FLAGS = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
const int EFFECTS_COUNT = 14;
keyrox_effect keyrox_effects[EFFECTS_COUNT] =

View file

@ -14,10 +14,11 @@
using namespace std::chrono_literals;
RedSquareKeyroxTKLClassicController::RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info)
RedSquareKeyroxTKLClassicController::RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info, std::string dev_name)
{
dev = dev_handle;
location = info.path;
name = dev_name;
}
RedSquareKeyroxTKLClassicController::~RedSquareKeyroxTKLClassicController()
@ -30,6 +31,11 @@ std::string RedSquareKeyroxTKLClassicController::GetDeviceLocation()
return("HID: " + location);
}
std::string RedSquareKeyroxTKLClassicController::GetNameString()
{
return(name);
}
std::string RedSquareKeyroxTKLClassicController::GetSerialString()
{
wchar_t serial_wchar[128];

View file

@ -54,10 +54,11 @@ enum
class RedSquareKeyroxTKLClassicController
{
public:
RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info);
RedSquareKeyroxTKLClassicController(hid_device *dev_handle, const hid_device_info &info, std::string dev_name);
~RedSquareKeyroxTKLClassicController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
int GetDirection(int direction);
@ -71,6 +72,7 @@ protected:
private:
std::string location;
std::string name;
std::string serial_number;
std::vector<unsigned int> led_sequence_positions;
};