Add pre detection hooks to resource manager. Closes #2184

This commit is contained in:
morg 2022-02-08 07:29:55 +01:00 committed by Adam Honse
parent 5ae6ef2c79
commit 5b4d55bb42
5 changed files with 39 additions and 3 deletions

View file

@ -37,6 +37,8 @@ typedef std::function<void(std::vector<RGBController*>&)> DeviceDetect
typedef std::function<void(std::vector<i2c_smbus_interface*>&)> I2CDeviceDetectorFunction;
typedef std::function<void(hid_device_info*, const std::string&)> HIDDeviceDetectorFunction;
typedef std::function<void()> DynamicDetectorFunction;
typedef std::function<void()> PreDetectionHookFunction;
typedef struct
{
std::string name;
@ -119,6 +121,7 @@ public:
int usage_page = HID_USAGE_PAGE_ANY,
int usage = HID_USAGE_ANY);
void RegisterDynamicDetector (std::string name, DynamicDetectorFunction detector);
void RegisterPreDetectionHook (PreDetectionHookFunction hook);
void RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg);
void RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void * new_callback_arg);
@ -149,6 +152,7 @@ public:
void SetConfigurationDirectory(std::string directory);
void ProcessPreDetectionHooks();
void ProcessDynamicDetectors();
void UpdateDeviceList();
void DeviceListChanged();
@ -224,6 +228,7 @@ private:
std::vector<std::string> hid_device_detector_strings;
std::vector<DynamicDetectorFunction> dynamic_detectors;
std::vector<std::string> dynamic_detector_strings;
std::vector<PreDetectionHookFunction> pre_detection_hooks;
bool dynamic_detectors_processed;