Remove RGB controllers argument from standard detector

This commit is contained in:
Adam Honse 2023-01-26 20:19:45 -06:00
parent 060567548f
commit 92f0720639
30 changed files with 35 additions and 51 deletions

View file

@ -7,7 +7,7 @@
#include "wmi.h" #include "wmi.h"
#include <string> #include <string>
static void DetectAsusTUFLaptopWMIControllers(std::vector<RGBController*>&) static void DetectAsusTUFLaptopWMIControllers()
{ {
// Try to retrieve ProductID / Device name from WMI; Possibly can be rewritten to use wmi.cpp // Try to retrieve ProductID / Device name from WMI; Possibly can be rewritten to use wmi.cpp
// IF you encounter false detection ( e.g. if your laptop keyboard backlight uses USB interface // IF you encounter false detection ( e.g. if your laptop keyboard backlight uses USB interface

View file

@ -5,7 +5,7 @@
#include "Detector.h" #include "Detector.h"
#include <unistd.h> #include <unistd.h>
static void DetectAsusTUFLaptopLinuxControllers(std::vector<RGBController*>&) static void DetectAsusTUFLaptopLinuxControllers()
{ {
/*-------------------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------------------*\
| If /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/kbd_rgb_mode exists, | | If /sys/devices/platform/asus-nb-wmi/leds/asus::kbd_backlight/kbd_rgb_mode exists, |

View file

@ -19,7 +19,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectBlinkyTapeControllers(std::vector<RGBController*> &rgb_controllers) void DetectBlinkyTapeControllers()
{ {
std::vector<std::string *> device_locations = find_usb_serial_port(BLINKINLABS_VID, BLINKYTAPE_PID); std::vector<std::string *> device_locations = find_usb_serial_port(BLINKINLABS_VID, BLINKYTAPE_PID);

View file

@ -20,7 +20,7 @@
#define CORSAIR_VID 0x1B1C #define CORSAIR_VID 0x1B1C
#define H100I_V2_PID 0x0C09 #define H100I_V2_PID 0x0C09
void DetectCorsairHydro2Controllers(std::vector<RGBController*>& rgb_controllers) void DetectCorsairHydro2Controllers()
{ {
libusb_init(NULL); libusb_init(NULL);

View file

@ -49,7 +49,7 @@ static const corsair_hydro_device device_list[] =
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectCorsairHydroControllers(std::vector<RGBController*>& rgb_controllers) void DetectCorsairHydroControllers()
{ {
libusb_init(NULL); libusb_init(NULL);

View file

@ -201,7 +201,7 @@ static const char *led_names[] =
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers) void DetectDebugControllers()
{ {
json debug_settings; json debug_settings;

View file

@ -19,7 +19,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectDygmaRaiseControllers(std::vector<RGBController*> &rgb_controllers) void DetectDygmaRaiseControllers()
{ {
std::vector<std::string *> ports = find_usb_serial_port(DYGMA_RAISE_VID, DYGMA_RAISE_PID); std::vector<std::string *> ports = find_usb_serial_port(DYGMA_RAISE_VID, DYGMA_RAISE_PID);

View file

@ -20,7 +20,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers) void DetectE131Controllers()
{ {
json e131_settings; json e131_settings;

View file

@ -20,7 +20,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers) void DetectSpectrixS40GControllers()
{ {
/*---------------------------------------------------------------------*\ /*---------------------------------------------------------------------*\
| Search for /dev/nvmeX nodes with model matching "XPG SPECTRIX S40G" | | Search for /dev/nvmeX nodes with model matching "XPG SPECTRIX S40G" |

View file

@ -92,7 +92,7 @@ HANDLE OpenDevice(wchar_t buff[MAX_PATH])
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectSpectrixS40GControllers(std::vector<RGBController*>& rgb_controllers) void DetectSpectrixS40GControllers()
{ {
/*-------------------------------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------------------------------*\
| https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-scsi-devices | | https://docs.microsoft.com/en-us/windows-hardware/drivers/install/identifiers-for-scsi-devices |

View file

@ -15,7 +15,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectElgatoKeyLightControllers(std::vector<RGBController*> &rgb_controllers) void DetectElgatoKeyLightControllers()
{ {
json elgato_keylight_settings; json elgato_keylight_settings;

View file

@ -15,7 +15,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectEspurnaControllers(std::vector<RGBController*> &rgb_controllers) void DetectEspurnaControllers()
{ {
json espurna_settings; json espurna_settings;

View file

@ -2,7 +2,7 @@
#include "FanBusController.h" #include "FanBusController.h"
#include "RGBController_FanBus.h" #include "RGBController_FanBus.h"
void DetectFanBusControllers(std::vector<RGBController*> &rgb_controllers) void DetectFanBusControllers()
{ {
FanBusInterface* new_interface; FanBusInterface* new_interface;
json fanbus_settings; json fanbus_settings;

View file

@ -153,7 +153,7 @@ void RGBController_Faustus::DeviceUpdateMode()
DeviceUpdateLEDs(); DeviceUpdateLEDs();
} }
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers) void DetectFaustusControllers()
{ {
const char* base_path = "/sys/devices/platform/faustus/kbbl"; const char* base_path = "/sys/devices/platform/faustus/kbbl";
DIR* dir = opendir(base_path); DIR* dir = opendir(base_path);

View file

@ -28,7 +28,7 @@ static gig_device compatible_devices[] =
{"X570 UD"} {"X570 UD"}
}; };
void DetectGigabyteSuperIORGBControllers(std::vector<RGBController*> &rgb_controllers) void DetectGigabyteSuperIORGBControllers()
{ {
int sio_addrs[2] = {0x2E, 0x4E}; int sio_addrs[2] = {0x2E, 0x4E};

View file

@ -15,7 +15,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers) void DetectLEDStripControllers()
{ {
json ledstrip_settings; json ledstrip_settings;
LEDStripDevice dev; LEDStripDevice dev;

View file

@ -15,7 +15,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectLIFXControllers(std::vector<RGBController*> &rgb_controllers) void DetectLIFXControllers()
{ {
json lifx_settings; json lifx_settings;

View file

@ -56,7 +56,7 @@
| requires libusb as hidapi provides no wIndex customization. | | requires libusb as hidapi provides no wIndex customization. |
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
void DetectLianLiUniHub(std::vector<RGBController*>&) void DetectLianLiUniHub()
{ {
libusb_device** devices = nullptr; libusb_device** devices = nullptr;
@ -102,7 +102,7 @@ void DetectLianLiUniHub(std::vector<RGBController*>&)
} }
} }
void DetectLianLiUniHub_AL10(std::vector<RGBController*>&) void DetectLianLiUniHub_AL10()
{ {
libusb_device** devices = nullptr; libusb_device** devices = nullptr;

View file

@ -18,7 +18,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectLinuxLEDControllers(std::vector<RGBController*> &rgb_controllers) void DetectLinuxLEDControllers()
{ {
json linux_led_settings; json linux_led_settings;

View file

@ -77,7 +77,7 @@ static msi_device compatible_devices[] =
{"7B87", true }, {"7B87", true },
}; };
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers) void DetectMSIRGBControllers()
{ {
int sio_addrs[2] = {0x2E, 0x4E}; int sio_addrs[2] = {0x2E, 0x4E};

View file

@ -61,7 +61,7 @@ static const gpu_pci_device device_list[] =
{NVIDIA_VEN, NVIDIA_RTX4090_DEV, NVIDIA_VEN, NVIDIA_RTX4090_FE_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA 4090 FE" }, {NVIDIA_VEN, NVIDIA_RTX4090_DEV, NVIDIA_VEN, NVIDIA_RTX4090_FE_SUB_DEV, NVIDIA_ILLUMINATION_V1, TREATS_RGBW_AS_RGBW, "NVIDIA 4090 FE" },
}; };
void DetectNVIDIAIllumGPUs(std::vector<RGBController*> &rgb_controllers) void DetectNVIDIAIllumGPUs()
{ {
static NV_PHYSICAL_GPU_HANDLE gpu_handles[64]; static NV_PHYSICAL_GPU_HANDLE gpu_handles[64];
static NV_S32 gpu_count = 0; static NV_S32 gpu_count = 0;

View file

@ -16,7 +16,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectNZXTHuePlusControllers(std::vector<RGBController*> &/*rgb_controllers*/) void DetectNZXTHuePlusControllers()
{ {
std::vector<std::string *> ports = find_usb_serial_port(NZXT_HUE_PLUS_VID, NZXT_HUE_PLUS_PID); std::vector<std::string *> ports = find_usb_serial_port(NZXT_HUE_PLUS_VID, NZXT_HUE_PLUS_PID);

View file

@ -11,7 +11,7 @@
| | | |
\*----------------------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------------------*/
void DetectNanoleafControllers(std::vector<RGBController*> &rgb_controllers) void DetectNanoleafControllers()
{ {
json nanoleaf_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("NanoleafDevices"); json nanoleaf_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("NanoleafDevices");

View file

@ -19,7 +19,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers) void DetectOpenRazerControllers()
{ {
char driver_path[512]; char driver_path[512];
DIR *dir; DIR *dir;

View file

@ -110,7 +110,7 @@ static void load_device_fn(device_fn_type* device_fn, device* dev)
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers) void DetectOpenRazerControllers()
{ {
static HMODULE module = LoadLibrary(OPENRAZERDLL); static HMODULE module = LoadLibrary(OPENRAZERDLL);

View file

@ -23,7 +23,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers) void DetectPhilipsHueControllers()
{ {
json hue_settings; json hue_settings;
@ -210,11 +210,11 @@ void DetectPhilipsHueControllers(std::vector<RGBController*>& rgb_controllers)
\*-------------------------------------------------*/ \*-------------------------------------------------*/
if(auto_connect) if(auto_connect)
{ {
for(unsigned int controller_idx = 0; controller_idx < rgb_controllers.size(); controller_idx++) for(unsigned int controller_idx = 0; controller_idx < ResourceManager::get()->GetRGBControllers().size(); controller_idx++)
{ {
if(rgb_controllers[controller_idx]->description == "Philips Hue Entertainment Mode Device") if(ResourceManager::get()->GetRGBControllers()[controller_idx]->description == "Philips Hue Entertainment Mode Device")
{ {
rgb_controllers[controller_idx]->SetMode(0); ResourceManager::get()->GetRGBControllers()[controller_idx]->SetMode(0);
break; break;
} }
} }

View file

@ -15,7 +15,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectPhilipsWizControllers(std::vector<RGBController*> &rgb_controllers) void DetectPhilipsWizControllers()
{ {
json wiz_settings; json wiz_settings;

View file

@ -15,7 +15,7 @@
* * * *
\******************************************************************************************/ \******************************************************************************************/
void DetectYeelightControllers(std::vector<RGBController*> &rgb_controllers) void DetectYeelightControllers()
{ {
json yeelight_settings; json yeelight_settings;

View file

@ -1461,26 +1461,10 @@ void ResourceManager::DetectDevicesThreadFunction()
{ {
DetectionProgressChanged(); DetectionProgressChanged();
device_detectors[detector_idx](rgb_controllers_hw); device_detectors[detector_idx]();
} }
/*-------------------------------------------------*\ if(rgb_controllers_hw.size() == detection_prev_size)
| If the device list size has changed, call the |
| device list changed callbacks |
\*-------------------------------------------------*/
if(rgb_controllers_hw.size() != detection_prev_size)
{
/*-------------------------------------------------*\
| First, load sizes for the new controllers |
\*-------------------------------------------------*/
for(unsigned int controller_size_idx = detection_prev_size; controller_size_idx < rgb_controllers_hw.size(); controller_size_idx++)
{
profile_manager->LoadDeviceFromListWithOptions(rgb_controllers_sizes, detection_size_entry_used, rgb_controllers_hw[controller_size_idx], true, false);
}
UpdateDeviceList();
}
else
{ {
LOG_DEBUG("[%s] no devices found", detection_string); LOG_DEBUG("[%s] no devices found", detection_string);
} }

View file

@ -35,7 +35,7 @@
struct hid_device_info; struct hid_device_info;
typedef std::function<bool()> I2CBusDetectorFunction; typedef std::function<bool()> I2CBusDetectorFunction;
typedef std::function<void(std::vector<RGBController*>&)> DeviceDetectorFunction; typedef std::function<void()> DeviceDetectorFunction;
typedef std::function<void(std::vector<i2c_smbus_interface*>&)> I2CDeviceDetectorFunction; typedef std::function<void(std::vector<i2c_smbus_interface*>&)> I2CDeviceDetectorFunction;
typedef std::function<void(i2c_smbus_interface*, uint8_t, const std::string&)> I2CPCIDeviceDetectorFunction; typedef std::function<void(i2c_smbus_interface*, uint8_t, const std::string&)> I2CPCIDeviceDetectorFunction;
typedef std::function<void(hid_device_info*, const std::string&)> HIDDeviceDetectorFunction; typedef std::function<void(hid_device_info*, const std::string&)> HIDDeviceDetectorFunction;