Store name in LogitechControllers to avoid setting it in detectors

This commit is contained in:
Adam Honse 2025-08-16 16:47:44 -05:00
parent 86fbdfa6e7
commit a0726dc065
35 changed files with 258 additions and 185 deletions

View file

@ -148,9 +148,9 @@ void DetectLogitechKeyboardG213(hid_device_info* info, const std::string& name)
if(dev)
{
LogitechG213Controller* controller = new LogitechG213Controller(dev, info->path);
LogitechG213Controller* controller = new LogitechG213Controller(dev, info->path, name);
RGBController_LogitechG213* rgb_controller = new RGBController_LogitechG213(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -190,9 +190,8 @@ void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name)
}
if(dev_usage_0x0602 && dev_usage_0x0604)
{
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604);
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604, name);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -207,9 +206,8 @@ void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name)
if(dev)
{
LogitechG810Controller* controller = new LogitechG810Controller(dev, dev);
LogitechG810Controller* controller = new LogitechG810Controller(dev, dev, name);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -251,9 +249,8 @@ void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name)
}
if(dev_usage_0x0602 && dev_usage_0x0604)
{
LogitechG910Controller* controller = new LogitechG910Controller(dev_usage_0x0602, dev_usage_0x0604);
LogitechG910Controller* controller = new LogitechG910Controller(dev_usage_0x0602, dev_usage_0x0604, name);
RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -268,9 +265,8 @@ void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name)
if(dev)
{
LogitechG910Controller* controller = new LogitechG910Controller(dev, dev);
LogitechG910Controller* controller = new LogitechG910Controller(dev, dev, name);
RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -312,9 +308,8 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
}
if(dev_usage_0x0602 && dev_usage_0x0604)
{
LogitechG815Controller* controller = new LogitechG815Controller(dev_usage_0x0602, dev_usage_0x0604);
LogitechG815Controller* controller = new LogitechG815Controller(dev_usage_0x0602, dev_usage_0x0604, name);
RGBController_LogitechG815* rgb_controller = new RGBController_LogitechG815(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -337,9 +332,8 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
if(dev)
{
LogitechG815Controller* controller = new LogitechG815Controller(dev, dev);
LogitechG815Controller* controller = new LogitechG815Controller(dev, dev, name);
RGBController_LogitechG815* rgb_controller = new RGBController_LogitechG815(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -353,9 +347,8 @@ void DetectLogitechKeyboardG915(hid_device_info* info, const std::string& name)
if(dev)
{
LogitechG915Controller* controller = new LogitechG915Controller(dev, false);
LogitechG915Controller* controller = new LogitechG915Controller(dev, false, name);
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller, is_tkl);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -368,9 +361,8 @@ void DetectLogitechKeyboardG915Wired(hid_device_info* info, const std::string& n
if(dev)
{
LogitechG915Controller* controller = new LogitechG915Controller(dev, true);
LogitechG915Controller* controller = new LogitechG915Controller(dev, true, name);
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller, is_tkl);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -411,9 +403,8 @@ void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name)
}
if(dev_usage_0x0602 && dev_usage_0x0604)
{
LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev_usage_0x0602, dev_usage_0x0604);
LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev_usage_0x0602, dev_usage_0x0604, name);
RGBController_LogitechGProKeyboard* rgb_controller = new RGBController_LogitechGProKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -428,9 +419,8 @@ void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name)
if(dev)
{
LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev, dev);
LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev, dev, name);
RGBController_LogitechGProKeyboard* rgb_controller = new RGBController_LogitechGProKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -472,9 +462,8 @@ static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::str
}
if(dev_usage_1 && dev_usage_2)
{
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev_usage_1, dev_usage_2, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id);
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev_usage_1, dev_usage_2, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id, name);
RGBController_LogitechGLightsync1zone* rgb_controller = new RGBController_LogitechGLightsync1zone (controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -492,9 +481,8 @@ static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::str
if(dev)
{
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id);
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id, name);
RGBController_LogitechGLightsync1zone* rgb_controller = new RGBController_LogitechGLightsync1zone(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -534,9 +522,8 @@ static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::str
}
if(dev_usage_1 && dev_usage_2)
{
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev_usage_1, dev_usage_2, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id);
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev_usage_1, dev_usage_2, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id, name);
RGBController_LogitechGLightsync* rgb_controller = new RGBController_LogitechGLightsync (controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -553,9 +540,8 @@ static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::str
if(dev)
{
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id);
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id, name);
RGBController_LogitechGLightsync* rgb_controller = new RGBController_LogitechGLightsync(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -574,9 +560,8 @@ void DetectLogitechMouseG203L(hid_device_info* info, const std::string& name)
if(dev)
{
LogitechG203LController* controller = new LogitechG203LController(dev, info->path);
LogitechG203LController* controller = new LogitechG203LController(dev, info->path, name);
RGBController_LogitechG203L* rgb_controller = new RGBController_LogitechG203L(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -609,9 +594,8 @@ void DetectLogitechG560(hid_device_info* info, const std::string& name)
/*---------------------------------------------*\
| Add G560 Speaker |
\*---------------------------------------------*/
LogitechG560Controller* controller = new LogitechG560Controller(dev, info->path);
LogitechG560Controller* controller = new LogitechG560Controller(dev, info->path, name);
RGBController_LogitechG560* rgb_controller = new RGBController_LogitechG560(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -626,9 +610,8 @@ void DetectLogitechG933(hid_device_info* info, const std::string& name)
/*---------------------------------------------*\
| Add G933 Headset |
\*---------------------------------------------*/
LogitechG933Controller* controller = new LogitechG933Controller(dev, info->path);
LogitechG933Controller* controller = new LogitechG933Controller(dev, info->path, name);
RGBController_LogitechG933* rgb_controller = new RGBController_LogitechG933(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
@ -643,9 +626,8 @@ void DetectLogitechX56(hid_device_info* info, const std::string& name)
/*---------------------------------------------*\
| Add X56 Devices |
\*---------------------------------------------*/
LogitechX56Controller* controller = new LogitechX56Controller(dev, info->path);
LogitechX56Controller* controller = new LogitechX56Controller(dev, info->path, name);
RGBController_LogitechX56* rgb_controller = new RGBController_LogitechX56(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}

View file

@ -13,10 +13,11 @@
#define PACKET_SIZE 20
LogitechG203LController::LogitechG203LController(hid_device* dev_handle, const char* path)
LogitechG203LController::LogitechG203LController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
// enable software control
unsigned char usb_buf[PACKET_SIZE];
@ -47,6 +48,11 @@ std::string LogitechG203LController::GetDeviceLocation()
return("HID: " + location);
}
std::string LogitechG203LController::GetNameString()
{
return(name);
}
std::string LogitechG203LController::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -27,10 +27,11 @@ enum
class LogitechG203LController
{
public:
LogitechG203LController(hid_device* dev_handle, const char* path);
LogitechG203LController(hid_device* dev_handle, const char* path, std::string dev_name);
~LogitechG203LController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void SetSingleLED(int led, unsigned char red, unsigned char green, unsigned char blue);
@ -38,8 +39,9 @@ public:
void SetDevice(std::vector<RGBColor> colors);
private:
hid_device* dev;
std::string location;
hid_device* dev;
std::string location;
std::string name;
void SendApply();
void SendPacket(unsigned char* buffer);

View file

@ -22,14 +22,14 @@
RGBController_LogitechG203L::RGBController_LogitechG203L(LogitechG203LController* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Logitech Mouse Device";
vendor = "Logitech";
type = DEVICE_TYPE_MOUSE;
description = "Logitech Mouse Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_MOUSE;
description = "Logitech Mouse Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";

View file

@ -13,10 +13,11 @@
#include "LogitechG213Controller.h"
#include "StringUtils.h"
LogitechG213Controller::LogitechG213Controller(hid_device* dev_handle, const char* path)
LogitechG213Controller::LogitechG213Controller(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
LogitechG213Controller::~LogitechG213Controller()
@ -29,6 +30,11 @@ std::string LogitechG213Controller::GetDeviceLocation()
return("HID: " + location);
}
std::string LogitechG213Controller::GetNameString()
{
return(name);
}
std::string LogitechG213Controller::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -52,10 +52,11 @@ enum
class LogitechG213Controller
{
public:
LogitechG213Controller(hid_device* dev_handle, const char* path);
LogitechG213Controller(hid_device* dev_handle, const char* path, std::string dev_name);
~LogitechG213Controller();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void SetDirect
@ -79,6 +80,7 @@ public:
private:
hid_device* dev;
std::string location;
std::string name;
void SendMode
(

View file

@ -44,14 +44,14 @@ static const unsigned char led_values[] =
RGBController_LogitechG213::RGBController_LogitechG213(LogitechG213Controller* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Logitech G213 Keyboard Device";
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech G213 Keyboard Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech G213 Keyboard Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
@ -78,14 +78,14 @@ RGBController_LogitechG213::RGBController_LogitechG213(LogitechG213Controller* c
modes.push_back(Cycle);
mode Wave;
Wave.name = "Wave";
Wave.value = LOGITECH_G213_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD;
Wave.color_mode = MODE_COLORS_NONE;
Wave.speed_min = LOGITECH_G213_SPEED_SLOWEST;
Wave.speed_max = LOGITECH_G213_SPEED_FASTEST;
Wave.speed = LOGITECH_G213_SPEED_NORMAL;
Wave.direction = MODE_DIRECTION_LEFT;
Wave.name = "Wave";
Wave.value = LOGITECH_G213_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_DIRECTION_UD;
Wave.color_mode = MODE_COLORS_NONE;
Wave.speed_min = LOGITECH_G213_SPEED_SLOWEST;
Wave.speed_max = LOGITECH_G213_SPEED_FASTEST;
Wave.speed = LOGITECH_G213_SPEED_NORMAL;
Wave.direction = MODE_DIRECTION_LEFT;
modes.push_back(Wave);
mode Breathing;

View file

@ -17,10 +17,11 @@
using namespace std::chrono_literals;
LogitechG560Controller::LogitechG560Controller(hid_device* dev_handle, const char* path)
LogitechG560Controller::LogitechG560Controller(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
LogitechG560Controller::~LogitechG560Controller()
@ -33,6 +34,11 @@ std::string LogitechG560Controller::GetDeviceLocation()
return("HID: " + location);
}
std::string LogitechG560Controller::GetDeviceName()
{
return(name);
}
void LogitechG560Controller::SetDirectMode(uint8_t zone)
{
unsigned char usb_buf[LOGI_G560_LED_PACKET_SIZE];

View file

@ -30,13 +30,14 @@ enum
class LogitechG560Controller
{
public:
LogitechG560Controller(hid_device* dev_handle, const char* path);
LogitechG560Controller(hid_device* dev_handle, const char* path, std::string dev_name);
~LogitechG560Controller();
std::string GetDeviceLocation();
std::string GetDeviceName();
void SetDirectMode(uint8_t zone);
void SetOffMode(uint8_t zone);
void SetDirectMode(uint8_t zone);
void SetOffMode(uint8_t zone);
void SendSpeakerMode
(
@ -48,10 +49,11 @@ public:
);
private:
hid_device* dev;
std::string location;
hid_device* dev;
std::string location;
std::string name;
void fail_retry_write(hid_device *device, const unsigned char *data, size_t length);
void fail_retry_write(hid_device *device, const unsigned char *data, size_t length);
};

View file

@ -25,13 +25,13 @@
RGBController_LogitechG560::RGBController_LogitechG560(LogitechG560Controller* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Logitech G560 Lightsync Speaker";
vendor = "Logitech";
type = DEVICE_TYPE_SPEAKER;
description = "Logitech G560 Lightsync Speaker";
location = controller->GetDeviceLocation();
name = controller->GetDeviceName();
vendor = "Logitech";
type = DEVICE_TYPE_SPEAKER;
description = "Logitech G560 Lightsync Speaker";
location = controller->GetDeviceLocation();
mode Off;
Off.name = "Off";

View file

@ -13,10 +13,11 @@
#include "LogitechG810Controller.h"
#include "StringUtils.h"
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12)
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name)
{
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
name = dev_name;
}
LogitechG810Controller::~LogitechG810Controller()
@ -25,6 +26,11 @@ LogitechG810Controller::~LogitechG810Controller()
hid_close(dev_pkt_0x12);
}
std::string LogitechG810Controller::GetNameString()
{
return(name);
}
std::string LogitechG810Controller::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -52,9 +52,10 @@ enum
class LogitechG810Controller
{
public:
LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12);
LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name);
~LogitechG810Controller();
std::string GetNameString();
std::string GetSerialString();
void Commit();
@ -78,6 +79,7 @@ public:
private:
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
std::string name;
void SendDirectFrame
(

View file

@ -181,13 +181,13 @@ static const led_type led_names[] =
RGBController_LogitechG810::RGBController_LogitechG810(LogitechG810Controller* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Logitech Keyboard Device";
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech Keyboard Device";
serial = controller->GetSerialString();
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech Keyboard Device";
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";

View file

@ -13,10 +13,11 @@
#include "LogitechG815Controller.h"
#include "StringUtils.h"
LogitechG815Controller::LogitechG815Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12)
LogitechG815Controller::LogitechG815Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name)
{
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
name = dev_name;
}
LogitechG815Controller::~LogitechG815Controller()
@ -24,6 +25,11 @@ LogitechG815Controller::~LogitechG815Controller()
}
std::string LogitechG815Controller::GetNameString()
{
return(name);
}
std::string LogitechG815Controller::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -65,10 +65,12 @@ enum
class LogitechG815Controller
{
public:
LogitechG815Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12);
LogitechG815Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name);
~LogitechG815Controller();
std::string GetNameString();
std::string GetSerialString();
void Commit();
void InitializeDirect();
void SetDirect
@ -95,6 +97,7 @@ public:
private:
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
std::string name;
void SendDirectFrame
(

View file

@ -185,13 +185,13 @@ static const logitech_g815_led led_names[] =
RGBController_LogitechG815::RGBController_LogitechG815(LogitechG815Controller* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Logitech G815 Keyboard Device";
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech G815 Keyboard Device";
serial = controller->GetSerialString();
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech G815 Keyboard Device";
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";

View file

@ -13,10 +13,11 @@
#include "LogitechG910Controller.h"
#include "StringUtils.h"
LogitechG910Controller::LogitechG910Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12)
LogitechG910Controller::LogitechG910Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name)
{
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
name = dev_name;
}
LogitechG910Controller::~LogitechG910Controller()
@ -25,6 +26,11 @@ LogitechG910Controller::~LogitechG910Controller()
hid_close(dev_pkt_0x12);
}
std::string LogitechG910Controller::GetNameString()
{
return(name);
}
std::string LogitechG910Controller::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -52,9 +52,10 @@ enum
class LogitechG910Controller
{
public:
LogitechG910Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12);
LogitechG910Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name);
~LogitechG910Controller();
std::string GetNameString();
std::string GetSerialString();
void Commit();
@ -78,6 +79,7 @@ public:
private:
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
std::string name;
void SendDirectFrame
(

View file

@ -182,13 +182,13 @@ static const led_type led_names[] =
RGBController_LogitechG910::RGBController_LogitechG910(LogitechG910Controller* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Logitech Keyboard Device";
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech Keyboard Device";
serial = controller->GetSerialString();
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech Keyboard Device";
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";

View file

@ -19,25 +19,26 @@ const size_t HEADER_SIZE = 4;
const size_t MESSAGE_LEN = 20;
const size_t RESPONSE_LEN = 20;
LogitechG915Controller::LogitechG915Controller(hid_device* dev_handle, bool wired)
LogitechG915Controller::LogitechG915Controller(hid_device* dev_handle, bool wired, std::string dev_name)
{
this->dev_handle = dev_handle;
this->dev_handle = dev_handle;
this->name = dev_name;
if(wired)
{
device_index = 0xFF;
feature_4522_idx = 0x0E;
feature_8040_idx = 0x13;
feature_8071_idx = 0x09;
feature_8081_idx = 0x0A;
device_index = 0xFF;
feature_4522_idx = 0x0E;
feature_8040_idx = 0x13;
feature_8071_idx = 0x09;
feature_8081_idx = 0x0A;
}
else
{
device_index = 0x01;
feature_4522_idx = 0x0F;
feature_8040_idx = 0x14;
feature_8071_idx = 0x0A;
feature_8081_idx = 0x0B;
device_index = 0x01;
feature_4522_idx = 0x0F;
feature_8040_idx = 0x14;
feature_8071_idx = 0x0A;
feature_8081_idx = 0x0B;
}
}
@ -46,6 +47,11 @@ LogitechG915Controller::~LogitechG915Controller()
}
std::string LogitechG915Controller::GetNameString()
{
return(name);
}
std::string LogitechG915Controller::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -83,10 +83,12 @@ enum
class LogitechG915Controller
{
public:
LogitechG915Controller(hid_device* dev_handle, bool wired);
LogitechG915Controller(hid_device* dev_handle, bool wired, std::string dev_name);
~LogitechG915Controller();
std::string GetNameString();
std::string GetSerialString();
void Commit();
void InitializeDirect();
void InitializeModeSet();
@ -115,12 +117,13 @@ public:
);
private:
hid_device* dev_handle;
unsigned char feature_4522_idx;
unsigned char device_index;
unsigned char feature_8040_idx;
unsigned char feature_8071_idx;
unsigned char feature_8081_idx;
hid_device* dev_handle;
unsigned char feature_4522_idx;
unsigned char device_index;
unsigned char feature_8040_idx;
unsigned char feature_8071_idx;
unsigned char feature_8081_idx;
std::string name;
void SendDirectFrame
(

View file

@ -282,14 +282,14 @@ RGBController_LogitechG915::RGBController_LogitechG915(LogitechG915Controller* c
if(is_tkl)
{
name = "Logitech G915TKL Keyboard Device";
description = "Logitech G915TKL Keyboard Device";
}
else
{
name = "Logitech G915 Keyboard Device";
description = "Logitech G915 Keyboard Device";
}
description = name;
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
serial = controller->GetSerialString();

View file

@ -17,10 +17,11 @@
using namespace std::chrono_literals;
LogitechG933Controller::LogitechG933Controller(hid_device* dev_handle, const char* path)
LogitechG933Controller::LogitechG933Controller(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
LogitechG933Controller::~LogitechG933Controller()
@ -33,6 +34,11 @@ std::string LogitechG933Controller::GetDeviceLocation()
return("HID: " + location);
}
std::string LogitechG933Controller::GetDeviceName()
{
return(name);
}
void LogitechG933Controller::SetDirectMode(uint8_t zone)
{
unsigned char usb_buf[LOGI_G933_LED_PACKET_SIZE];

View file

@ -30,13 +30,14 @@ enum
class LogitechG933Controller
{
public:
LogitechG933Controller(hid_device* dev_handle, const char* path);
LogitechG933Controller(hid_device* dev_handle, const char* path, std::string dev_name);
~LogitechG933Controller();
std::string GetDeviceLocation();
std::string GetDeviceName();
void SetDirectMode(uint8_t zone);
void SetOffMode(uint8_t zone);
void SetDirectMode(uint8_t zone);
void SetOffMode(uint8_t zone);
void SendHeadsetMode
(
@ -48,10 +49,11 @@ public:
);
private:
hid_device* dev;
std::string location;
hid_device* dev;
std::string location;
std::string name;
void fail_retry_write(hid_device *device, const unsigned char *data, size_t length);
void fail_retry_write(hid_device *device, const unsigned char *data, size_t length);
};

View file

@ -25,13 +25,13 @@
RGBController_LogitechG933::RGBController_LogitechG933(LogitechG933Controller* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Logitech G933 Lightsync Headset";
vendor = "Logitech";
type = DEVICE_TYPE_HEADSET;
description = "Logitech G933 Lightsync Headset";
location = controller->GetDeviceLocation();
name = controller->GetDeviceName();
vendor = "Logitech";
type = DEVICE_TYPE_HEADSET;
description = "Logitech G933 Lightsync Headset";
location = controller->GetDeviceLocation();
mode Off;
Off.name = "Off";

View file

@ -13,7 +13,7 @@
#include "LogitechGLightsyncController.h"
#include "StringUtils.h"
LogitechGLightsyncController::LogitechGLightsyncController(hid_device* dev_cmd_handle, hid_device *dev_handle, const char *path, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id)
LogitechGLightsyncController::LogitechGLightsyncController(hid_device* dev_cmd_handle, hid_device *dev_handle, const char *path, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id, std::string dev_name)
{
dev = dev_handle;
cmd_dev = dev_cmd_handle;
@ -22,9 +22,10 @@ LogitechGLightsyncController::LogitechGLightsyncController(hid_device* dev_cmd_h
feature_index = hid_feature_index;
fctn_ase_id = hid_fctn_ase_id;
mutex = nullptr;
name = dev_name;
}
LogitechGLightsyncController::LogitechGLightsyncController(hid_device* dev_cmd_handle, hid_device *dev_handle, const char *path, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id, std::shared_ptr<std::mutex> mutex_ptr)
LogitechGLightsyncController::LogitechGLightsyncController(hid_device* dev_cmd_handle, hid_device *dev_handle, const char *path, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id, std::shared_ptr<std::mutex> mutex_ptr, std::string dev_name)
{
dev = dev_handle;
cmd_dev = dev_cmd_handle;
@ -33,6 +34,7 @@ LogitechGLightsyncController::LogitechGLightsyncController(hid_device* dev_cmd_h
feature_index = hid_feature_index;
fctn_ase_id = hid_fctn_ase_id;
mutex = mutex_ptr;
name = dev_name;
}
LogitechGLightsyncController::~LogitechGLightsyncController()
@ -45,6 +47,11 @@ std::string LogitechGLightsyncController::GetDeviceLocation()
return ("HID: " + location);
}
std::string LogitechGLightsyncController::GetNameString()
{
return(name);
}
std::string LogitechGLightsyncController::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -38,25 +38,33 @@ enum
class LogitechGLightsyncController
{
public:
LogitechGLightsyncController(
hid_device* dev_cmd_handle,
hid_device* dev_handle,
const char* path,
unsigned char hid_dev_index,
unsigned char hid_feature_index,
unsigned char hid_fctn_ase_id);
LogitechGLightsyncController(
hid_device* dev_cmd_handle,
hid_device* dev_handle,
const char* path,
unsigned char hid_dev_index,
unsigned char hid_feature_index,
unsigned char hid_fctn_ase_id,
std::shared_ptr<std::mutex> mutex_ptr);
LogitechGLightsyncController
(
hid_device* ev_cmd_handle,
hid_device* ev_handle,
const char* ath,
unsigned char id_dev_index,
unsigned char id_feature_index,
unsigned char id_fctn_ase_id,
std::string ev_name
);
LogitechGLightsyncController
(
hid_device* dev_cmd_handle,
hid_device* dev_handle,
const char* path,
unsigned char hid_dev_index,
unsigned char hid_feature_index,
unsigned char hid_fctn_ase_id,
std::shared_ptr<std::mutex> mutex_ptr,
std::string dev_name
);
~LogitechGLightsyncController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void UpdateMouseLED
@ -75,6 +83,7 @@ private:
hid_device* dev;
hid_device* cmd_dev;
std::string location;
std::string name;
unsigned char dev_index;
unsigned char feature_index;
unsigned char fctn_ase_id;

View file

@ -26,7 +26,7 @@ RGBController_LogitechGLightsync::RGBController_LogitechGLightsync(LogitechGLigh
{
controller = controller_ptr;
name = "Logitech G Lightsync Mouse";
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_MOUSE;
description = "Logitech G Lightsync Mouse";

View file

@ -26,7 +26,7 @@ RGBController_LogitechGLightsync1zone::RGBController_LogitechGLightsync1zone(Log
{
controller = controller_ptr;
name = "Logitech G Lightsync Mouse Single Zone";
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_MOUSE;
description = "Logitech G Lightsync Mouse Single Zone";

View file

@ -26,7 +26,7 @@ RGBController_LogitechGPowerPlay::RGBController_LogitechGPowerPlay(LogitechGLigh
{
controller = controller_ptr;
name = "Logitech G PowerPlay Wireless Charging System";
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_MOUSEMAT;
description = "Logitech G PowerPlay Wireless Charging System";

View file

@ -13,10 +13,11 @@
#include "LogitechGProKeyboardController.h"
#include "StringUtils.h"
LogitechGProKeyboardController::LogitechGProKeyboardController(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12)
LogitechGProKeyboardController::LogitechGProKeyboardController(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name)
{
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
name = dev_name;
}
LogitechGProKeyboardController::~LogitechGProKeyboardController()
@ -25,6 +26,11 @@ LogitechGProKeyboardController::~LogitechGProKeyboardController()
hid_close(dev_pkt_0x12);
}
std::string LogitechGProKeyboardController::GetNameString()
{
return(name);
}
std::string LogitechGProKeyboardController::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -52,13 +52,14 @@ enum
class LogitechGProKeyboardController
{
public:
LogitechGProKeyboardController(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12);
LogitechGProKeyboardController(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name);
~LogitechGProKeyboardController();
std::string GetNameString();
std::string GetSerialString();
void Commit();
void SetDirect
(
unsigned char zone,
@ -78,6 +79,7 @@ public:
private:
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
std::string name;
void SendDirectFrame
(

View file

@ -158,13 +158,13 @@ static const led_type led_names[] =
RGBController_LogitechGProKeyboard::RGBController_LogitechGProKeyboard(LogitechGProKeyboardController* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = "Logitech Keyboard Device";
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech Keyboard Device";
serial = controller->GetSerialString();
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech Keyboard Device";
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";

View file

@ -13,10 +13,11 @@
#include "LogitechX56Controller.h"
#include "StringUtils.h"
LogitechX56Controller::LogitechX56Controller(hid_device* dev_handle, const char* path)
LogitechX56Controller::LogitechX56Controller(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
LogitechX56Controller::~LogitechX56Controller()
@ -29,9 +30,9 @@ std::string LogitechX56Controller::GetDeviceLocation()
return("HID: " + location);
}
char* LogitechX56Controller::GetDeviceName()
std::string LogitechX56Controller::GetDeviceName()
{
return device_name;
return(name);
}
std::string LogitechX56Controller::GetSerialString()

View file

@ -20,19 +20,19 @@
class LogitechX56Controller
{
public:
LogitechX56Controller(hid_device* dev_handle, const char* path);
LogitechX56Controller(hid_device* dev_handle, const char* path, std::string dev_name);
~LogitechX56Controller();
std::string GetDeviceLocation();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetSerialString();
void SetColor(RGBColor colors, uint8_t brightness);
void Save();
void SetColor(RGBColor colors, uint8_t brightness);
void Save();
private:
char device_name[32];
hid_device* dev;
std::string location;
hid_device* dev;
std::string location;
std::string name;
};