Beispiel #1
0
        static void UpdateKeyboard(CorsairKeyboardRGBDevice keyboard)
        {
            do
            {
                Color c1 = colors[0];
                Color c2 = colors[3];
                Color c3 = colors[1];
                Color c4 = colors[2];

                foreach (Led led in keyboard)
                {
                    if (led.LedRectangle.Location.X < 450 / 4)
                    {
                        led.Color = c1;
                    }
                    else if (led.LedRectangle.Location.X < (450 / 4) * 2)
                    {
                        led.Color = c2;
                    }
                    else if (led.LedRectangle.Location.X < (450 / 4) * 3)
                    {
                        led.Color = c3;
                    }
                    else
                    {
                        led.Color = c4;
                    }
                }

                System.Threading.Thread.Sleep(34);
            } while (running);
        }
Beispiel #2
0
        /// <summary>
        /// Initilize the keylighter
        /// </summary>
        public void Start()
        {
            //initilize the keyboard or return an exception if it fails.
            try
            {
                surface.Exception += args =>
                {
                    Console.WriteLine("RGB Wrapper Exception!");
                    Console.WriteLine("Message:" + args.Exception.Message);
                };
                surface.LoadDevices(CorsairDeviceProvider.Instance);

                Console.WriteLine("CUE Started");

                keyboard = surface.Devices.FirstOrDefault(x => x.DeviceInfo.Manufacturer.ToUpper() == "CORSAIR" && x.DeviceInfo.DeviceType == RGBDeviceType.Keyboard) as CorsairKeyboardRGBDevice;
                if (keyboard != null)
                {
                    keyboard.UpdateMode = DeviceUpdateMode.Sync;
                    //keyboard.UpdateFrequency = 1f/30f;
                    KeyGroups.SetupKeyGroups(keyboard);
                }
            }
            catch (CUEException ex)
            {
                Console.WriteLine("CUE Exception!");
                Console.WriteLine("ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error));
                keyboard = null;
            }
        }
Beispiel #3
0
        static void UpdateKeyboard(CorsairKeyboardRGBDevice keyboard, Color c1, Color c2, Color c3, Color c4)
        {
            do
            {
                c1 = backIOColor;
                c2 = headerTwoColor;
                c3 = pchColor;
                c4 = headerOneColor;

                foreach (Led led in keyboard)
                {
                    if (led.LedRectangle.Location.X < 450 / 4)
                    {
                        led.Color = c1;
                    }
                    else if (led.LedRectangle.Location.X < (450 / 4) * 2)
                    {
                        led.Color = c2;
                    }
                    else if (led.LedRectangle.Location.X < (450 / 4) * 3)
                    {
                        led.Color = c3;
                    }
                    else
                    {
                        led.Color = c4;
                    }
                }

                System.Threading.Thread.Sleep(15);
            } while (running);
        }
Beispiel #4
0
        static void InitializeDevices()
        {
            corsairLNP = new HidDeviceLoader().GetDevices().Where(d => d.ProductID == 0x0C0B).First();
            lnpStream  = corsairLNP.Open();
            LightingNodeUtils.FirstTransaction(lnpStream);

            surface            = RGBSurface.Instance;
            surface.Exception += args => Debug.WriteLine(args.Exception.Message);
            surface.UpdateMode = UpdateMode.Continuous;
            surface.LoadDevices(AsusDeviceProvider.Instance, RGBDeviceType.Mainboard);
            surface.LoadDevices(CorsairDeviceProvider.Instance);

            auraMb              = surface.Devices.OfType <AsusMainboardRGBDevice>().First();
            auraMb.UpdateMode   = DeviceUpdateMode.SyncBack;
            corsairKeyboard     = surface.Devices.OfType <CorsairKeyboardRGBDevice>().First();
            corsairMousepad     = surface.Devices.OfType <CorsairMousepadRGBDevice>().First();
            corsairHeadsetStand = surface.Devices.OfType <CorsairHeadsetStandRGBDevice>().First();

            IBridgeLocator locator                = new HttpBridgeLocator();
            var            locateBridges          = locator.LocateBridgesAsync(TimeSpan.FromSeconds(5));
            IEnumerable <LocatedBridge> bridgeIPs = locateBridges.Result;

            if (bridgeIPs.Where(B => B.BridgeId == "001788fffe678124").Count() > 0)
            {
                bridgeOne = new LocalHueClient(bridgeIPs.Where(B => B.BridgeId == "001788fffe678124").First().IpAddress);
                var registerOne = bridgeOne.RegisterAsync("LightingLink", "WarMachine");
                //string appKeyOne = registerOne.Result;
                bridgeOne.Initialize("NnmhRXVqLmBUw93kmIwi8PPCt6QHgWlHwkTYT9NC");
            }

            if (bridgeIPs.Where(B => B.BridgeId == "001788fffea04d9c").Count() > 0)
            {
                bridgeTwo = new LocalHueClient(bridgeIPs.Where(B => B.BridgeId == "001788fffea04d9c").First().IpAddress);
                var registerTwo = bridgeTwo.RegisterAsync("LightingLink", "WarMachine");
                //string appKeyTwo = registerTwo.Result;
                bridgeTwo.Initialize("2b0AIky9S2g1LgbggOgsCdNV8EzE2JS8QfBOCHHv");
            }

            GetAsusColors();
        }
Beispiel #5
0
        static void InitializeDevices()
        {
            exclusive = new OpenConfiguration();
            exclusive.SetOption(OpenOption.Exclusive, true);
            exclusive.SetOption(OpenOption.Interruptible, false);

            corsairLNP = DeviceList.Local.GetHidDevices().Where(d => d.ProductID == 0x0C0B).First();
            lnpStream  = corsairLNP.Open(exclusive);
            LightingNodeUtils.FirstTransaction(lnpStream);

            surface            = RGBSurface.Instance;
            surface.Exception += args => Debug.WriteLine(args.Exception.Message);
            surface.LoadDevices(AsusDeviceProvider.Instance, RGBDeviceType.Mainboard);
            surface.LoadDevices(CorsairDeviceProvider.Instance);

            auraMb              = surface.Devices.OfType <AsusMainboardRGBDevice>().First();
            auraMb.UpdateMode   = DeviceUpdateMode.SyncBack;
            corsairKeyboard     = surface.Devices.OfType <CorsairKeyboardRGBDevice>().First();
            corsairMousepad     = surface.Devices.OfType <CorsairMousepadRGBDevice>().First();
            corsairHeadsetStand = surface.Devices.OfType <CorsairHeadsetStandRGBDevice>().First();

            GetAsusColors();
        }
Beispiel #6
0
        private void PremadeSyncGroups()
        {
            AsusMainboardRGBDevice auraMB = RGBSurface.Instance.Devices.OfType <AsusMainboardRGBDevice>().First();

            CorsairKeyboardRGBDevice corsairKeyboard = RGBSurface.Instance.Devices.OfType <CorsairKeyboardRGBDevice>().First();
            double keyboardWidth = corsairKeyboard.Max(x => x.LedRectangle.Location.X);

            CorsairMousepadRGBDevice     corsairMousepad     = RGBSurface.Instance.Devices.OfType <CorsairMousepadRGBDevice>().First();
            CorsairHeadsetStandRGBDevice corsairHeadsetStand = RGBSurface.Instance.Devices.OfType <CorsairHeadsetStandRGBDevice>().First();

            List <CorsairCustomRGBDevice> corsairCustomDevices = RGBSurface.Instance.Devices.OfType <CorsairCustomRGBDevice>().ToList();
            CorsairCustomRGBDevice        stripOne             = corsairCustomDevices[0];
            CorsairCustomRGBDevice        stripTwo             = corsairCustomDevices[1];
            CorsairCustomRGBDevice        stripThree           = corsairCustomDevices[2];
            CorsairCustomRGBDevice        stripFour            = corsairCustomDevices[3];
            CorsairCustomRGBDevice        fanOne   = corsairCustomDevices[4];
            CorsairCustomRGBDevice        fanTwo   = corsairCustomDevices[5];
            CorsairCustomRGBDevice        fanThree = corsairCustomDevices[6];
            CorsairCustomRGBDevice        fanFour  = corsairCustomDevices[7];
            CorsairCustomRGBDevice        fanFive  = corsairCustomDevices[8];
            CorsairCustomRGBDevice        fanSix   = corsairCustomDevices[9];

            //CorsairCustomRGBDevice stripOne = surface.Devices.OfType<CorsairCustomRGBDevice>().

            //backIO = 0
            SyncLed    backIO        = new SyncLed(auraMB.ElementAt(0));
            List <Led> backIOTargets = new List <Led>();

            backIOTargets.AddRange(corsairKeyboard.Where(x => x.LedRectangle.Location.X <= keyboardWidth / 4).ToList());
            backIOTargets.AddRange(corsairMousepad.Take(4));
            backIOTargets.Add(corsairHeadsetStand.ElementAt(8));
            backIOTargets.AddRange(stripOne);
            backIOTargets.AddRange(fanOne);
            backIOTargets.AddRange(fanTwo);
            SyncGroup syncBackIO = new SyncGroup {
                SyncLed = backIO, Leds = new ObservableCollection <SyncLed>(backIOTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterSyncGroup(syncBackIO);

            //pch = 1
            SyncLed    pch        = new SyncLed(auraMB.ElementAt(1));
            List <Led> pchTargets = new List <Led>();

            pchTargets.AddRange(corsairKeyboard.Where(x => x.LedRectangle.Location.X > keyboardWidth / 4 && x.LedRectangle.Location.X <= keyboardWidth / 2).ToList());
            pchTargets.AddRange(corsairMousepad.Skip(4).Take(3));
            pchTargets.Add(corsairHeadsetStand.ElementAt(6));
            pchTargets.AddRange(stripThree);
            pchTargets.AddRange(fanFour);
            SyncGroup syncPch = new SyncGroup {
                SyncLed = pch, Leds = new ObservableCollection <SyncLed>(pchTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterSyncGroup(syncPch);


            //headerOne = 2
            SyncLed    headerOne        = new SyncLed(auraMB.ElementAt(2));
            List <Led> headerOneTargets = new List <Led>();

            headerOneTargets.AddRange(corsairKeyboard.Where(x => x.LedRectangle.Location.X > keyboardWidth / 2 && x.LedRectangle.Location.X <= keyboardWidth / 4 * 3).ToList());
            headerOneTargets.AddRange(corsairMousepad.Skip(8).Take(3));
            headerOneTargets.Add(corsairHeadsetStand.ElementAt(4));
            headerOneTargets.AddRange(stripTwo);
            headerOneTargets.AddRange(fanThree);
            SyncGroup syncHeaderOne = new SyncGroup {
                SyncLed = headerOne, Leds = new ObservableCollection <SyncLed>(headerOneTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterSyncGroup(syncHeaderOne);


            //headerTwo = 3
            SyncLed    headerTwo        = new SyncLed(auraMB.ElementAt(3));
            List <Led> headerTwoTargets = new List <Led>();

            headerTwoTargets.AddRange(corsairKeyboard.Where(x => x.LedRectangle.Location.X > keyboardWidth / 4 * 3).ToList());
            headerTwoTargets.AddRange(corsairMousepad.Skip(11).Take(4));
            headerTwoTargets.Add(corsairHeadsetStand.ElementAt(2));
            headerTwoTargets.AddRange(stripFour);
            headerTwoTargets.AddRange(fanFive);
            headerTwoTargets.AddRange(fanSix);
            SyncGroup syncHeaderTwo = new SyncGroup {
                SyncLed = headerTwo, Leds = new ObservableCollection <SyncLed>(headerTwoTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterSyncGroup(syncHeaderTwo);

            //average backIO and pch
            List <SyncLed> avgBackPch = new List <SyncLed>()
            {
                backIO, pch
            };
            List <Led> avgBackPchTargets = new List <Led>()
            {
                corsairHeadsetStand.ElementAt(7)
            };
            AverageSyncGroup syncAvgBackPch = new AverageSyncGroup {
                SyncLed = new ObservableCollection <SyncLed>(avgBackPch.ToList()), Leds = new ObservableCollection <SyncLed>(avgBackPchTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterAverageSyncGroup(syncAvgBackPch);

            //average backIO and headerTwo
            List <SyncLed> avgBackTwo = new List <SyncLed>()
            {
                backIO, headerTwo
            };
            List <Led> avgBackTwoTargets = new List <Led>()
            {
                corsairHeadsetStand.ElementAt(1)
            };
            AverageSyncGroup syncAvgBackTwo = new AverageSyncGroup {
                SyncLed = new ObservableCollection <SyncLed>(avgBackTwo.ToList()), Leds = new ObservableCollection <SyncLed>(avgBackTwoTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterAverageSyncGroup(syncAvgBackTwo);

            //average pch and headerOne
            List <SyncLed> avgPchOne = new List <SyncLed>()
            {
                pch, headerOne
            };
            List <Led> avgPchOneTargets = new List <Led>()
            {
                corsairHeadsetStand.ElementAt(5), corsairMousepad.ElementAt(7)
            };
            AverageSyncGroup syncAvgPchOne = new AverageSyncGroup {
                SyncLed = new ObservableCollection <SyncLed>(avgPchOne.ToList()), Leds = new ObservableCollection <SyncLed>(avgPchOneTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterAverageSyncGroup(syncAvgPchOne);

            //average headerOne and headerTwo
            List <SyncLed> avgOneTwo = new List <SyncLed>()
            {
                headerOne, headerTwo
            };
            List <Led> avgOneTwoTargets = new List <Led>()
            {
                corsairHeadsetStand.ElementAt(3)
            };
            AverageSyncGroup syncAvgOneTwo = new AverageSyncGroup {
                SyncLed = new ObservableCollection <SyncLed>(avgOneTwo.ToList()), Leds = new ObservableCollection <SyncLed>(avgOneTwoTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterAverageSyncGroup(syncAvgOneTwo);

            //average backIO and pch and headerOne and headerTwo
            List <SyncLed> avgAll = new List <SyncLed>()
            {
                backIO, pch, headerOne, headerTwo
            };
            List <Led> avgAllTargets = new List <Led>()
            {
                corsairHeadsetStand.ElementAt(0)
            };
            AverageSyncGroup syncAvgAll = new AverageSyncGroup {
                SyncLed = new ObservableCollection <SyncLed>(avgAll.ToList()), Leds = new ObservableCollection <SyncLed>(avgAllTargets.Select(x => new SyncLed(x)).ToList())
            };

            RegisterAverageSyncGroup(syncAvgAll);
        }
Beispiel #7
0
        /// <summary>
        /// Intial setup of keygroups using the keyboard provided.
        /// </summary>
        /// <param name="keyboard"></param>
        /// <param name="useNumpad"></param>
        public static void SetupKeyGroups(CorsairKeyboardRGBDevice keyboard)
        {
            try
            {
                WASD = new ListLedGroup(
                    keyboard[CorsairLedId.W],
                    keyboard[CorsairLedId.A],
                    keyboard[CorsairLedId.S],
                    keyboard[CorsairLedId.D]);

                healthFunction = new ListLedGroup(
                    keyboard[CorsairLedId.F1],
                    keyboard[CorsairLedId.F2],
                    keyboard[CorsairLedId.F3],
                    keyboard[CorsairLedId.F4],
                    keyboard[CorsairLedId.F5],
                    keyboard[CorsairLedId.F6]);
                armorFunction = new ListLedGroup(
                    keyboard[CorsairLedId.F7],
                    keyboard[CorsairLedId.F8],
                    keyboard[CorsairLedId.F9],
                    keyboard[CorsairLedId.F10],
                    keyboard[CorsairLedId.F11],
                    keyboard[CorsairLedId.F12]);

                numpad = new RectangleLedGroup(keyboard[CorsairLedId.NumLock], keyboard[CorsairLedId.KeypadEnter], 1.0f, true);

                numpadDigital = new List <ListLedGroup>();
                for (int i = 0; i < 10; ++i)
                {
                    numpadDigital.Add(null);
                }

                numpadDigital[1] = new ListLedGroup(
                    keyboard[CorsairLedId.NumLock],
                    keyboard[CorsairLedId.KeypadSlash],
                    keyboard[CorsairLedId.Keypad8],
                    keyboard[CorsairLedId.Keypad5],
                    keyboard[CorsairLedId.Keypad2],
                    keyboard[CorsairLedId.Keypad0],
                    keyboard[CorsairLedId.KeypadPeriodAndDelete]);

                var numpad2Keys = new Led[] {
                    keyboard[CorsairLedId.NumLock],
                    keyboard[CorsairLedId.KeypadSlash],
                    keyboard[CorsairLedId.KeypadAsterisk],
                    keyboard[CorsairLedId.Keypad9],
                    keyboard[CorsairLedId.Keypad6],
                    keyboard[CorsairLedId.Keypad5],
                    keyboard[CorsairLedId.Keypad4],
                    keyboard[CorsairLedId.Keypad1],
                    keyboard[CorsairLedId.Keypad0],
                    keyboard[CorsairLedId.KeypadPeriodAndDelete]
                };
                numpadDigital[2] = new ListLedGroup(numpad2Keys);

                numpadDigital[3] = new ListLedGroup(numpad2Keys);
                numpadDigital[3].AddLed(keyboard[CorsairLedId.Keypad3]);
                numpadDigital[3].RemoveLed(keyboard[CorsairLedId.Keypad1]);

                var numpad4Keys = new Led[] { keyboard[CorsairLedId.NumLock],
                                              keyboard[CorsairLedId.Keypad7],
                                              keyboard[CorsairLedId.Keypad4],
                                              keyboard[CorsairLedId.Keypad5],
                                              keyboard[CorsairLedId.Keypad6],
                                              keyboard[CorsairLedId.Keypad9],
                                              keyboard[CorsairLedId.KeypadAsterisk],
                                              keyboard[CorsairLedId.Keypad3],
                                              keyboard[CorsairLedId.KeypadPeriodAndDelete] };
                numpadDigital[4] = new ListLedGroup(numpad4Keys);

                numpadDigital[5] = new ListLedGroup(numpad2Keys);
                numpadDigital[5].AddLed(keyboard[CorsairLedId.Keypad7], keyboard[CorsairLedId.Keypad3]);
                numpadDigital[5].RemoveLed(keyboard[CorsairLedId.Keypad9], keyboard[CorsairLedId.Keypad1]);

                numpadDigital[6] = new ListLedGroup(numpad2Keys);
                numpadDigital[6].AddLed(keyboard[CorsairLedId.Keypad3], keyboard[CorsairLedId.Keypad7]);
                numpadDigital[6].RemoveLed(keyboard[CorsairLedId.Keypad9]);

                var numpad7Keys = new Led[] {
                    keyboard[CorsairLedId.Keypad7],
                    keyboard[CorsairLedId.NumLock],
                    keyboard[CorsairLedId.KeypadSlash],
                    keyboard[CorsairLedId.KeypadAsterisk],
                    keyboard[CorsairLedId.Keypad9],
                    keyboard[CorsairLedId.Keypad6],
                    keyboard[CorsairLedId.Keypad3],
                    keyboard[CorsairLedId.KeypadPeriodAndDelete]
                };
                numpadDigital[7] = new ListLedGroup(numpad7Keys);

                numpadDigital[8] = new ListLedGroup(numpad2Keys);
                numpadDigital[8].AddLed(
                    keyboard[CorsairLedId.Keypad7],
                    keyboard[CorsairLedId.Keypad3]);

                numpadDigital[9] = new ListLedGroup(numpad4Keys);
                numpadDigital[9].AddLed(keyboard[CorsairLedId.KeypadSlash]);

                numpadDigital[0] = new ListLedGroup(numpad7Keys);
                numpadDigital[0].AddLed(
                    keyboard[CorsairLedId.Keypad0],
                    keyboard[CorsairLedId.Keypad1],
                    keyboard[CorsairLedId.Keypad4]);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in creating key groups!");
                Console.WriteLine("Message: " + ex.Message);
            }
        }