private void SetupNetwork(string ip) { _localIp = ip; _sendToAddress = IPAddress.Parse(ip); _sendingEndPoint = new IPEndPoint(_sendToAddress, 56700); try { CueSDK.Initialize(); if (CueSDK.KeyboardSDK != null) { CueSDK.KeyboardSDK.Brush = (SolidColorBrush)System.Drawing.Color.Transparent; } if (CueSDK.MouseSDK != null) { CueSDK.MouseSDK.Brush = (SolidColorBrush)System.Drawing.Color.Transparent; } Mouse = CueSDK.MouseSDK; Keyboard = CueSDK.KeyboardSDK; if (Keyboard != null) { KeyboardLedDictionary = Keyboard.Leds.ToDictionary(x => x.Id.ToString(), x => x); } } catch (Exception e) { } auraSDK = new AuraSDK(); }
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 static void Setup() { mouse = CueSDK.MouseSDK; if (mouse == null) { IsMouseCompatible = false; return; } MagicWeaponBrush = new HitBrush(new CorsairColor(255, 0, 0, 255)); MeleeWeaponBrush = new HitBrush(new CorsairColor(255, 255, 0, 0)); mouse.Brush = (SolidColorBrush) new CorsairColor(255, 0, 0, 0); mouse.Update(); }
/// <inheritdoc /> public override void Initialize() { if (IsDisabled) { return; } Logger.Debug("Initializing CueSDK.MouseSDK..."); _mouse = CueSDK.MouseSDK; if (_mouse != null) { _mouse.Brush = (SolidColorBrush)Color.Transparent; Logger.Debug("Initialization of CueSDK.MouseSDK done"); } else { Logger.Warn("CueSDK.MouseSDK could not be registered, do you have a Cue supported mouse?"); Logger.Debug("--- SDK info ---"); Logger.Debug("Last SDK error: " + CueSDK.LastError); Logger.Debug("Devices: " + string.Join(",", CueSDK.InitializedDevices.Select(x => x.DeviceInfo.Type + "-" + x.DeviceInfo.Model))); } }
public bool Initialize() { try { CueSDK.Initialize(); Global.logger.LogLine("Corsair device, Initialized with " + CueSDK.LoadedArchitecture + "-SDK", Logging_Level.Info); keyboard = CueSDK.KeyboardSDK; mouse = CueSDK.MouseSDK; if (keyboard == null) { throw new WrapperException("No keyboard found"); } else { 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); }
// ReSharper disable once ExceptionNotThrown /// <summary> /// Initializes the CUE-SDK. This method should be called exactly ONE time, before anything else is done. /// </summary> /// <param name="exclusiveAccess">Specifies whether the application should request exclusive access or not.</param> /// <exception cref="WrapperException">Thrown if the SDK is already initialized, the SDK is not compatible to CUE or if CUE returns unknown devices.</exception> /// <exception cref="CUEException">Thrown if the CUE-SDK provides an error.</exception> public static void Initialize(bool exclusiveAccess = false) { if (IsInitialized) { throw new WrapperException("CueSDK is already initialized."); } _CUESDK.Reload(); ProtocolDetails = new CorsairProtocolDetails(_CUESDK.CorsairPerformProtocolHandshake()); CorsairError error = LastError; if (error != CorsairError.Success) { Throw(error, true); } if (ProtocolDetails.BreakingChanges) { throw new WrapperException("The SDK currently used isn't compatible with the installed version of CUE.\r\n" + $"CUE-Version: {ProtocolDetails.ServerVersion} (Protocol {ProtocolDetails.ServerProtocolVersion})\r\n" + $"SDK-Version: {ProtocolDetails.SdkVersion} (Protocol {ProtocolDetails.SdkProtocolVersion})"); } if (exclusiveAccess) { if (!_CUESDK.CorsairRequestControl(CorsairAccessMode.ExclusiveLightingControl)) { Throw(LastError, true); } HasExclusiveAccess = true; } IList <ICueDevice> devices = new List <ICueDevice>(); int deviceCount = _CUESDK.CorsairGetDeviceCount(); for (int i = 0; i < deviceCount; i++) { _CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo)); GenericDeviceInfo info = new GenericDeviceInfo(nativeDeviceInfo); if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting)) { continue; // Everything that doesn't support lighting control is useless } ICueDevice device; switch (info.Type) { case CorsairDeviceType.Keyboard: device = KeyboardSDK = new CorsairKeyboard(new CorsairKeyboardDeviceInfo(nativeDeviceInfo)); break; case CorsairDeviceType.Mouse: device = MouseSDK = new CorsairMouse(new CorsairMouseDeviceInfo(nativeDeviceInfo)); break; case CorsairDeviceType.Headset: device = HeadsetSDK = new CorsairHeadset(new CorsairHeadsetDeviceInfo(nativeDeviceInfo)); break; case CorsairDeviceType.Mousemat: device = MousematSDK = new CorsairMousemat(new CorsairMousematDeviceInfo(nativeDeviceInfo)); break; case CorsairDeviceType.HeadsetStand: device = HeadsetStandSDK = new CorsairHeadsetStand(new CorsairHeadsetStandDeviceInfo(nativeDeviceInfo)); break; // ReSharper disable once RedundantCaseLabel case CorsairDeviceType.Unknown: default: throw new WrapperException("Unknown Device-Type"); } device.Initialize(); devices.Add(device); error = LastError; if (error != CorsairError.Success) { Throw(error, true); } } error = LastError; if (error != CorsairError.Success) { Throw(error, false); } InitializedDevices = new ReadOnlyCollection <ICueDevice>(devices); IsInitialized = true; }
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); } }