/// <summary> /// Initializes the provider /// </summary> public void Initialize() { PerformHealthCheck(); Thread.Sleep(30000); for (var i = 0; i < CorsairLightingSDK.GetDeviceCount(); i++) { _devices.Add(new CorsairDevice(i)); } }
/// <summary> /// Performs a health check on the provider /// </summary> public void PerformHealthCheck() { var cueRunning = Process.GetProcessesByName("iCUE").Length != 0; while (!cueRunning) { Thread.Sleep(1000); cueRunning = Process.GetProcessesByName("iCUE").Length != 0; } CorsairLightingSDK.GetDeviceCount(); var error = CorsairLightingSDK.GetLastError(); while (error == CorsairError.ServerNotFound || error == CorsairError.ProtocolHandshakeMissing) { CorsairLightingSDK.PerformProtocolHandshake(); Thread.Sleep(1000); error = CorsairLightingSDK.GetLastError(); } }
/// <summary> /// Lists the devices. /// </summary> /// <returns></returns> public Device[] ListDevices() { int deviceCount = CorsairLightingSDK.GetDeviceCount(); if (deviceCount > 0) { Device[] devices = new Device[deviceCount]; for (int i = 0; i < deviceCount; i++) { CorsairDeviceInfo deviceInfo = CorsairLightingSDK.GetDeviceInfo(i); CorsairLedPositions positions = GetLedPositions(i); List <Led> leds = new List <Led>(); for (int j = 0; j < positions.LedPosition.Length; j++) { leds.Add(new Led(positions.LedPosition[j])); } devices[i] = new Device(deviceInfo, i, leds); RefreshDeviceColor(devices[i]); } return(devices); } return(new Device[0]); }