コード例 #1
0
        private void RestoreLeds()
        {
            Global.logger.LogLine("Corsair starting restoring leds", Logging_Level.Info);

            if (keyboard != null)
            {
                foreach (var key in saved_keys)
                {
                    keyboard[key.Key].Led.Color = key.Value;
                }
                keyboard.Update();
            }

            if (mouse != null)
            {
                foreach (var key in saved_mouse)
                {
                    mouse[key.Key].Color = key.Value;
                }
                mouse.Update();
            }

            if (headset != null)
            {
                foreach (var key in saved_headset)
                {
                    headset[key.Key].Color = key.Value;
                }
                headset.Update();
            }

            Global.logger.LogLine("Corsair restored leds", Logging_Level.Info);
        }
コード例 #2
0
        public static void DealtDamage(bool isMagic, int damage, bool isCrit, int dmgMax)
        {
            HitBrush hitBrush;

            if (isMagic)
            {
                hitBrush = MagicWeaponBrush;
            }
            else
            {
                hitBrush = MeleeWeaponBrush;
            }

            hitBrush.Damage    = damage;
            hitBrush.IsCrit    = isCrit;
            hitBrush.DamageMax = dmgMax;

            mouse.Brush = hitBrush;
            mouse.Update();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        protected override void OnEffectTick(PatternRow playPattern)
        {
            if (_mouse == null)
            {
                return; //something probably went wrong during initialization, ignore this device effect playback
            }
            var maxWidth   = (int)Math.Round(_mouse.DeviceRectangle.Width);
            var maxHeight  = (int)Math.Round(_mouse.DeviceRectangle.Height);
            var columnSize = maxWidth / playPattern.TotalColumns;
            var startIndex = 0;

            for (var patternColumn = 0; patternColumn < playPattern.TotalColumns; patternColumn++)
            {
                var columnEndIndex = startIndex + columnSize;
                var rowEndIndex    = startIndex + columnSize;

                if (IsMismatchingLastEndIndex(playPattern, maxWidth, patternColumn, columnEndIndex))
                {
                    columnEndIndex = maxWidth;
                }
                if (IsMismatchingLastEndIndex(playPattern, maxHeight, patternColumn, columnEndIndex))
                {
                    rowEndIndex = maxHeight;
                }

                if (IsAnimateVerticallyEnabled)
                {
                    AnimateVertical(playPattern, startIndex, rowEndIndex, patternColumn);
                    startIndex = rowEndIndex;
                }
                else
                {
                    AnimateHorizontal(playPattern, startIndex, columnEndIndex, patternColumn);
                    startIndex = columnEndIndex;
                }
            }

            _mouse.Update();
        }
コード例 #5
0
        public void SendPayloadToMacAddress(IPayload Payload, string macAddress, string ipAddress)
        {
            switch (Payload.PayloadType)
            {
            case BulbType.Lifx:
                var targetMacAddress = Utils.StringToByteArray(macAddress + "0000");

                //Socket sendingSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                IPAddress  sendToAddress   = IPAddress.Parse(ipAddress);
                IPEndPoint sendingEndPoint = new IPEndPoint(sendToAddress, 56700);

                byte[] sendData = Utils.StringToByteArray(PacketFactory.GetPacket(targetMacAddress, Payload));

                var a = new UdpClient();
                a.Connect(sendingEndPoint);
                a.Send(sendData, sendData.Length);
                a.Close();
                break;

            case BulbType.CorsairMouse:
                if (Payload is SetColourPayload)
                {
                    var led = Mouse.Leds.FirstOrDefault(x => x.Id.ToString() == ipAddress);

                    System.Drawing.Color colour;

                    if (((SetColourPayload)Payload).RGBColour != null)
                    {
                        colour = ((SetColourPayload)Payload).RGBColour.Value;
                    }
                    else
                    {
                        colour = HsbToRgb(((SetColourPayload)Payload).Hue, ((SetColourPayload)Payload).Saturation / 65535f, ((SetColourPayload)Payload).Brightness / 65535f);
                    }

                    _cacheMouseLock.EnterReadLock();
                    try
                    {
                        led.Color = colour;
                    }
                    finally
                    {
                        _cacheMouseLock.ExitReadLock();
                    }

                    _cacheMouseLock.EnterWriteLock();
                    try
                    {
                        if ((DateTime.Now - lastCorsairUpdate).TotalMilliseconds > 20)
                        {
                            Mouse.Update();
                            lastCorsairUpdate = DateTime.Now;
                        }
                    }
                    finally
                    {
                        _cacheMouseLock.ExitWriteLock();
                    }
                }

                break;

            case BulbType.CorsairKeyboard:
                if (Payload is SetColourPayload)
                {
                    var led = KeyboardLedDictionary[ipAddress];

                    System.Drawing.Color colour;

                    if (((SetColourPayload)Payload).RGBColour != null)
                    {
                        colour = ((SetColourPayload)Payload).RGBColour.Value;
                    }
                    else
                    {
                        colour = HsbToRgb(((SetColourPayload)Payload).Hue, ((SetColourPayload)Payload).Saturation / 65535f, ((SetColourPayload)Payload).Brightness / 65535f);
                    }

                    _cacheLock.EnterReadLock();
                    try
                    {
                        led.Color = colour;
                    }
                    finally
                    {
                        _cacheLock.ExitReadLock();
                    }

                    _cacheLock.EnterWriteLock();
                    try
                    {
                        if ((DateTime.Now - lastCorsairKbdUpdate).TotalMilliseconds > 20)
                        {
                            Keyboard.Update();
                            lastCorsairKbdUpdate = DateTime.Now;
                        }
                    }
                    finally
                    {
                        _cacheLock.ExitWriteLock();
                    }
                }

                break;

            case BulbType.Asus:
                if (Payload is SetColourPayload)
                {
                    //if (!auraSDK.Motherboards.Any()) return;

                    if (disappointingAuraColourCache == null)
                    {
                        disappointingAuraColourCache = new AuraSDKDotNet.Color[auraSDK.Motherboards[0].LedCount];
                        for (var i = 0; i < disappointingAuraColourCache.Length; i++)
                        {
                            disappointingAuraColourCache[i] = new AuraSDKDotNet.Color(0, 0, 0);
                        }
                    }

                    var color = (((SetColourPayload)Payload).RGBColour != null)  ? ((SetColourPayload)Payload).RGBColour :
                                HsbToRgb(((SetColourPayload)Payload).Hue, ((SetColourPayload)Payload).Saturation / 65535f, ((SetColourPayload)Payload).Brightness / 65535f);

                    var c = new AuraSDKDotNet.Color(color.Value.R, color.Value.G, color.Value.B);
                    disappointingAuraColourCache[int.Parse(ipAddress)] = c;

                    if ((DateTime.Now - lastAuraUpdate).TotalMilliseconds > 200)
                    {
                        new Thread(() =>
                        {
                            auraSDK.Motherboards[0].SetColors(disappointingAuraColourCache);
                        }).Start();

                        //auraSDK.Motherboards[0].SetColors(disappointingAuraColourCache);
                        lastAuraUpdate = DateTime.Now;
                    }
                }

                break;
            }
        }
コード例 #6
0
        private void SendColorToPeripheral(Color color, bool forced = false)
        {
            if ((!previous_peripheral_Color.Equals(color) || forced))
            {
                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 && !Global.Configuration.devices_disable_mouse)
                    {
                        if (mouse[CorsairLedId.B1] != null)
                        {
                            mouse[CorsairLedId.B1].Color = color;
                        }
                        if (mouse[CorsairLedId.B2] != null)
                        {
                            mouse[CorsairLedId.B2].Color = color;
                        }
                        if (mouse[CorsairLedId.B3] != null)
                        {
                            mouse[CorsairLedId.B3].Color = color;
                        }
                        if (mouse[CorsairLedId.B4] != null)
                        {
                            mouse[CorsairLedId.B4].Color = color;
                        }

                        mouse.Update(true);
                    }

                    if (headset != null && !Global.Configuration.devices_disable_headset)
                    {
                        if (headset[CorsairLedId.LeftLogo] != null)
                        {
                            headset[CorsairLedId.LeftLogo].Color = color;
                        }
                        if (headset[CorsairLedId.RightLogo] != null)
                        {
                            headset[CorsairLedId.RightLogo].Color = color;
                        }

                        headset.Update(true);
                    }

                    if (mousemat != null && !Global.Configuration.devices_disable_mouse)
                    {
                        if (mousemat[CorsairLedId.Zone1] != null)
                        {
                            mousemat[CorsairLedId.Zone1].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone2] != null)
                        {
                            mousemat[CorsairLedId.Zone2].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone3] != null)
                        {
                            mousemat[CorsairLedId.Zone3].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone4] != null)
                        {
                            mousemat[CorsairLedId.Zone4].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone5] != null)
                        {
                            mousemat[CorsairLedId.Zone5].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone6] != null)
                        {
                            mousemat[CorsairLedId.Zone6].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone7] != null)
                        {
                            mousemat[CorsairLedId.Zone7].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone8] != null)
                        {
                            mousemat[CorsairLedId.Zone8].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone9] != null)
                        {
                            mousemat[CorsairLedId.Zone9].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone10] != null)
                        {
                            mousemat[CorsairLedId.Zone10].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone11] != null)
                        {
                            mousemat[CorsairLedId.Zone11].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone12] != null)
                        {
                            mousemat[CorsairLedId.Zone12].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone13] != null)
                        {
                            mousemat[CorsairLedId.Zone13].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone14] != null)
                        {
                            mousemat[CorsairLedId.Zone14].Color = color;
                        }
                        if (mousemat[CorsairLedId.Zone15] != null)
                        {
                            mousemat[CorsairLedId.Zone15].Color = color;
                        }

                        mousemat.Update(true);
                    }

                    previous_peripheral_Color = color;
                    peripheral_updated        = true;
                }
                else
                {
                    if (peripheral_updated)
                    {
                        peripheral_updated = false;
                    }
                }
            }
        }