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); }
public static void ChangeHealth(int health, int healthMax) { HealthP = (float)Math.Ceiling((float)health / healthMax * 10) / 10f; int num_keys = (int)((HealthP + 0.00001f) * 10); HealthBrush.BarProgress = num_keys; HealthBrush.HealthP = (int)((float)health / healthMax * 100); HealthGroup.Brush = HealthBrush; keyboard.Update(); }
private void SendColorsToKeyboard(bool forced = false) { if (keyboard != null && !Global.Configuration.devices_disable_keyboard) { keyboard.Update(true); keyboard_updated = true; } }
protected void ShowStartScreen() { var backgroundColor = new CorsairColor(0, 0, 0); var textColor1 = new CorsairColor(255, 255, 0); var startKeyColor = new CorsairColor(0, 255, 0); var startKey = CorsairLedId.Space; SetColorToAllKeys(backgroundColor); // Color the start key to its color Keyboard[startKey].Color = startKeyColor; Keyboard[CorsairLedId.T].Color = startKeyColor; // Write out ssss... // -= S =- Keyboard[CorsairLedId.F2].Color = textColor1; Keyboard[CorsairLedId.F1].Color = textColor1; Keyboard[CorsairLedId.D1].Color = textColor1; Keyboard[CorsairLedId.Q].Color = textColor1; Keyboard[CorsairLedId.W].Color = textColor1; Keyboard[CorsairLedId.S].Color = textColor1; Keyboard[CorsairLedId.Z].Color = textColor1; Keyboard[CorsairLedId.NonUsBackslash].Color = textColor1; // TODO Complete writing out S's Keyboard.Update(); Console.WriteLine("Welcome to snake!"); Console.WriteLine("[T] - Test Keys"); Console.WriteLine("[Space] - Start Game"); var keyInfo = Console.ReadKey(true); Console.Clear(); if (keyInfo.Key == ConsoleKey.T) { KeyboardLayout.TestGameBoard(); } else if (keyInfo.Key == ConsoleKey.Spacebar) { StartGame(); } }
public void SetColor(char key, string name) { if (runWithoutKeyboard) { return; } switch (key) { case '1': keyboard[CorsairKeyboardLedId.D1].Color = Color.FromName(name); break; case '2': keyboard[CorsairKeyboardLedId.D2].Color = Color.FromName(name); break; case '3': keyboard[CorsairKeyboardLedId.D3].Color = Color.FromName(name); break; case '4': keyboard[CorsairKeyboardLedId.D4].Color = Color.FromName(name); break; case '5': keyboard[CorsairKeyboardLedId.D5].Color = Color.FromName(name); break; case '6': keyboard[CorsairKeyboardLedId.D6].Color = Color.FromName(name); break; case '7': keyboard[CorsairKeyboardLedId.D7].Color = Color.FromName(name); break; case '8': keyboard[CorsairKeyboardLedId.D8].Color = Color.FromName(name); break; case '9': keyboard[CorsairKeyboardLedId.D9].Color = Color.FromName(name); break; case '0': keyboard[CorsairKeyboardLedId.D0].Color = Color.FromName(name); break; default: keyboard[key].Color = Color.FromName(name); break; } keyboard.Update(); }
public static void Main(Model model) { try { CueSDK.Initialize(); System.Console.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK"); CorsairKeyboard keyboard = CueSDK.KeyboardSDK; if (keyboard == null) { throw new WrapperException("No keyboard found"); } keyboard.Brush = (SolidColorBrush)Color.Transparent; model.Translation(new PointF(10, 3)); //Flyt den ind i midten af tastaturet model.Translation(new PointF3D(0)); //Flyt modellen model.Scaler(4.0f); while (true) { model.RotateBy(new PointF3D((float)model.properties.rotateAmount, (float)model.properties.rotateAmount, (float)model.properties.rotateAmount)); Draw.LEDClear(keyboard); System.Console.Clear(); //System.Console.WriteLine("Model points"); //foreach (var point in model.GetPoints()) { // Matrix.Log(point); //} System.Console.WriteLine("Scaler"); Matrix.Log(model.GetScaler()); System.Console.WriteLine("Translator"); Matrix.Log(model.GetTranslater()); System.Console.WriteLine("Translator2D"); Matrix.Log(model.GetTranslater2D()); System.Console.WriteLine("Rotation"); Matrix.Log(model.GetRotation()); model.Draw(keyboard, Color.Red, Color.Green); keyboard.Update(); Thread.Sleep((int)(0.1 * 1000)); } } catch (CUEException ex) { System.Console.WriteLine("CUE Exception! ErrorCode: " + Enum.GetName(typeof(CorsairError), ex.Error)); } catch (WrapperException ex) { System.Console.WriteLine("Wrapper Exception! Message:" + ex.Message); } System.Console.Read(); }
public void SetColor(RgbColor color) { // Keyboard CueSDK.KeyboardSDK.Brush = (SolidColorBrush)color.GetColor(); foreach (var corsairLed in _keyboard.GetLeds()) { corsairLed.Color = color.GetColor(); } _keyboard.Update(); // TODO: Mouse, Mousepad, and headset }
private void toggleButton_Click(object sender, EventArgs e) { if (game.GetRunningState() == 0) { this.toggleButton.Text = "Disable"; this.pauseButton.Text = "Pause"; this.pauseButton.Enabled = true; //don't let me people change games while running radioLightsOut.Enabled = false; radioWhackAMole.Enabled = false; radioSimonSays.Enabled = false; CueSDK.Reinitialize(); keyboard.Brush = new SolidColorBrush(Color.DeepSkyBlue); keyboard.Update(); GameTask = Task.Factory.StartNew( () => { game.StartGame(); }); } else { // display the game and set the keyboard to previous state this.toggleButton.Text = "Enable"; this.pauseButton.Enabled = false; CueSDK.Reinitialize(); radioLightsOut.Enabled = true; radioWhackAMole.Enabled = true; radioSimonSays.Enabled = true; game.StopGame(); } Console.WriteLine("Playing set to: {0}", game.GetRunningState()); }
private void Refresh(object sender, EventArgs e) { /*switch (lightningMode) * { * case 0: * AverageColor(); * break; * case 1: * AmbientColor(); * break; * case 2: * BottomColor(); * break; * }*/ if (active) { AverageColor(); } else { keyboard.Brush = null; keyboard.Update(); } }
public Task SetColors(IEnumerable <RGB> colors, CancellationToken token) { return(Task.Run(() => { var i = 0; foreach (var color in colors) { ledPositions[i].Led.Color = new CorsairColor( (byte)color.R, (byte)color.G, (byte)color.B); i++; } keyboard.Update(); }, token)); }
public static void TeamLighting(int teamValue) { CorsairKeyboard keyboard = CueSDK.KeyboardSDK; if (teamValue == 0) { SolidColorBrush blueTeam = new SolidColorBrush(Color.Blue); blueTeam.Brightness = 0.4F; keyboard.Brush = blueTeam; } else { SolidColorBrush orangeTeam = new SolidColorBrush(Color.OrangeRed); orangeTeam.Brightness = 0.4F; keyboard.Brush = orangeTeam; } keyboard.Update(); }
public static void Setup() { keyboard = CueSDK.KeyboardSDK; if (keyboard == null) { IsKeyboardCompatible = false; return; } HealthLedIDs = new List <CorsairLedId>() { CorsairLedId.D0, CorsairLedId.D1, CorsairLedId.D2, CorsairLedId.D3, CorsairLedId.D4, CorsairLedId.D5, CorsairLedId.D6, CorsairLedId.D7, CorsairLedId.D8, CorsairLedId.D9, }; ManaLedIDs = new List <CorsairLedId>() { CorsairLedId.F1, CorsairLedId.F2, CorsairLedId.F3, CorsairLedId.F4, CorsairLedId.F5, CorsairLedId.F6, CorsairLedId.F7, CorsairLedId.F8, CorsairLedId.F9, CorsairLedId.F10, CorsairLedId.F11, CorsairLedId.F12, }; HealthGroup = new ListLedGroup(keyboard, HealthLedIDs); ManaGroup = new ListLedGroup(keyboard, ManaLedIDs); keyboard.Brush = (SolidColorBrush)CorsairColor.Transparent; keyboard.Update(); }
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; } }
static void Main() { CorsairKeyboardKeyId[] Health = { CorsairKeyboardKeyId.Escape, CorsairKeyboardKeyId.F1, CorsairKeyboardKeyId.F2, CorsairKeyboardKeyId.F3, CorsairKeyboardKeyId.F4, CorsairKeyboardKeyId.F5, CorsairKeyboardKeyId.F6, CorsairKeyboardKeyId.F7 }; CorsairKeyboardKeyId[] Mana = { CorsairKeyboardKeyId.F8, CorsairKeyboardKeyId.F9, CorsairKeyboardKeyId.F10, CorsairKeyboardKeyId.F11, CorsairKeyboardKeyId.F12, CorsairKeyboardKeyId.PrintScreen, CorsairKeyboardKeyId.ScrollLock, CorsairKeyboardKeyId.PauseBreak }; CueSDK.Initialize(); Debug.WriteLine("Initialized with " + CueSDK.LoadedArchitecture + "-SDK"); CorsairKeyboard keyboard = CueSDK.KeyboardSDK; if (keyboard == null) { throw new WrapperException("No keyboard found"); } Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = "C:\\Python34\\python.exe"; proc.StartInfo.Arguments = "-u \"C:\\Users\\Chris\\Documents\\Visual Studio 2015\\Projects\\dota_keyboard_prototype\\dota_keyboard_prototype\\dota_keyboard_prototype.py\""; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.UseShellExecute = false; proc.StartInfo.CreateNoWindow = false; proc.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal; proc.Start(); StreamReader q = proc.StandardOutput; while (!proc.HasExited) { String[] status = q.ReadLine().Split(null); Console.WriteLine(q.ReadLine()); if (status[0] == "BG") { continue; } int health_int = Int32.Parse(status[0]); int mana_int = Int32.Parse(status[1]); for (int i = 0; i < 8; i++) { if (i < health_int) { keyboard[Health[i]].Led.Color = Color.Green; } else { keyboard[Health[i]].Led.Color = Color.Red; } if (i < mana_int) { keyboard[Mana[i]].Led.Color = Color.Blue; } else { keyboard[Mana[i]].Led.Color = Color.White; } keyboard.Update(); } } }
public void Tick() { //set all keys to black ResetKeys(); try { //if our secondary thread hasn't paused this... if (!Pause) { //for each red heart container, set the light depending on if it's at full or half for (int i = 0; i < MaxRedHearts / 2; i++) { if (RedHearts - 1 > i * 2) { keyBoard[HealthKeys[i]].Led.Color = Color.Red; } else if (RedHearts == (i * 2) + 1) { keyBoard[HealthKeys[i]].Led.Color = Color.FromArgb(128, 0, 0); } } //for each slot other than max hearts, make sure there's no soul hearts or black hearts there for (int i = 0; i < 11 - (MaxRedHearts / 2); i++) { if (SoulHearts - 1 > i * 2) { keyBoard[HealthKeys[i + MaxRedHearts / 2]].Led.Color = BlackHearts[i] == '1' ? Color.Purple : Color.LightBlue; } else if (SoulHearts == (i * 2) + 1) { keyBoard[HealthKeys[i + MaxRedHearts / 2]].Led.Color = BlackHearts[i] == '1' ? Color.FromArgb(40, 0, 40) : Color.FromArgb(255, 86, 108, 115); } } //ezpz check that eternal heart and do the thing if (EternalHearts == 1) { keyBoard[HealthKeys[(MaxRedHearts / 2) - 1]].Led.Color = Color.White; } if (ENABLE_G_KEYS) { for (int i = 0; i < Math.Min(Keys, 6); i++) { keyBoard[KeyKeys[i]].Led.Color = Color.LightGray; } for (int i = 0; i < Math.Min(Bombs, 6); i++) { keyBoard[BombKeys[i]].Led.Color = Color.Purple; } for (int i = 0; i < Math.Min(Coins / 5, 6); i++) { keyBoard[CoinKeys[i]].Led.Color = Color.Yellow; } } } } catch (Exception e) { Debug.WriteLine("God damnit - " + e); ResetKeys(); } //finally, update the keyboard keyBoard.Update(); }
//Clear keyboard public static void LEDClear(CorsairKeyboard keyboard) { keyboard.RestoreColors(); keyboard.Update(); }
// Crazy long function to print a string private static void writeSentence(CorsairKeyboard keyboard, string message, Color color1, Color color2, int typingTime) { ListKeyGroup keyGroup1 = new ListKeyGroup(keyboard); List <MessageKey> activeKeys1 = new List <MessageKey>(); keyGroup1.Brush = new SolidColorBrush(color1); ListKeyGroup keyGroup2 = new ListKeyGroup(keyboard); List <MessageKey> activeKeys2 = new List <MessageKey>(); keyGroup2.Brush = new SolidColorBrush(color2); int messageIndex = 0; foreach (char c in message) { Char upperChar = Char.ToUpper(c); string c1 = modifyChar(upperChar); CorsairKey newKey = keyboard[GetKeyboardID(c1)]; // Change colors if repeating character // Check for space bar and characters. How to map charactes if (keyGroup1.ContainsKey(newKey)) { // Add this char to the secondary key group activeKeys2.Add(new MessageKey(c1, messageIndex)); keyGroup2.AddKey(newKey); // Remove Char from other keygroup list activeKeys1.RemoveAll(s => s.key == c1); keyGroup1.RemoveKey(newKey); } else { // Add this char to the primary key group activeKeys1.Add(new MessageKey(c1, messageIndex)); keyGroup1.AddKey(newKey); if (keyGroup2.ContainsKey(newKey)) { // Remove Key from other keygroup list activeKeys2.RemoveAll(s => s.key == c1); keyGroup2.RemoveKey(newKey); } } if (activeKeys1.Count > 0 && messageIndex - activeKeys1[0].index > 3) { // Remove this key! keyGroup1.RemoveKey(keyboard[GetKeyboardID(activeKeys1[0].key)]); activeKeys1.RemoveAt(0); } if (activeKeys2.Count > 0 && messageIndex - activeKeys2[0].index > 3) { // Remove this key! keyGroup2.RemoveKey(keyboard[GetKeyboardID(activeKeys2[0].key)]); activeKeys2.RemoveAt(0); } messageIndex++; keyboard.Update(); Wait(typingTime); } keyGroup1.Detach(); keyGroup2.Detach(); }
protected void UpdateKeyboard() { keyboard.Update(); }