public override bool OnKeypress(CorsairLedId ledId, bool pressed) { if (pressed) { IBrush Brush; switch (ledId) { case CorsairLedId.ScanNextTrack: case CorsairLedId.ScanPreviousTrack: Brush = new LinearGradientBrush(new LinearGradient(new GradientStop[] { Profile.GradStop(0x00FFFFFF, 0f), Profile.GradStop(0xFFFFFFFF, -0.5f), Profile.GradStop(0x00FFFFFF, -1.0f), })); Brush.AddEffect(new MoveLinearGradientEffect(2, ledId == CorsairLedId.ScanNextTrack)); MediaGroup2.Brush = Brush; return(true); case CorsairLedId.PlayPause: case CorsairLedId.Stop: Brush = new SolidColorBrush(ledId == CorsairLedId.PlayPause ? Color.Green : Color.Red); FlashEffect Effect = new FlashEffect() { Attack = 0, Sustain = 0.5f, Release = 0.5f, Repetitions = 1 }; Brush.AddEffect(Effect); (ledId == CorsairLedId.PlayPause ? MediaGroup : MediaGroup3).Brush = Brush; return(true); } } return(false); }
private void SendColorToMouse(CorsairLedId ledid, Color color, bool forced = false) { if (Global.Configuration.devices_disable_mouse) { return; } if (Global.Configuration.allow_peripheral_devices) { //Apply and strip Alpha color = Color.FromArgb(255, Utils.ColorUtils.MultiplyColorByScalar(color, color.A / 255.0D)); if (mouse != null) { if (mouse[ledid] != null) { mouse[ledid].Color = color; } mouse.Update(true); } peripheral_updated = true; } else { if (peripheral_updated) { peripheral_updated = false; } } }
/// <summary> /// Initializes a new instance of the <see cref="BrushRenderTarget" /> class. /// </summary> /// <param name="ledId">The ID of the target-LED.</param> /// <param name="rectangle">The rectangle representing the area to render the target-LED.</param> public BrushRenderTarget(CorsairLedId ledId, RectangleF rectangle) { Rectangle = rectangle; LedId = ledId; Point = rectangle.GetCenter(); }
protected override bool OnKeyPress(CorsairLedId ledId, bool pressed) { if (ledId == CorsairLedId.C || ledId == CorsairLedId.Space) { SolidColorBrush Brush = new SolidColorBrush(FromArgb(0xFFFF0000)); if (!pressed) { Brush.AddEffect(new FlashEffect() { Attack = 0, Sustain = 0, Release = 1, Repetitions = 1, }); } else { //Brush.AddEffect(new FlashEffect() //{ // Attack = 0.01f, // Sustain = 0.02f, // Release = 0.01f, // Repetitions = 0, // Interval = 0.02f, //}); } ShootingEffectGroup.Brush = Brush; } return(false); }
private void SendColorToMousepad(CorsairLedId zoneKey, Color color) { if (Global.Configuration.devices_disable_mouse) { return; } if (Global.Configuration.allow_peripheral_devices) { if (mousemat != null && !Global.Configuration.devices_disable_mouse) { if (mousemat[zoneKey] != null) { mousemat[zoneKey].Color = color; } mousemat.Update(true); } peripheral_updated = true; } else { if (peripheral_updated) { peripheral_updated = false; } } }
/// <summary> /// Initializes a new instance of the <see cref="BrushRenderTarget"/> class. /// </summary> /// <param name="ledId">The ID of the target-LED.</param> /// <param name="rectangle">The rectangle representing the area to render the target-LED.</param> public BrushRenderTarget(CorsairLedId ledId, RectangleF rectangle) { this.Rectangle = rectangle; this.LedId = ledId; Point = rectangle.GetCenter(); }
public CorsairLedColor(CorsairLedId ledId, int r, int g, int b) { this.ledId = ledId; this.r = r; this.g = g; this.b = b; }
/// <summary> /// Gets the <see cref="CorsairLed" /> with the specified ID. /// </summary> /// <param name="ledId">The ID of the LED to get.</param> /// <returns>The LED with the specified ID or null if no LED is found.</returns> public CorsairLed this[CorsairLedId ledId] { get { CorsairLed key; return LedMapping.TryGetValue(ledId, out key) ? key : null; } }
public static ListLedGroup GetSingleLedGroup(ICueDevice device, CorsairLedId ledId) { if (!SingleLedGroups.ContainsKey(ledId)) { SingleLedGroups.Add(ledId, new ListLedGroup(device, ledId)); } return(SingleLedGroups[ledId]); }
/// <summary> /// Gets the <see cref="CorsairLed" /> with the specified ID. /// </summary> /// <param name="ledId">The ID of the LED to get.</param> /// <returns>The LED with the specified ID or null if no LED is found.</returns> public CorsairLed this[CorsairLedId ledId] { get { CorsairLed key; return(LedMapping.TryGetValue(ledId, out key) ? key : null); } }
public bool UpdateDevice(Dictionary <DeviceKeys, Color> keyColors, DoWorkEventArgs e, bool forced = false) { if (e.Cancel) { return(false); } CorsairLedId keyindex = CorsairLedId.Invalid; try { if (e.Cancel) { return(false); } foreach (KeyValuePair <DeviceKeys, Color> key in keyColors) { if (e.Cancel) { return(false); } CorsairLedId localKey = ToCorsair(key.Key); if (localKey == CorsairLedId.Invalid && key.Key == DeviceKeys.Peripheral_Logo || localKey == CorsairLedId.Invalid && key.Key == DeviceKeys.Peripheral) { SendColorToMouse(CorsairLedId.B1, (Color)(key.Value)); SendColorToPeripheral((Color)(key.Value), forced); } else if (localKey == CorsairLedId.Invalid && key.Key == DeviceKeys.Peripheral_FrontLight) { SendColorToMouse(CorsairLedId.B2, (Color)(key.Value)); } else if (localKey == CorsairLedId.Invalid && key.Key == DeviceKeys.Peripheral_ScrollWheel) { SendColorToMouse(CorsairLedId.B3, (Color)(key.Value)); } else if (localKey != CorsairLedId.Invalid) { SetOneKey(localKey, (Color)(key.Value)); } keyindex = localKey; } if (e.Cancel) { return(false); } SendColorsToKeyboard(forced); return(true); } catch (Exception exc) { Global.logger.Error("Corsair device, error when updating device. Error: " + exc); Console.WriteLine(exc); return(false); } }
/// <summary> /// Creates a instance of CorsairLedColor /// </summary> public CorsairLedColor() { ledId = CorsairLedId.CLI_Invalid; r = 0; g = 0; b = 0; ApplyToNative(); }
internal InputBitMask(CorsairLedId ledId) { ContainingByte = ((int)ledId - 1) / 8; Bit = ((int)ledId - (ContainingByte * 8)) - 1; this.LedId = ledId; _mask = (byte)(1 << Bit); }
/// <summary> /// Creates a instance of CorsairLedPosition /// </summary> /// <param name="ledPositionNative">The native led position</param> internal CorsairLedPosition(CorsairLedPositionNative ledPositionNative) { native = ledPositionNative; ledId = native.ledId; top = native.top; left = native.left; height = native.height; width = native.width; }
private void SetOneKey(CorsairLedId localKey, Color color) { //Apply and strip Alpha color = Color.FromArgb(255, Utils.ColorUtils.MultiplyColorByScalar(color, color.A / 255.0D)); if (keyboard != null && keyboard[localKey] != null) { keyboard[localKey].Color = color; } }
/// <summary> /// Gets the <see cref="CorsairLed" /> representing the given character by calling the SDK-method 'CorsairGetLedIdForKeyName'.<br /> /// Note that this currently only works for letters. /// </summary> /// <param name="key">The character of the key.</param> /// <returns>The led representing the given character or null if no led is found.</returns> public CorsairLed this[char key] { get { CorsairLedId ledId = _CUESDK.CorsairGetLedIdForKeyName(key); CorsairLed led; return(LedMapping.TryGetValue(ledId, out led) ? led : null); } }
public void SetLed(CorsairLedId keyId, int r, int g, int b) { var key = Keyboard[keyId]; if (key == null) { return; } key.Color = Color.FromArgb(r, g, b); }
// Define your groups here public virtual void Init() { try { Keyboard = CueSDK.KeyboardSDK; if (Keyboard == null) { throw new WrapperException("No keyboard found"); } OnInput = (sender, args) => { CorsairLedId ledId = args.LedId; bool pressed = args.Action == InputAction.Pressed; //Console.WriteLine("Key pressed: {0}", ledId); if (ledId == CorsairLedId.RightCtrl) { CtrlDown = pressed; } else if (ledId == CorsairLedId.RightShift) { ShiftDown = pressed; } else if (ledId == CorsairLedId.RightAlt) { AltDown = pressed; } else if (CtrlDown && AltDown && ledId == CorsairLedId.ScrollLock && pressed) { Environment.Exit(0); } else if (CtrlDown && ShiftDown && ledId == CorsairLedId.ScrollLock && pressed) { fadeFromBlack(); } if (!OnKeyPress(ledId, pressed)) { foreach (KeyManager keyManager in KeyManagers) { if (keyManager.OnKeypress(ledId, pressed)) { return; } } } }; } catch (CUEException ex) { Debug.WriteLine("CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error)); } catch (WrapperException ex) { Debug.WriteLine("Wrapper Exception! Message:" + ex.Message); } }
private void UpdateSnakePositions(CorsairLedId newKey) { SnakePositions.Add(newKey); SnakeGame.Keyboard[newKey].Color = SnakeColor; SnakeGame.Keyboard.Update(); if (Food.FoodPositionKey == null) { Food.SpawnFood(); } }
public override void DoFrameAction() { foreach (Hotspot Hotspot in this.Hotspots) { Hotspot.SetCaptureRect(Hotspot.SettingHotspot.CaptureRect); Hotspot.SetCastableDetectionArea(Hotspot.SettingHotspot.CastableDetectionArea); Hotspot.SetCastableDetectionColors(Hotspot.SettingHotspot.CastableDetectionColors); Hotspot.BorderCut = Hotspot.SettingHotspot.BorderCut; Mat HotspotMat = new Mat(this.CaptureResult, Hotspot.CaptureRect); Hotspot.CaptureSource = HotspotMat; Hotspot.CreateFilteredMat(); Hotspot.DoBeforeFrameAction(); Hotspot.Tick(); Hotspot.DoFrameAction(); Hotspot.DoAfterFrameAction(); foreach (SettingLedChain LedChain in Hotspot.SettingHotspot.LedChains) { List <LedResults.Color> colors = Hotspot.getCurrentColors(LedChain.LedIdNames); int colorIndex = 0; foreach (string LedIdName in LedChain.LedIdNames) { CorsairLedId ledId = (CorsairLedId)Enum.Parse(typeof(CorsairLedId), LedIdName); int curColorIndex = colorIndex % LedChain.LedIdNames.Count; LedResults.Color CurColor = colors.ElementAt(curColorIndex); GetICueBridge().GetDevice(LedChain.DeviceType).SetLedColor(ledId, CurColor); colorIndex++; } } } GetICueBridge().Keyboard.sendToHardware(); GetICueBridge().LedStrip.sendToHardware(); this.DrawFPS(); /* * var ledResult = new LedResult(); * var indexer = mat.GetGenericIndexer<OpenCvSharp.Vec3b>(); * int getX = 60; * int getY = 50; * for (int i = 0; i < 4; i++) * { * OpenCvSharp.Vec3b color = indexer[getY, getX + i]; * ledResult.setSkill(i, new LedResults.Color(color.Item2, color.Item1, color.Item0)); * } * iCueBridge.SetResult(ledResult); * * mat.Rectangle(new OpenCvSharp.Point(getX - 1, getY - 1), new OpenCvSharp.Point(getX + 5, getY + 1), new OpenCvSharp.Scalar(164, 196, 215, 255)); */ }
public CorsairColor CorsairGetColorReference(CorsairLedId key) { Color color; if (_keyMap.TryGetValue(key, out color)) { return(color); } return(CorsairColor.Transparent); }
/// <summary> /// Creates a instance of CorsairLedColor /// </summary> /// <param name="ledColorNative">The native led color</param> internal CorsairLedColor(CorsairLedColorNative ledColorNative) { ledId = CorsairLedId.CLI_Invalid; r = 0; g = 0; b = 0; native = ledColorNative; ApplyToManaged(); }
public int b; // blue brightness[0..255]. public CorsairLedColor(CorsairLedId led, Color color) { ledId = led; /*r = rr; * g = gg; * b = bb; */ r = (int)(color.r * 100); g = (int)(color.g * 100); b = (int)(color.b * 100); }
/// <summary> /// Initializes the LED-Object with the specified id. /// </summary> /// <param name="ledId">The LED-Id to initialize.</param> /// <param name="ledRectangle">The rectangle representing the position of the LED to initialize.</param> /// <returns></returns> protected CorsairLed InitializeLed(CorsairLedId ledId, RectangleF ledRectangle) { if (LedMapping.ContainsKey(ledId)) { return(null); } CorsairLed led = new CorsairLed(this, ledId, ledRectangle); LedMapping.Add(ledId, led); return(led); }
/// <summary> /// Applies changes on the native instance to the object /// </summary> internal void ApplyToManaged() { if (native == null) { native = new CorsairLedColorNative(); } ledId = native.ledId; r = native.r; g = native.g; b = native.b; }
public CorsairLedId?GetNextKey(CorsairLedId originKey, Snake.Directions direction) { var rowAndKeyIndex = GetRowAndKeyIndex(originKey); var originRowIndex = rowAndKeyIndex[0]; var originKeyIndex = rowAndKeyIndex[1]; switch (direction) { case Snake.Directions.Up: return(GetKeyAtIndex( new int[] { originRowIndex - 1, originKeyIndex } )); case Snake.Directions.Left: return(GetKeyAtIndex( new int[] { originRowIndex, originKeyIndex - 1 } )); case Snake.Directions.Right: return(GetKeyAtIndex( new int[] { originRowIndex, originKeyIndex + 1 } )); case Snake.Directions.Down: return(GetKeyAtIndex( new int[] { originRowIndex + 1, originKeyIndex } )); default: return(null); } }
private void UpdateSnakePositions(CorsairLedId previousKey, CorsairLedId newKey) { if (Food.FoodPositionKey == newKey) { GrowSnake(); } else if (SnakePositions.Contains(newKey)) { SnakeGame.EndGame(); } else { SnakePositions.Remove(previousKey); SnakeGame.Keyboard[previousKey].Color = new CorsairColor(0, 0, 0); } UpdateSnakePositions(newKey); }
public override void Update(float deltaTime) { CorsairLedId[] activeLeds = _observedDevice.GetActiveInputs(); foreach (KeyValuePair <BrushRenderTarget, CorsairColor> renderTarget in Brush.RenderedTargets) { CorsairLedId ledId = renderTarget.Key.LedId; if (activeLeds.Contains(ledId)) { _alphaValues[ledId] = renderTarget.Value.GetFloatA(); } else { float alpha; if (_alphaValues.TryGetValue(ledId, out alpha)) { if (DecayTime <= 0) { alpha = 0; } else { alpha -= ((1f / DecayTime) * deltaTime); } if (alpha <= 0) { _alphaValues.Remove(ledId); } else { _alphaValues[ledId] = alpha; } } else { alpha = 0; } renderTarget.Value.A = ColorHelper.GetIntColorFromFloat(alpha); } } }
public int[] GetRowAndKeyIndex(CorsairLedId key) { var rowAndKeyIndex = new int[2]; for (var rowIndex = 0; rowIndex < _rowKeys.Count; rowIndex++) { for (var keyIndex = 0; keyIndex < _rowKeys[rowIndex].Count; keyIndex++) { if (_rowKeys[rowIndex][keyIndex] == key) { rowAndKeyIndex[0] = rowIndex; rowAndKeyIndex[1] = keyIndex; return(rowAndKeyIndex); } } } return(null); }
public override bool OnKeypress(CorsairLedId ledId, bool pressed) { Update(); switch (ledId) { case CorsairLedId.CapsLock: return(ManageCapsLock); case CorsairLedId.NumLock: return(ManageNumLock); case CorsairLedId.ScrollLock: return(ManageScrollLock); case CorsairLedId.VolumeDown: case CorsairLedId.VolumeUp: case CorsairLedId.Mute: return(ManageMuteKey); } return(false); }
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 override bool OnKeypress(CorsairLedId ledId, bool pressed) { if (AppliedKeys.Contains(CueSDK.KeyboardSDK[ledId])) { SolidColorBrush brush = new SolidColorBrush(FlashColor); if (!pressed) { brush.AddEffect(new FlashEffect() { Attack = this.Attack, Decay = this.Decay, Sustain = this.Sustain, Release = this.Release, AttackValue = this.AttackValue, SustainValue = this.SustainValue, Repetitions = 1 }); } Profile.GetSingleLedGroup(ledId).Brush = brush; } return(false); }
/// <summary> /// Initializes the LED-Object with the specified id. /// </summary> /// <param name="ledId">The LED-Id to initialize.</param> /// <param name="ledRectangle">The rectangle representing the position of the LED to initialize.</param> /// <returns></returns> protected CorsairLed InitializeLed(CorsairLedId ledId, RectangleF ledRectangle) { if (LedMapping.ContainsKey(ledId)) return null; CorsairLed led = new CorsairLed(ledId, ledRectangle); LedMapping.Add(ledId, led); return led; }
/// <summary> /// Checks if a given LED is contained by this ledgroup. /// </summary> /// <param name="ledId">The ID of 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(CorsairLedId ledId) { return ContainsLed(Device[ledId]); }
/// <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 ID of the first LED to calculate the rectangle of this ledgroup from.</param> /// <param name="toLed">They ID of the 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, CorsairLedId fromLed, CorsairLedId toLed, float minOverlayPercentage = 0.5f, bool autoAttach = true) : this(device, device[fromLed], device[toLed], minOverlayPercentage, autoAttach) { }
/// <summary> /// Initializes a new instance of the <see cref="CorsairLed"/> class. /// </summary> /// <param name="id">The ID of the LED</param> /// <param name="ledRectangle">The rectangle representing the physical location of the LED.</param> internal CorsairLed(CorsairLedId id, RectangleF ledRectangle) { this.Id = id; this.LedRectangle = ledRectangle; }
/// <summary> /// Initializes a new instance of the <see cref="LedUpateRequest"/> class. /// </summary> /// <param name="ledId">The id of the led to update.</param> /// <param name="color">The requested color of the led.</param> public LedUpateRequest(CorsairLedId ledId, CorsairColor color) { this.LedId = ledId; this.Color = color; }