mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-01-22 05:57:53 -05:00
Move HID detector calls to RunHIDDetector/RunHIDWrappedDetector functions and return controller list from detector functions
This commit is contained in:
@@ -43,15 +43,15 @@
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| Logitech vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define LOGITECH_VID 0x046D
|
||||
#define LOGITECH_LIGHTSPEED_DETECT_MAX_RETRY 10
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
#define LOGITECH_G213_PID 0xC336
|
||||
#define LOGITECH_G512_PID 0xC342
|
||||
#define LOGITECH_G512_RGB_PID 0xC33C
|
||||
@@ -70,9 +70,9 @@ using namespace std::chrono_literals;
|
||||
#define LOGITECH_G910_PID 0xC335
|
||||
#define LOGITECH_GPRO_KEYBOARD_1_PID 0xC339
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Mouse product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| Mouse product IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
#define LOGITECH_G203_PID 0xC084
|
||||
#define LOGITECH_G203_LIGHTSYNC_PID 0xC092
|
||||
#define LOGITECH_G203_LIGHTSYNC_PID_2 0xC09D
|
||||
@@ -94,19 +94,19 @@ using namespace std::chrono_literals;
|
||||
#define LOGITECH_G_PRO_HERO_PID 0xC08C
|
||||
#define LOGITECH_G_PRO_WIRELESS_PID 0xC088
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Mousemat product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| Mousemat product IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
#define LOGITECH_G_LIGHTSPEED_POWERPLAY_PID 0xC53A
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Speaker product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| Speaker product IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
#define LOGITECH_G560_PID 0x0A78
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Headset product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| Headset product IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
#define LOGITECH_G633_PID 0x0A5C
|
||||
#define LOGITECH_G635_PID 0x0A89
|
||||
#define LOGITECH_G733_PID 0x0AB5
|
||||
@@ -115,10 +115,10 @@ using namespace std::chrono_literals;
|
||||
#define LOGITECH_G933_PID 0x0A5B
|
||||
#define LOGITECH_G935_PID 0x0A87
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Unifying Device IDs (Including Lightspeed receivers) |
|
||||
| NB: Not used but preserved for debugging |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| Unifying Device IDs (Including Lightspeed receivers) |
|
||||
| NB: Not used but preserved for debugging |
|
||||
\*---------------------------------------------------------*/
|
||||
#define LOGITECH_G_UNIFYING_RECEIVER_1_PID 0xC52B
|
||||
#define LOGITECH_G_NANO_RECEIVER_PID 0xC52F
|
||||
#define LOGITECH_G_G700_RECEIVER_PID 0xC531
|
||||
@@ -136,35 +136,43 @@ using namespace std::chrono_literals;
|
||||
#define LOGITECH_G_PRO_WIRELESS_VIRTUAL_PID 0x4079
|
||||
#define LOGITECH_POWERPLAY_MAT_VIRTUAL_PID 0x405F
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Joystick product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
/*---------------------------------------------------------*\
|
||||
| Joystick product IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
#define LOGITECH_X56_VID 0x0738
|
||||
#define LOGITECH_X56_JOYSTICK_PID 0x2221
|
||||
#define LOGITECH_X56_THROTTLE_PID 0xA221
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech Keyboards |
|
||||
\*-----------------------------------------------------*/
|
||||
void DetectLogitechKeyboardG213(hid_device_info* info, const std::string& name)
|
||||
/*---------------------------------------------------------*\
|
||||
| Logitech Keyboards |
|
||||
\*---------------------------------------------------------*/
|
||||
DetectedControllers DetectLogitechKeyboardG213(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
LogitechG213Controller* controller = new LogitechG213Controller(dev, info->path, name);
|
||||
RGBController_LogitechG213* rgb_controller = new RGBController_LogitechG213(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
|
||||
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for |
|
||||
| 20-byte packets and one for 64-byte packets. Usage |
|
||||
| 0x0602 for 20 byte, usage 0x0604 for 64 byte, both |
|
||||
| are on usage page 0xFF43 |
|
||||
\*-----------------------------------------------------*/
|
||||
DetectedControllers detected_controllers;
|
||||
#ifdef USE_HID_USAGE
|
||||
hid_device* dev_usage_0x0602 = nullptr;
|
||||
hid_device* dev_usage_0x0604 = nullptr;
|
||||
@@ -197,7 +205,7 @@ void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name)
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604, name);
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -213,17 +221,22 @@ void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name)
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev, dev, name);
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
|
||||
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for |
|
||||
| 20-byte packets and one for 64-byte packets. Usage |
|
||||
| 0x0602 for 20 byte, usage 0x0604 for 64 byte, both |
|
||||
| are on usage page 0xFF43 |
|
||||
\*-----------------------------------------------------*/
|
||||
DetectedControllers detected_controllers;
|
||||
#ifdef USE_HID_USAGE
|
||||
hid_device* dev_usage_0x0602 = nullptr;
|
||||
hid_device* dev_usage_0x0604 = nullptr;
|
||||
@@ -256,7 +269,7 @@ void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name)
|
||||
LogitechG910Controller* controller = new LogitechG910Controller(dev_usage_0x0602, dev_usage_0x0604, name);
|
||||
RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -272,17 +285,22 @@ void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name)
|
||||
LogitechG910Controller* controller = new LogitechG910Controller(dev, dev, name);
|
||||
RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
|
||||
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for |
|
||||
| 20-byte packets and one for 64-byte packets. Usage |
|
||||
| 0x0602 for 20 byte, usage 0x0604 for 64 byte, both |
|
||||
| are on usage page 0xFF43 |
|
||||
\*-----------------------------------------------------*/
|
||||
DetectedControllers detected_controllers;
|
||||
#ifdef USE_HID_USAGE
|
||||
hid_device* dev_usage_0x0602 = nullptr;
|
||||
hid_device* dev_usage_0x0604 = nullptr;
|
||||
@@ -315,7 +333,7 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
|
||||
LogitechG815Controller* controller = new LogitechG815Controller(dev_usage_0x0602, dev_usage_0x0604, name);
|
||||
RGBController_LogitechG815* rgb_controller = new RGBController_LogitechG815(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -339,45 +357,60 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
|
||||
LogitechG815Controller* controller = new LogitechG815Controller(dev, dev, name);
|
||||
RGBController_LogitechG815* rgb_controller = new RGBController_LogitechG815(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechKeyboardG915(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechKeyboardG915(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
bool is_tkl = info->product_id == LOGITECH_G915TKL_RECEIVER_PID;
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
bool is_tkl = info->product_id == LOGITECH_G915TKL_RECEIVER_PID;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
LogitechG915Controller* controller = new LogitechG915Controller(dev, false, name);
|
||||
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller, is_tkl);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechKeyboardG915Wired(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechKeyboardG915Wired(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
bool is_tkl = info->product_id == LOGITECH_G915TKL_WIRED_PID;
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
bool is_tkl = info->product_id == LOGITECH_G915TKL_WIRED_PID;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
LogitechG915Controller* controller = new LogitechG915Controller(dev, true, name);
|
||||
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller, is_tkl);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
|
||||
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for |
|
||||
| 20-byte packets and one for 64-byte packets. Usage |
|
||||
| 0x0602 for 20 byte, usage 0x0604 for 64 byte, both |
|
||||
| are on usage page 0xFF43 |
|
||||
\*-----------------------------------------------------*/
|
||||
DetectedControllers detected_controllers;
|
||||
#ifdef USE_HID_USAGE
|
||||
hid_device* dev_usage_0x0602 = nullptr;
|
||||
hid_device* dev_usage_0x0604 = nullptr;
|
||||
@@ -410,7 +443,7 @@ void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name)
|
||||
LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev_usage_0x0602, dev_usage_0x0604, name);
|
||||
RGBController_LogitechGProKeyboard* rgb_controller = new RGBController_LogitechGProKeyboard(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -426,16 +459,19 @@ void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name)
|
||||
LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev, dev, name);
|
||||
RGBController_LogitechGProKeyboard* rgb_controller = new RGBController_LogitechGProKeyboard(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech Mice |
|
||||
\*-----------------------------------------------------*/
|
||||
static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::string& name, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id)
|
||||
/*---------------------------------------------------------*\
|
||||
| Logitech Mice |
|
||||
\*---------------------------------------------------------*/
|
||||
DetectedControllers addLogitechLightsyncMouse1zone(hid_device_info* info, const std::string& name, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id)
|
||||
{
|
||||
DetectedControllers detected_controllers;
|
||||
#ifdef USE_HID_USAGE
|
||||
{
|
||||
hid_device* dev_usage_1 = nullptr;
|
||||
@@ -469,7 +505,7 @@ static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::str
|
||||
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);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -488,14 +524,17 @@ static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::str
|
||||
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);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::string& name, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id)
|
||||
DetectedControllers addLogitechLightsyncMouse2zone(hid_device_info* info, const std::string& name, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id)
|
||||
{
|
||||
DetectedControllers detected_controllers;
|
||||
#ifdef USE_HID_USAGE
|
||||
{
|
||||
hid_device* dev_usage_1 = nullptr;
|
||||
@@ -529,7 +568,7 @@ static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::str
|
||||
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);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -547,107 +586,134 @@ static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::str
|
||||
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);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechMouseG203(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechMouseG203(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
addLogitechLightsyncMouse1zone(info, name, 0xFF, 0x0E, 0x3A);
|
||||
return(addLogitechLightsyncMouse1zone(info, name, 0xFF, 0x0E, 0x3A));
|
||||
}
|
||||
|
||||
void DetectLogitechMouseG203L(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechMouseG203L(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
LogitechG203LController* controller = new LogitechG203LController(dev, info->path, name);
|
||||
RGBController_LogitechG203L* rgb_controller = new RGBController_LogitechG203L(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechMouseG303(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechMouseG303(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x0E, 0x3A);
|
||||
return(addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x0E, 0x3A));
|
||||
}
|
||||
|
||||
void DetectLogitechMouseG403(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechMouseG403(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x0E, 0x3A);
|
||||
return(addLogitechLightsyncMouse2zone(info, name, 0xFF, 0x0E, 0x3A));
|
||||
}
|
||||
|
||||
void DetectLogitechMouseG600(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechMouseG600(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
LogitechG600Controller* controller = new LogitechG600Controller(dev, info->path, name);
|
||||
RGBController_LogitechG600* rgb_controller = new RGBController_LogitechG600(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechMouseGPRO(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechMouseGPRO(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
addLogitechLightsyncMouse1zone(info, name, 0xFF, 0x0E, 0x3C);
|
||||
return(addLogitechLightsyncMouse1zone(info, name, 0xFF, 0x0E, 0x3C));
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Other Logitech Devices |
|
||||
\*-----------------------------------------------------*/
|
||||
void DetectLogitechG560(hid_device_info* info, const std::string& name)
|
||||
/*---------------------------------------------------------*\
|
||||
| Other Logitech Devices |
|
||||
\*---------------------------------------------------------*/
|
||||
DetectedControllers DetectLogitechG560(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
/*---------------------------------------------*\
|
||||
| Add G560 Speaker |
|
||||
\*---------------------------------------------*/
|
||||
/*-------------------------------------------------*\
|
||||
| Add G560 Speaker |
|
||||
\*-------------------------------------------------*/
|
||||
LogitechG560Controller* controller = new LogitechG560Controller(dev, info->path, name);
|
||||
RGBController_LogitechG560* rgb_controller = new RGBController_LogitechG560(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechG933(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechG933(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
/*---------------------------------------------*\
|
||||
| Add G933 Headset |
|
||||
\*---------------------------------------------*/
|
||||
/*-------------------------------------------------*\
|
||||
| Add G933 Headset |
|
||||
\*-------------------------------------------------*/
|
||||
LogitechG933Controller* controller = new LogitechG933Controller(dev, info->path, name);
|
||||
RGBController_LogitechG933* rgb_controller = new RGBController_LogitechG933(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechX56(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectLogitechX56(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
/*---------------------------------------------*\
|
||||
| Add X56 Devices |
|
||||
\*---------------------------------------------*/
|
||||
/*-------------------------------------------------*\
|
||||
| Add X56 Devices |
|
||||
\*-------------------------------------------------*/
|
||||
LogitechX56Controller* controller = new LogitechX56Controller(dev, info->path, name);
|
||||
RGBController_LogitechX56* rgb_controller = new RGBController_LogitechX56(controller);
|
||||
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
@@ -708,13 +774,14 @@ REGISTER_HID_DETECTOR_IPU("Logitech X56 Rhino Hotas Throttle", Dete
|
||||
| |
|
||||
\*---------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void CreateLogitechLightspeedDevice(char *path, usages device_usages, uint8_t device_index, uint16_t pid, bool wireless, std::shared_ptr<std::mutex> mutex_ptr)
|
||||
DetectedControllers CreateLogitechLightspeedDevice(char *path, usages device_usages, uint8_t device_index, uint16_t pid, bool wireless, std::shared_ptr<std::mutex> mutex_ptr)
|
||||
{
|
||||
LogitechLightspeedController* controller = new LogitechLightspeedController(device_usages.find(2)->second, path);
|
||||
bool lightspeedDeviceIsValid = false;
|
||||
int retryCount = 0;
|
||||
DetectedControllers detected_controllers;
|
||||
LogitechLightspeedController* controller = new LogitechLightspeedController(device_usages.find(2)->second, path);
|
||||
bool lightspeedDeviceIsValid = false;
|
||||
int retryCount = 0;
|
||||
|
||||
while (!lightspeedDeviceIsValid && retryCount < LOGITECH_LIGHTSPEED_DETECT_MAX_RETRY)
|
||||
while(!lightspeedDeviceIsValid && retryCount < LOGITECH_LIGHTSPEED_DETECT_MAX_RETRY)
|
||||
{
|
||||
std::this_thread::sleep_for(50ms);
|
||||
controller->lightspeed = new logitech_device(path, device_usages, device_index, wireless, mutex_ptr);
|
||||
@@ -726,7 +793,9 @@ void CreateLogitechLightspeedDevice(char *path, usages device_usages, uint8_t de
|
||||
{
|
||||
RGBController_LogitechLightspeed* rgb_controller = new RGBController_LogitechLightspeed(controller);
|
||||
rgb_controller->pid = pid;
|
||||
DetectionManager::get()->RegisterRGBController(rgb_controller);
|
||||
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
|
||||
LOG_DEBUG("Added controller in %i retries", retryCount);
|
||||
}
|
||||
else
|
||||
@@ -734,18 +803,20 @@ void CreateLogitechLightspeedDevice(char *path, usages device_usages, uint8_t de
|
||||
delete controller;
|
||||
LOG_DEBUG("Failed to set up device - exceeded retries");
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
void DetectLogitechWired(hid_device_info* info, const std::string& /*name*/)
|
||||
DetectedControllers DetectLogitechWired(hid_device_info* info, const std::string& /*name*/)
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Wired lightspeed devices don't use the FAP short message |
|
||||
| Be sure to specify a Page AND Usage when using this detector |
|
||||
| i.e. REGISTER_HID_DETECTOR_IPU |
|
||||
\*-----------------------------------------------------------------*/
|
||||
//char *path = info->path;
|
||||
usages device_usages;
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
DetectedControllers detected_controllers;
|
||||
usages device_usages;
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
@@ -759,8 +830,10 @@ void DetectLogitechWired(hid_device_info* info, const std::string& /*name*/)
|
||||
|
||||
if(device_usages.size() > 0)
|
||||
{
|
||||
CreateLogitechLightspeedDevice(info->path, device_usages, LOGITECH_DEFAULT_DEVICE_INDEX, info->product_id, false, nullptr);
|
||||
detected_controllers = CreateLogitechLightspeedDevice(info->path, device_usages, LOGITECH_DEFAULT_DEVICE_INDEX, info->product_id, false, nullptr);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------------------------------------*\
|
||||
@@ -810,18 +883,19 @@ usages BundleLogitechUsages(hid_device_info* info)
|
||||
return temp_usages;
|
||||
}
|
||||
|
||||
void DetectLogitechLightspeedReceiver(hid_device_info* info, const std::string& /*name*/)
|
||||
DetectedControllers DetectLogitechLightspeedReceiver(hid_device_info* info, const std::string& /*name*/)
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Need to save the PID and the device path before iterating |
|
||||
| over "info" in BundleLogitechUsages() |
|
||||
\*-----------------------------------------------------------------*/
|
||||
char *path = info->path;
|
||||
uint16_t dev_pid = info->product_id;
|
||||
usages device_usages = BundleLogitechUsages(info);
|
||||
DetectedControllers detected_controllers;
|
||||
char *path = info->path;
|
||||
uint16_t dev_pid = info->product_id;
|
||||
usages device_usages = BundleLogitechUsages(info);
|
||||
|
||||
wireless_map wireless_devices;
|
||||
unsigned int device_count = getWirelessDevice(device_usages, dev_pid, &wireless_devices);
|
||||
wireless_map wireless_devices;
|
||||
unsigned int device_count = getWirelessDevice(device_usages, dev_pid, &wireless_devices);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Lightspeed Receivers will only have one paired /connected device |
|
||||
@@ -837,9 +911,11 @@ void DetectLogitechLightspeedReceiver(hid_device_info* info, const std::string&
|
||||
|
||||
for(wireless_map::iterator wd = wireless_devices.begin(); wd != wireless_devices.end(); wd++)
|
||||
{
|
||||
CreateLogitechLightspeedDevice(path, device_usages, wd->second, dev_pid, true, logitech_mutex);
|
||||
detected_controllers = CreateLogitechLightspeedDevice(path, device_usages, wd->second, dev_pid, true, logitech_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
@@ -857,16 +933,16 @@ REGISTER_HID_DETECTOR_IPU("Logitech G Powerplay Mousepad",
|
||||
\*---------------------------------------------------------------------------------------------------------*/
|
||||
#ifdef __linux__
|
||||
|
||||
void DetectLogitechWireless(hid_device_info* info, const std::string& /*name*/)
|
||||
DetectedControllers DetectLogitechWireless(hid_device_info* info, const std::string& /*name*/)
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Wireless lightspeed devices on Linux are handled by the Kernel |
|
||||
| and as such can largely be treated as Wired with the caveat |
|
||||
| that they may not be connected |
|
||||
\*-----------------------------------------------------------------*/
|
||||
//char *path = info->path;
|
||||
usages device_usages;
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
DetectedControllers detected_controllers;
|
||||
usages device_usages;
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
@@ -886,8 +962,10 @@ void DetectLogitechWireless(hid_device_info* info, const std::string& /*name*/)
|
||||
\*-------------------------------------------------*/
|
||||
std::shared_ptr<std::mutex> logitech_mutex = std::make_shared<std::mutex>();
|
||||
|
||||
CreateLogitechLightspeedDevice(info->path, device_usages, LOGITECH_DEFAULT_DEVICE_INDEX, info->product_id, true, logitech_mutex);
|
||||
detected_controllers = CreateLogitechLightspeedDevice(info->path, device_usages, LOGITECH_DEFAULT_DEVICE_INDEX, info->product_id, true, logitech_mutex);
|
||||
}
|
||||
|
||||
return(detected_controllers);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------------------------------------------------------*\
|
||||
|
||||
Reference in New Issue
Block a user