public bool Initialize() { if (!isInitialized) { try { CueSDK.Initialize(true); Global.logger.LogLine("Corsair device, Initialized with " + CueSDK.LoadedArchitecture + "-SDK", Logging_Level.Info); keyboard = CueSDK.KeyboardSDK; mouse = CueSDK.MouseSDK; headset = CueSDK.HeadsetSDK; if (keyboard == null && mouse == null && headset == null) { throw new WrapperException("No devices found"); } else { if (Global.Configuration.corsair_first_time) { CorsairInstallInstructions instructions = new CorsairInstallInstructions(); instructions.ShowDialog(); Global.Configuration.corsair_first_time = false; Settings.ConfigManager.Save(Global.Configuration); } SaveLeds(); isInitialized = true; return(true); } } catch (CUEException ex) { Global.logger.LogLine("Corsair device, CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error), Logging_Level.Error); } catch (WrapperException ex) { Global.logger.LogLine("Corsair device, Wrapper Exception! Message:" + ex.Message, Logging_Level.Error); } catch (Exception ex) { Global.logger.LogLine("Corsair device, Exception! Message:" + ex, Logging_Level.Error); } isInitialized = false; return(false); } return(isInitialized); }
public bool Initialize() { lock (action_lock) { if (!isInitialized) { try { if (wasInitializedOnce) { CueSDK.Reinitialize(true); } else { CueSDK.Initialize(true); } Global.logger.Info("Corsair device, Initialized with " + CueSDK.LoadedArchitecture + "-SDK"); keyboard = CueSDK.KeyboardSDK; mouse = CueSDK.MouseSDK; headset = CueSDK.HeadsetSDK; mousemat = CueSDK.MousematSDK; keyboard.Brush = (CUE.NET.Brushes.SolidColorBrush)Color.Transparent; mouse.Brush = (CUE.NET.Brushes.SolidColorBrush)Color.Transparent; headset.Brush = (CUE.NET.Brushes.SolidColorBrush)Color.Transparent; mousemat.Brush = (CUE.NET.Brushes.SolidColorBrush)Color.Transparent; if (keyboard == null && mouse == null && headset == null && mousemat == null) { throw new WrapperException("No devices found"); } else { if (Global.Configuration.corsair_first_time) { CorsairInstallInstructions instructions = new CorsairInstallInstructions(); instructions.ShowDialog(); Global.Configuration.corsair_first_time = false; Settings.ConfigManager.Save(Global.Configuration); } //SaveLeds(); isInitialized = true; wasInitializedOnce = true; return(true); } } catch (CUEException ex) { Global.logger.Error("Corsair device, CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error)); } catch (WrapperException ex) { Global.logger.Error("Corsair device, Wrapper Exception! Message: " + ex.Message); } catch (Exception ex) { Global.logger.Error("Corsair device, Exception! Message: " + ex); } isInitialized = false; return(false); } return(isInitialized); } }