/// <summary> /// Checks for any input this frame, and if there is any, registers that as the new /// input method for the given input type. /// </summary> /// <param name="input"></param> /// <returns>Whether or not a new input was accepted.</returns> public bool ListenForNewInput(Input input) { SmileyInputConfig config = SMH.ConfigManager.Config.Inputs.Single(i => i.Input == input); GamePadState gamePadState = GamePad.GetState(PlayerIndex.One); foreach (Buttons button in Enum.GetValues(typeof(Buttons))) { if (gamePadState.IsButtonDown(button)) { config.Device = InputDevice.GamePad; config.Code = (int)button; return(true); } } KeyboardState state = Keyboard.GetState(); foreach (Keys key in Enum.GetValues(typeof(Keys))) { if (state.IsKeyDown(key)) { config.Device = InputDevice.Keyboard; config.Code = (int)key; return(true); } } return(false); }
/// <summary> /// Gets a user friendly description for the key or button currently configured /// for the given input. /// </summary> /// <param name="input"></param> /// <returns></returns> public string GetInputDescription(Input input) { SmileyInputConfig config = SMH.ConfigManager.Config.Inputs.Single(i => i.Input == input); if (config.Device == InputDevice.Keyboard) { return(((Keys)config.Code).ToString()); } else //if (_inputs[input].Device == InputDevice.GamePad) { return(((Buttons)config.Code).ToString()); } }