static void InitializeKeyboard(bool firstTime = false) { Led = null; try { if (firstTime) { CueSDK.Initialize(); } else { CueSDK.Reinitialize(); } Led = CueSDK.KeyboardSDK[KeyboardKey].Led; } catch { if (!firstTime) { try { InitializeKeyboard(true); } catch { // ignore } } } }
public override KeyMatch?GetKeyPosition(Keys keyCode) { var widthMultiplier = Width / _keyboard.Brush.RenderedRectangle.Width; var heightMultiplier = Height / _keyboard.Brush.RenderedRectangle.Height; CorsairLed cueLed = null; try { cueLed = _keyboard.Leds.FirstOrDefault(k => k.Id.ToString() == keyCode.ToString()) ?? _keyboard.Leds.FirstOrDefault(k => k.Id == CorsairUtilities.FormsKeys[keyCode]); Logger.Trace("Keycode: {0} resolved to CUE LED: {1}", keyCode, cueLed); } catch (Exception) { // ignored } if (cueLed == null) { return(null); } var center = cueLed.LedRectangle.GetCenter(); return(new KeyMatch(keyCode, (int)(center.X * widthMultiplier), (int)(center.Y * heightMultiplier))); }
public override KeyMatch?GetKeyPosition(Keys keyCode) { var widthMultiplier = Width / _keyboard.Brush.RenderedRectangle.Width; var heightMultiplier = Height / _keyboard.Brush.RenderedRectangle.Height; CorsairLed cueLed = null; try { cueLed = _keyboard.Leds.FirstOrDefault(k => k.Id.ToString() == keyCode.ToString()) ?? _keyboard.Leds.FirstOrDefault(k => k.Id == KeyMap.FormsKeys[keyCode]); } catch (Exception) { // ignored } if (cueLed != null) { return(new KeyMatch(keyCode, (int)(cueLed.LedRectangle.X * widthMultiplier), (int)(cueLed.LedRectangle.Y * heightMultiplier))); } return(null); }
/// <summary> /// Gets the color at an specific point assuming the brush is drawn into the given rectangle. /// </summary> /// <param name="rectangle">The rectangle in which the brush should be drawn.</param> /// <param name="renderTarget">The target (key/point) from which the color should be taken.</param> /// <returns>The color at the specified point.</returns> protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget) { CorsairLed led = CueSDK.KeyboardSDK[renderTarget.LedId]; if (led == null) { return(CorsairColor.Transparent); } CorsairColor color; return(!_colors.TryGetValue(led.Id, out color) ? CorsairColor.Transparent : color); }
/// <summary> /// Checks if a given LED is contained by this ledgroup. /// </summary> /// <param name="led">The LED which should be checked.</param> /// <returns><c>true</c> if the LED is contained by this ledgroup; otherwise, <c>false</c>.</returns> public bool ContainsLed(CorsairLed led) => led != null && GroupLeds.Contains(led);
public ListLedGroup GetSingleLedGroup(CorsairLed led) { return(AddGroupInternal(KeyboardController.GetSingleLedGroup(Keyboard, led))); }
/// <summary> /// Initializes a new instance of the <see cref="RectangleLedGroup"/> class. /// </summary> /// <param name="device">The device this ledgroup belongs to.</param> /// <param name="fromLed">They first LED to calculate the rectangle of this ledgroup from.</param> /// <param name="toLed">They second LED to calculate the rectangle of this ledgroup from.</param> /// <param name="minOverlayPercentage">(optional) The minimal percentage overlay a LED must have with the <see cref="Rectangle" /> to be taken into the ledgroup. (default: 0.5f)</param> /// <param name="autoAttach">(optional) Specifies whether this group should be automatically attached or not. (default: true)</param> public RectangleLedGroup(ICueDevice device, CorsairLed fromLed, CorsairLed toLed, float minOverlayPercentage = 0.5f, bool autoAttach = true) : this(device, RectangleHelper.CreateRectangleFromRectangles(fromLed.LedRectangle, toLed.LedRectangle), minOverlayPercentage, autoAttach) { }
public LedPosition(CorsairLed led, Position position) { Led = led; Position = position; }
/// <summary> /// Checks if a given LED is contained by this ledgroup. /// </summary> /// <param name="led">The LED which should be checked.</param> /// <returns><c>true</c> if the LED is contained by this ledgroup; otherwise, <c>false</c>.</returns> public bool ContainsLed(CorsairLed led) { return(led != null && GroupLeds.Contains(led)); }