public static void paint_ammo(int weapon, int currentAmmo, int maxAmmo, dynamic data) { CorsairKeyboardKeyId Key1 = Program.keys[0]; CorsairKeyboardKeyId Key2 = Program.keys[1]; CorsairKeyboardKeyId Key3 = Program.keys[2]; CorsairKeyboardKeyId Key4 = Program.keys[3]; CorsairKeyboardKeyId Key5 = Program.keys[4]; CorsairKeyboardKeyId Key6 = Program.keys[5]; CorsairKeyboardKeyId Key7 = Program.keys[6]; CorsairKeyboardKeyId[] FKeys = { CorsairKeyboardKeyId.F1, CorsairKeyboardKeyId.F2, CorsairKeyboardKeyId.F3, CorsairKeyboardKeyId.F4, CorsairKeyboardKeyId.F5, CorsairKeyboardKeyId.F6, CorsairKeyboardKeyId.F7, CorsairKeyboardKeyId.F8, CorsairKeyboardKeyId.F9, CorsairKeyboardKeyId.F10, CorsairKeyboardKeyId.F11, CorsairKeyboardKeyId.F12 }; CorsairKeyboardKeyId[] gamingkeys = { CorsairKeyboardKeyId.W, CorsairKeyboardKeyId.A, CorsairKeyboardKeyId.S, CorsairKeyboardKeyId.D, CorsairKeyboardKeyId.Escape }; CorsairKeyboardAPI.setKeyColors(team, gamingkeys); try{ float health = data.player.state.health; health = health.remap(0, 100, 0, 120); CorsairKeyboardAPI.setKeyColors(Program.ColorFromHSV(health, 1, 1), FKeys); }catch (Exception) {} switch (weapon) { case -1: CorsairKeyboardAPI.setKeyColor(Color.Black, Key1); CorsairKeyboardAPI.setKeyColor(Color.Black, Key2); CorsairKeyboardAPI.setKeyColor(Color.Black, Key3); CorsairKeyboardAPI.setKeyColor(Color.Black, Key4); CorsairKeyboardAPI.setKeyColor(Color.Black, Key5); CorsairKeyboardAPI.setKeyColor(Color.Black, Key6); CorsairKeyboardAPI.setKeyColor(Color.Black, Key7); break; case 0: if ((currentAmmo == -1 && maxAmmo == -1) || (currentAmmo == 1 && maxAmmo == 1)) { CorsairKeyboardAPI.setKeyColor(Color.White, Key1); } else { float magasin = currentAmmo; magasin = magasin.remap(0, maxAmmo, 120, 0); CorsairKeyboardAPI.setKeyColor(Program.ColorFromHSV(magasin, 1, 1), Key1); } break; case 1: if ((currentAmmo == -1 && maxAmmo == -1) || (currentAmmo == 1 && maxAmmo == 1)) { CorsairKeyboardAPI.setKeyColor(Color.White, Key2); } else { float magasin = currentAmmo; magasin = magasin.remap(0, maxAmmo, 0, 120); CorsairKeyboardAPI.setKeyColor(Program.ColorFromHSV(magasin, 1, 1), Key2); } break; case 2: if ((currentAmmo != -1 && maxAmmo != -1) || (currentAmmo != 1 && maxAmmo != 1)) { float magasin = currentAmmo; magasin = magasin.remap(0, maxAmmo, 0, 120); CorsairKeyboardAPI.setKeyColor(Program.ColorFromHSV(magasin, 1, 1), Key3); } else { CorsairKeyboardAPI.setKeyColor(Color.White, Key3); } break; case 3: if ((currentAmmo != -1 && maxAmmo != -1) || (currentAmmo != 1 && maxAmmo != 1)) { float magasin = currentAmmo; magasin = magasin.remap(0, maxAmmo, 0, 120); CorsairKeyboardAPI.setKeyColor(Program.ColorFromHSV(magasin, 1, 1), Key4); } else { CorsairKeyboardAPI.setKeyColor(Color.White, Key4); } break; case 4: if ((currentAmmo != -1 && maxAmmo != -1) || (currentAmmo != 1 && maxAmmo != 1)) { float magasin = currentAmmo; magasin = magasin.remap(0, maxAmmo, 0, 120); CorsairKeyboardAPI.setKeyColor(Program.ColorFromHSV(magasin, 1, 1), Key5); } else { CorsairKeyboardAPI.setKeyColor(Color.White, Key5); } break; case 5: if ((currentAmmo != -1 && maxAmmo != -1) || (currentAmmo != 1 && maxAmmo != 1)) { float magasin = currentAmmo; magasin = magasin.remap(0, maxAmmo, 0, 120); CorsairKeyboardAPI.setKeyColor(Program.ColorFromHSV(magasin, 1, 1), Key6); } else { CorsairKeyboardAPI.setKeyColor(Color.White, Key6); } break; case 6: if ((currentAmmo != -1 && maxAmmo != -1) || (currentAmmo != 1 && maxAmmo != 1)) { float magasin = currentAmmo; magasin = magasin.remap(0, maxAmmo, 0, 120); CorsairKeyboardAPI.setKeyColor(Program.ColorFromHSV(magasin, 1, 1), Key7); } else { CorsairKeyboardAPI.setKeyColor(Color.White, Key7); } break; } }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Yellow; #region Create default XML file if not existing if (!File.Exists(configName)) { Console.WriteLine("csgo_keyboard_config.xml doesn't exists, creating default template"); new XDocument( new XElement("root", new XElement("weapon_0_button_corsair", Convert.ChangeType(CorsairKeyboardKeyId.D1, typeof(string))), new XElement("weapon_1_button_corsair", Convert.ChangeType(CorsairKeyboardKeyId.D2, typeof(string))), new XElement("weapon_2_button_corsair", Convert.ChangeType(CorsairKeyboardKeyId.D3, typeof(string))), new XElement("weapon_3_button_corsair", Convert.ChangeType(CorsairKeyboardKeyId.D4, typeof(string))), new XElement("weapon_4_button_corsair", Convert.ChangeType(CorsairKeyboardKeyId.D5, typeof(string))), new XElement("weapon_5_button_corsair", Convert.ChangeType(CorsairKeyboardKeyId.D6, typeof(string))), new XElement("weapon_6_button_corsair", Convert.ChangeType(CorsairKeyboardKeyId.D7, typeof(string))), //https://github.com/SteelSeries/gamesense-sdk/blob/master/doc/api/standard-zones.md#zones-specifying-various-individual-keys new XElement("weapon_0_button_steelseries", "keyboard-1"), new XElement("weapon_1_button_steelseries", "keyboard-2"), new XElement("weapon_2_button_steelseries", "keyboard-3"), new XElement("weapon_3_button_steelseries", "keyboard-4"), new XElement("weapon_4_button_steelseries", "keyboard-5"), new XElement("weapon_5_button_steelseries", "keyboard-6"), new XElement("weapon_6_button_steelseries", "keyboard-7"), new XElement("ConsoleTitle", "CS:GO Keyboard Effetcs | APLHA"), new XElement("Engine", "Corsair") ) ).Save(configName); } #endregion #region Read config from xml file XmlDocument xml = new XmlDocument(); xml.Load(configName); XmlNode consoleTitleNode = xml.DocumentElement.SelectSingleNode("/root/ConsoleTitle"); XmlNode weapon_0_corsair = xml.DocumentElement.SelectSingleNode("/root/weapon_0_button_corsair"); XmlNode weapon_1_corsair = xml.DocumentElement.SelectSingleNode("/root/weapon_1_button_corsair"); XmlNode weapon_2_corsair = xml.DocumentElement.SelectSingleNode("/root/weapon_2_button_corsair"); XmlNode weapon_3_corsair = xml.DocumentElement.SelectSingleNode("/root/weapon_3_button_corsair"); XmlNode weapon_4_corsair = xml.DocumentElement.SelectSingleNode("/root/weapon_4_button_corsair"); XmlNode weapon_5_corsair = xml.DocumentElement.SelectSingleNode("/root/weapon_5_button_corsair"); XmlNode weapon_6_corsair = xml.DocumentElement.SelectSingleNode("/root/weapon_6_button_corsair"); XmlNode weapon_0_steelseries = xml.DocumentElement.SelectSingleNode("/root/weapon_0_button_steelseries"); XmlNode weapon_1_steelseries = xml.DocumentElement.SelectSingleNode("/root/weapon_1_button_steelseries"); XmlNode weapon_2_steelseries = xml.DocumentElement.SelectSingleNode("/root/weapon_2_button_steelseries"); XmlNode weapon_3_steelseries = xml.DocumentElement.SelectSingleNode("/root/weapon_3_button_steelseries"); XmlNode weapon_4_steelseries = xml.DocumentElement.SelectSingleNode("/root/weapon_4_button_steelseries"); XmlNode weapon_5_steelseries = xml.DocumentElement.SelectSingleNode("/root/weapon_5_button_steelseries"); XmlNode weapon_6_steelseries = xml.DocumentElement.SelectSingleNode("/root/weapon_6_button_steelseries"); XmlNode keyboard_engine = xml.DocumentElement.SelectSingleNode("/root/Engine"); #endregion Console.WriteLine("Loaded XmlNodes"); #region Get engine from config file try{ if (keyboard_engine.InnerText.ToLower() == "corsair") { useCorsair = true; } else if (keyboard_engine.InnerText.ToLower() == "steelseries") { useCorsair = true; // Will implement steelseries keyboards later. } }catch (Exception e) { errorWrite("NO ENGINE SELECTED!\nPlease choose between \"Corsair\" or \"steelseries\"\nPress any key to exit!\nError msg: " + e.Message); Console.ReadKey(); Environment.Exit(0); } #endregion Console.WriteLine("Got what engine to use"); #region Title try { Console.Title = consoleTitleNode.InnerText + " | Made by /u/pcnorden on reddit"; }catch (Exception) { Console.Title = "ERROR IN XML FILE | Made by /u/pcnorden on reddit"; } #endregion Console.WriteLine("Custom title: " + Console.Title); #region Get weapon_0 key from config file try{ if (useCorsair) { keys[0] = (CorsairKeyboardKeyId)Enum.Parse(typeof(CorsairKeyboardKeyId), weapon_0_corsair.InnerText); } else { steelSeriesKeys[0] = weapon_0_steelseries.InnerText; } }catch (Exception) { errorWrite("Cound not find key id in config file for weapon_0! Reverting to default key!"); if (useCorsair) { keys[0] = CorsairKeyboardKeyId.D1; } else { steelSeriesKeys[0] = "keyboard-1"; } } #endregion Console.WriteLine("Loaded weapon_0 key"); #region Get weapon_1 key from config file try{ if (useCorsair) { keys[1] = (CorsairKeyboardKeyId)Enum.Parse(typeof(CorsairKeyboardKeyId), weapon_1_corsair.InnerText); } else { steelSeriesKeys[1] = weapon_1_steelseries.InnerText; } }catch (Exception) { errorWrite("Could not find key id in config file for weapon_1! Reverting to default key!"); if (useCorsair) { keys[1] = CorsairKeyboardKeyId.D2; } else { steelSeriesKeys[1] = "keyboard-1"; } } #endregion Console.WriteLine("Loaded weapon_1 key"); #region Get weapon_2 key from config file try{ if (useCorsair) { keys[2] = (CorsairKeyboardKeyId)Enum.Parse(typeof(CorsairKeyboardKeyId), weapon_2_corsair.InnerText); } else { steelSeriesKeys[2] = weapon_2_steelseries.InnerText; } }catch (Exception) { errorWrite("Could not find key id in config file for weapon_2! Reverting to default key!"); if (useCorsair) { keys[2] = CorsairKeyboardKeyId.D3; } else { steelSeriesKeys[2] = "keyboard-3"; } } #endregion Console.WriteLine("Loaded weapon_2 key"); #region Get weapon_3 key from config file try{ if (useCorsair) { keys[3] = (CorsairKeyboardKeyId)Enum.Parse(typeof(CorsairKeyboardKeyId), weapon_3_corsair.InnerText); } else { steelSeriesKeys[3] = weapon_3_steelseries.InnerText; } }catch (Exception) { errorWrite("Could not find key id in config file for weapon_3! Reverting to defualt key!"); if (useCorsair) { keys[3] = CorsairKeyboardKeyId.D4; } else { steelSeriesKeys[3] = "keyboard-4"; } } #endregion Console.WriteLine("Loaded weapon_3 key"); #region Get weapon_4 key from config file try{ if (useCorsair) { keys[4] = (CorsairKeyboardKeyId)Enum.Parse(typeof(CorsairKeyboardKeyId), weapon_4_corsair.InnerText); } else { steelSeriesKeys[4] = weapon_4_steelseries.InnerText; } }catch (Exception) { errorWrite("Could not find key id in config file for weapon_4! Reverting to default key!"); if (useCorsair) { keys[4] = CorsairKeyboardKeyId.D5; } else { steelSeriesKeys[4] = "keyboard-5"; } } #endregion Console.WriteLine("Loaded weapon_4 key"); #region Get weapon_5 key from config file try{ if (useCorsair) { keys[5] = (CorsairKeyboardKeyId)Enum.Parse(typeof(CorsairKeyboardKeyId), weapon_5_corsair.InnerText); } else { steelSeriesKeys[5] = weapon_5_steelseries.InnerText; } }catch (Exception) { errorWrite("Could not find key id in config file for weapon_5! Reverting to default key!"); if (useCorsair) { keys[5] = CorsairKeyboardKeyId.D6; } else { steelSeriesKeys[5] = "keyboard-6"; } } #endregion Console.WriteLine("Loaded weapon_5 key"); #region Get weapon_6 key from config file try{ if (useCorsair) { keys[6] = (CorsairKeyboardKeyId)Enum.Parse(typeof(CorsairKeyboardKeyId), weapon_6_corsair.InnerText); } else { steelSeriesKeys[6] = weapon_6_steelseries.InnerText; } }catch (Exception) { errorWrite("Could not find key id in config file for weapon_6! Reverting to default key!"); if (useCorsair) { keys[6] = CorsairKeyboardKeyId.D7; } else { steelSeriesKeys[6] = "keyboard-7"; } } #endregion Console.WriteLine("Loaded weapon_6 key\n"); Console.ForegroundColor = ConsoleColor.White; if (useCorsair) { // We will try and launch the corsair effects engine SDK wrapper, and if returned true, we have suceeded if (CorsairKeyboardAPI.initSDK()) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Initialized the corsair wrapper"); WebServer.initServer(); Console.WriteLine("Started the server\n\nPress escape when this window is active to close the program"); while (true) { ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.Escape) { Environment.Exit(0); } } } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\"I'm sorry Dave, I'm afraid I can't do that\""); Console.WriteLine("Failed to initialize the Corsair SDK, please check that you have CUE running"); Console.WriteLine("Press any key to exit"); Console.ReadKey(); Environment.Exit(0); } } else { Console.ForegroundColor = ConsoleColor.Cyan; foreach (string str in notSupported) { Console.WriteLine(str); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); Environment.Exit(0); } }