/// <summary> /// Checks for new Corsair USB devices. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CheckForDevice(object sender, ElapsedEventArgs e) { int newNumDevices = CueSDK.CorsairGetDeviceCount(); if (numDevices < newNumDevices) { CueSDK.Initialize(); NewCorsairDeviceConnected?.Invoke(this, new EventArgs()); } numDevices = newNumDevices; }
/// <summary> /// Attempts to initialize SDK. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InitializeSDK(object sender, ElapsedEventArgs e) { try { CueSDK.Initialize(); NewCorsairDeviceConnected?.Invoke(this, new EventArgs()); if (CueSDK.IsSDKAvailable(CorsairDeviceType.Keyboard)) { numDevices++; } if (CueSDK.IsSDKAvailable(CorsairDeviceType.Mouse)) { numDevices++; } if (CueSDK.IsSDKAvailable(CorsairDeviceType.Headset)) { numDevices++; } if (CueSDK.IsSDKAvailable(CorsairDeviceType.Mousemat)) { numDevices++; } initializationTimer.Enabled = false; initializationTimer.Elapsed -= InitializeSDK; initializationTimer.Elapsed += CheckForDevice; initializationTimer.Enabled = true; } catch (WrapperException ex) { Debug.WriteLine("Wrapper Exception! Message:" + ex.Message); } catch (CUEException ex) { Debug.WriteLine("CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error)); } }