public void Update() { if (UpdateRequired) { CorsairLedColor[] corsairLedColors = new CorsairLedColor[Leds.Length]; for (int i = 0; i < Leds.Length; i++) { corsairLedColors[i] = ((CueRgbLed)Leds[i]).RawLed; } CueSdkWrapper.SetLedsColorsAsync(corsairLedColors.Length, corsairLedColors); //CueSdkWrapper.SetLedsColors(corsairLedColors.Length, corsairLedColors); } }
/// <summary> /// Applies light changes to the device /// </summary> public void ApplyLights() { if (NumberOfLights > 0) { var buffer = new CorsairLedColor[_lights.Count]; for (var i = 0; i < _lights.Count; i++) { buffer[i] = _lights[i]._deviceLight; } CorsairLightingSDK.SetLedsColorsBufferByDeviceIndex(_deviceIndex, buffer); CorsairLightingSDK.SetLedsColorsFlushBuffer(); } }
public virtual void SetLedColor(CorsairLedId ledId, LedResults.Color color) { CorsairLedColor CorsairColor = new CorsairLedColor { ledId = (int)ledId, r = (int)color.R, g = (int)color.G, b = (int)color.B }; int existsIndex = this.Colors.FindIndex(ind => ind.ledId == CorsairColor.ledId); if (existsIndex == -1) { this.Colors.Add(CorsairColor); } else { this.Colors[existsIndex] = CorsairColor; } }
public void ApplyToKeyboard(ColorScheme colorScheme) { /* * //foreach (CorsairLedId key in Enum.GetValues(typeof(CorsairLedId))) * //{ * * //} * * // Absolute keys do not need to be converted to QWERTY, they are already specified in QWERTY. * foreach (var entry in colorScheme.AbsoluteKeys) * { * if (KeyMapping.ContainsKey(entry.Key)) * { * colorMap[KeyCodeToScanCode(entry.Key)] = entry.Value; * } * } * * // Mapped keys DO need to be converted to QWERTY before use. * foreach (var entry in colorScheme.MappedKeys) * { * * var qwertyKey = KeyShine.Instance.LayoutProvider.ConvertToQwertyCode(entry.Key); * * if (KeyMapping.ContainsKey(qwertyKey)) * { * colorMap[KeyCodeToScanCode(qwertyKey)] = entry.Value; * } * } * * ColorList.Add(key); */ //List<CorsairLedColor> ColorList = new List<CorsairLedColor>(); var colorMap = new Dictionary <CorsairLedId, Color32>(); try { foreach (CorsairLedId key in Enum.GetValues(typeof(CorsairLedId))) { //ColorList.Add(new CorsairLedColor(key, colorScheme.BaseColor)); colorMap.Add(key, colorScheme.BaseColor); } foreach (var key in colorScheme.AbsoluteKeys) { //ColorList.Add(new CorsairLedColor(KeyCodeToScanCode(key.Key), key.Value)); colorMap[KeyCodeToScanCode(key.Key)] = key.Value; } foreach (var key in colorScheme.MappedKeys) { var qwertyKey = KeyShine.Instance.LayoutProvider.ConvertToQwertyCode(key.Key); if (KeyMapping.ContainsKey(qwertyKey)) { //ColorList.Add(new CorsairLedColor(KeyCodeToScanCode(key.Key), key.Value)); colorMap[KeyCodeToScanCode(key.Key)] = key.Value; } } } catch (Exception e) { KeyShine.extPrint(e.Message); } CorsairLedColor[] ColorMapOut = new CorsairLedColor[157]; var ii = 0; foreach (CorsairLedId led in colorMap.Keys) { ColorMapOut[ii] = new CorsairLedColor(led, colorMap[led]); ii++; } CorsairSetLedsColors(ColorMapOut.Length, ColorMapOut); //CorsairSDK.CorsairSetLedsColors(); }
public static string ToString(this CorsairLedColor corsairLedColor) => $"{corsairLedColor.LedId}, ({corsairLedColor.R},{corsairLedColor.G},{corsairLedColor.B})";
static void Main(string[] args) { var dets = CUE.PerformProtocolHandshake(); if (CUE.RequestControl()) { int a = CUE.GetDeviceCount(); List <CorsairDeviceInfo> infos = new List <CorsairDeviceInfo>(); for (int i = 0; i < a; i++) { var info = CUE.GetDeviceInfo(i); Console.WriteLine(info.Model); infos.Add(info); } var colorbuffer = new CorsairLedColor[] { new CorsairLedColor() { LedId = CorsairLedId.K_W, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.K_A, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.K_S, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.K_D, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.M_1, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.M_2, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.M_3, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.M_4, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.M_5, R = 0, G = 0, B = 255 }, new CorsairLedColor() { LedId = CorsairLedId.M_6, R = 0, G = 0, B = 255 }, }; CUE.SetLedColors(colorbuffer); CUE.Update(); } Console.ReadLine(); CUE.ReleaseControl(); Console.ReadLine(); }