Add optional HID device hotplug support (requires https://gitlab.com/OpenRGBDevelopers/hidapi-hotplug)

This commit is contained in:
Adam Honse
2026-01-22 13:02:56 -06:00
parent 3d113dab3c
commit 39f112bb98
46 changed files with 1434 additions and 226 deletions

View File

@@ -31,7 +31,7 @@ AOCKeyboardController::~AOCKeyboardController()
std::string AOCKeyboardController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string AOCKeyboardController::GetDeviceName()

View File

@@ -27,7 +27,7 @@ AOCMouseController::~AOCMouseController()
std::string AOCMouseController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string AOCMouseController::GetDeviceName()

View File

@@ -27,7 +27,7 @@ AOCMousematController::~AOCMousematController()
std::string AOCMousematController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string AOCMousematController::GetDeviceName()

View File

@@ -23,7 +23,7 @@ CreativeSoundBlasterXG6Controller::~CreativeSoundBlasterXG6Controller()
std::string CreativeSoundBlasterXG6Controller::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string CreativeSoundBlasterXG6Controller::GetDeviceName()

View File

@@ -26,7 +26,7 @@ HYTEKeyboardController::~HYTEKeyboardController()
std::string HYTEKeyboardController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HYTEKeyboardController::GetDeviceName()

View File

@@ -32,7 +32,7 @@ HyperXAlloyElite2Controller::~HyperXAlloyElite2Controller()
std::string HyperXAlloyElite2Controller::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXAlloyElite2Controller::GetNameString()

View File

@@ -27,7 +27,7 @@ HyperXAlloyOrigins60and65Controller::~HyperXAlloyOrigins60and65Controller()
std::string HyperXAlloyOrigins60and65Controller::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXAlloyOrigins60and65Controller::GetNameString()

View File

@@ -30,7 +30,7 @@ HyperXAlloyOriginsController::~HyperXAlloyOriginsController()
std::string HyperXAlloyOriginsController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXAlloyOriginsController::GetNameString()

View File

@@ -42,7 +42,7 @@ HyperXAlloyOriginsCoreController::~HyperXAlloyOriginsCoreController()
std::string HyperXAlloyOriginsCoreController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXAlloyOriginsCoreController::GetNameString()

View File

@@ -27,7 +27,7 @@ HyperXOrigins2_65Controller::~HyperXOrigins2_65Controller()
std::string HyperXOrigins2_65Controller::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXOrigins2_65Controller::GetNameString()

View File

@@ -37,7 +37,7 @@ HyperXMicrophoneController::~HyperXMicrophoneController()
std::string HyperXMicrophoneController::GetDeviceLocation()
{
return(location);
return("HID: " + location);
}
std::string HyperXMicrophoneController::GetNameString()

View File

@@ -37,7 +37,7 @@ HyperXMicrophoneV2Controller::~HyperXMicrophoneV2Controller()
std::string HyperXMicrophoneV2Controller::GetDeviceLocation()
{
return(location);
return("HID: " + location);
}
std::string HyperXMicrophoneV2Controller::GetNameString()

View File

@@ -27,7 +27,7 @@ HyperXPulsefireFPSProController::~HyperXPulsefireFPSProController()
std::string HyperXPulsefireFPSProController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXPulsefireFPSProController::GetNameString()

View File

@@ -27,7 +27,7 @@ HyperXPulsefireHasteController::~HyperXPulsefireHasteController()
std::string HyperXPulsefireHasteController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXPulsefireHasteController::GetNameString()

View File

@@ -27,7 +27,7 @@ HyperXPulsefireSurgeController::~HyperXPulsefireSurgeController()
std::string HyperXPulsefireSurgeController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXPulsefireSurgeController::GetNameString()

View File

@@ -28,7 +28,7 @@ HyperXMousematController::~HyperXMousematController()
std::string HyperXMousematController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string HyperXMousematController::GetNameString()

View File

@@ -54,7 +54,7 @@ unsigned int JGINYUEInternalUSBController::GetZoneCount()
std::string JGINYUEInternalUSBController::GetDeviceLocation()
{
return("HID:" + location);
return("HID: " + location);
}
std::string JGINYUEInternalUSBController::GetDeviceName()

View File

@@ -68,7 +68,7 @@ unsigned int JGINYUEInternalUSBV2Controller::GetZoneCount()
std::string JGINYUEInternalUSBV2Controller::GetDeviceLocation()
{
return("HID:" + location);
return("HID: " + location);
}
std::string JGINYUEInternalUSBV2Controller::GetDeviceName()

View File

@@ -210,7 +210,7 @@ DetectedControllers DetectLogitechKeyboardG810(hid_device_info* info, const std:
}
if(dev_usage_0x0602 && dev_usage_0x0604)
{
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604, name);
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604, info->path, name);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
detected_controllers.push_back(rgb_controller);
@@ -226,7 +226,7 @@ DetectedControllers DetectLogitechKeyboardG810(hid_device_info* info, const std:
if(dev)
{
LogitechG810Controller* controller = new LogitechG810Controller(dev, dev, name);
LogitechG810Controller* controller = new LogitechG810Controller(dev, dev, info->path, name);
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
detected_controllers.push_back(rgb_controller);
@@ -274,7 +274,7 @@ DetectedControllers DetectLogitechKeyboardG910(hid_device_info* info, const std:
}
if(dev_usage_0x0602 && dev_usage_0x0604)
{
LogitechG910Controller* controller = new LogitechG910Controller(dev_usage_0x0602, dev_usage_0x0604, name);
LogitechG910Controller* controller = new LogitechG910Controller(dev_usage_0x0602, dev_usage_0x0604, info->path, name);
RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller);
detected_controllers.push_back(rgb_controller);
@@ -290,7 +290,7 @@ DetectedControllers DetectLogitechKeyboardG910(hid_device_info* info, const std:
if(dev)
{
LogitechG910Controller* controller = new LogitechG910Controller(dev, dev, name);
LogitechG910Controller* controller = new LogitechG910Controller(dev, dev, info->path, name);
RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller);
detected_controllers.push_back(rgb_controller);

View File

@@ -13,10 +13,11 @@
#include "LogitechG810Controller.h"
#include "StringUtils.h"
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, std::string dev_name)
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, char* path, std::string dev_name)
{
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
location = path;
name = dev_name;
}
@@ -26,6 +27,11 @@ LogitechG810Controller::~LogitechG810Controller()
hid_close(dev_pkt_0x12);
}
std::string LogitechG810Controller::GetLocationString()
{
return("HID: " + location);
}
std::string LogitechG810Controller::GetNameString()
{
return(name);

View File

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

View File

@@ -187,6 +187,7 @@ RGBController_LogitechG810::RGBController_LogitechG810(LogitechG810Controller* c
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech Keyboard Device";
location = controller->GetLocationString();
serial = controller->GetSerialString();
mode 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, std::string dev_name)
LogitechG910Controller::LogitechG910Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, char* path, std::string dev_name)
{
dev_pkt_0x11 = dev_handle_0x11;
dev_pkt_0x12 = dev_handle_0x12;
location = path;
name = dev_name;
}
@@ -31,6 +32,11 @@ std::string LogitechG910Controller::GetNameString()
return(name);
}
std::string LogitechG910Controller::GetLocationString()
{
return("HID: " + location);
}
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, std::string dev_name);
LogitechG910Controller(hid_device* dev_handle_0x11, hid_device* dev_handle_0x12, char* path, std::string dev_name);
~LogitechG910Controller();
std::string GetLocationString();
std::string GetNameString();
std::string GetSerialString();
@@ -79,6 +80,7 @@ public:
private:
hid_device* dev_pkt_0x11;
hid_device* dev_pkt_0x12;
std::string location;
std::string name;
void SendDirectFrame

