コード例 #1
0
        /// <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));
            }
        }
コード例 #2
0
        /// <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();
            }
        }
コード例 #3
0
        /// <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]);
        }