/// <summary> /// Rebinds a key to the given Keybind /// </summary> /// <param name="name"></param> /// <param name="newBinding"></param> public static void RebindKey(string name, Keybind newBinding) { if (keybinds.ContainsKey(name.ToLower())) { Keybind toBind = keybinds[name.ToLower()]; toBind.keyboardBinding = newBinding.keyboardBinding; toBind.gamepadBinding = newBinding.gamepadBinding; toBind.mouseBinding = newBinding.mouseBinding; keybinds[name.ToLower()] = toBind; } }
private static void BindKey(string name, Keybind fallback) { if (!keybinds.ContainsKey(name.ToLower())) { //try to load the keybind from file keybinds.Add(name.ToLower(), fallback); } else { Logger.fatal(0, "An error occured when registering keybind \"" + name.ToLower() + "\"! (ERR_KEYBIND_CONFLICT)"); } }
/// <summary> /// Returns a keybind representing the currently pressed key /// </summary> /// <returns></returns> public static Keybind CaptureBinding() { Keybind currentBinding = new Keybind(); //Get the first element in the current keyboard keys currentBinding.keyboardBinding = CurrentKeys.GetPressedKeys()[0]; //Get the first element in the current gamepad state currentBinding.gamepadBinding = GetGamepadButtons(); //Get the first element in the current mouse state currentBinding.mouseBinding = GetMouseButtons(); return(currentBinding); }