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 e1b84ba874
commit e8495115b5
33 changed files with 1401 additions and 212 deletions

View File

@@ -228,6 +228,28 @@ private:
std::vector<std::string> dynamic_detector_strings;
std::vector<PreDetectionHookFunction> pre_detection_hooks;
#ifdef __linux__
#ifdef __GLIBC__
/*-----------------------------------------------------*\
| Wrapped libusb hidapi handles |
\*-----------------------------------------------------*/
void * hidapi_libusb_handle;
hidapi_wrapper hidapi_libusb_wrapper;
#endif
#endif
/*-----------------------------------------------------*\
| HID Hotplug handles |
\*-----------------------------------------------------*/
#if(HID_HOTPLUG_ENABLED)
hid_hotplug_callback_handle hotplug_callback_handle;
#ifdef __linux__
#ifdef __GLIBC__
hid_hotplug_callback_handle libusb_hotplug_callback_handle;
#endif
#endif
#endif
/*-----------------------------------------------------*\
| Detection Callbacks |
\*-----------------------------------------------------*/
@@ -303,6 +325,26 @@ private:
void ProcessPreDetectionHooks();
void UpdateDetectorSettings();
#if(HID_HOTPLUG_ENABLED)
/*-----------------------------------------------------*\
| HID hotplug management functions |
\*-----------------------------------------------------*/
void StartHIDHotplug();
void StopHIDHotplug();
/*-----------------------------------------------------*\
| HID hotplug callback functions |
\*-----------------------------------------------------*/
static int HotplugCallbackFunction(hid_hotplug_callback_handle callback_handle, hid_device_info *device, hid_hotplug_event event, void *user_data);
static int UnplugCallbackFunction(hid_hotplug_callback_handle callback_handle, hid_device_info *device, hid_hotplug_event event, void *user_data);
#ifdef __linux__
#ifdef __GLIBC__
static int WrappedHotplugCallbackFunction(hid_hotplug_callback_handle callback_handle, hid_device_info *device, hid_hotplug_event event, void *user_data);
#endif
#endif
#endif
/*-----------------------------------------------------*\
| Function for signalling DetectionManager updates to |
| registered callbacks |