View File

@@ -188,6 +188,7 @@ RGBController_LogitechG910::RGBController_LogitechG910(LogitechG910Controller* c
vendor = "Logitech";
type = DEVICE_TYPE_KEYBOARD;
description = "Logitech Keyboard Device";
location = controller->GetLocationString();
serial = controller->GetSerialString();
mode Direct;

View File

@@ -28,7 +28,7 @@ PatriotViperMouseController::~PatriotViperMouseController()
std::string PatriotViperMouseController::GetLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string PatriotViperMouseController::GetName()

View File

@@ -226,7 +226,8 @@ std::string RealtekBridgeController::get_sn()
std::string RealtekBridgeController::get_dev_loc()
{
return hidinfo->path;
std::string location = hidinfo->path;
return("HID: " + location);
}
std::string RealtekBridgeController::get_fw_ver()

View File

@@ -26,12 +26,12 @@ WushiL50USBController::~WushiL50USBController()
std::string WushiL50USBController::getName()
{
return name;
return(name);
}
std::string WushiL50USBController::getLocation()
{
return location;
return("HID: " + location);
}
std::string WushiL50USBController::GetSerialString()

View File

@@ -43,7 +43,7 @@ ZETBladeOpticalController::~ZETBladeOpticalController()
std::string ZETBladeOpticalController::GetDeviceLocation()
{
return("HID " + location);
return("HID: " + location);
}
std::string ZETBladeOpticalController::GetNameString()