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(); }
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(); }
static void UpdateMousepad(CorsairMousepadRGBDevice mousepad) { do { Color c1 = colors[0]; Color c2 = colors[3]; Color c3 = colors[1]; Color c4 = colors[2]; for (int i = 0; i < mousepad.Count(); i++) { if (i < 4) { mousepad.ElementAt(i).Color = c1; } else if (i < 7) { mousepad.ElementAt(i).Color = c2; } else if (7 < i && i < 11) { mousepad.ElementAt(i).Color = c3; } else if (10 < i && i < 15) { mousepad.ElementAt(i).Color = c4; } else { mousepad.ElementAt(i).Color = ColorUtils.colorMixer(c2, c3); } } System.Threading.Thread.Sleep(34); } while (running); }
static void UpdateMousepad(CorsairMousepadRGBDevice mousepad, Color c1, Color c2, Color c3, Color c4) { do { c1 = backIOColor; c2 = headerTwoColor; c3 = pchColor; c4 = headerOneColor; for (int i = 0; i < mousepad.Count(); i++) { if (i < 4) { mousepad.ElementAt(i).Color = c1; } else if (i < 7) { mousepad.ElementAt(i).Color = c2; } else if (7 < i && i < 11) { mousepad.ElementAt(i).Color = c3; } else if (10 < i && i < 15) { mousepad.ElementAt(i).Color = c4; } else { mousepad.ElementAt(i).Color = ColorUtils.colorMixer(c2, c3); } } System.Threading.Thread.Sleep(15); } while (running); }
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); }