/// <summary> /// Updates the InputManagerComponent, calling the Update method on all input related classes. /// </summary> /// <param name="gameTime">The current GameTime.</param> public override void Update(GameTime gameTime) { base.Update(gameTime); KeyboardManager.Update(); #if WINDOWS MouseManager.Update(); #endif GamePadManager.UpdateAll(); }
/// <summary> /// Update this GamePadButtonEnumerator. /// </summary> /// <param name="gt">The current GameTime.</param> public virtual void Update(GameTime gt) { if (XnaExtensions.IsGuideVisible) { //Don't perform logic return; } GamePadState current = GamePadManager.GetManager(Player).Current; bool isJoystick = Input == InputType.LeftJoystick || Input == InputType.RightJoystick; if (isJoystick) { Vector2 joystick = Input == InputType.LeftJoystick ? current.ThumbSticks.Left : (Input == InputType.RightJoystick ? current.ThumbSticks.Right : Vector2.Zero); if (joystick.Y >= _axisDifference) { _elapsedUpTime += gt.ElapsedGameTime; } else if (joystick.Y <= -_axisDifference) { _elapsedDownTime += gt.ElapsedGameTime; } if (joystick.X >= _axisDifference) { _elapsedRightTime += gt.ElapsedGameTime; } else if (joystick.X <= -_axisDifference) { _elapsedLeftTime += gt.ElapsedGameTime; } if (_elapsedUpTime >= _delay) { _elapsedUpTime = TimeSpan.Zero; MoveSelection(Direction.Top); } if (_elapsedDownTime >= _delay) { _elapsedDownTime = TimeSpan.Zero; MoveSelection(Direction.Bottom); } if (_elapsedLeftTime >= _delay) { _elapsedLeftTime = TimeSpan.Zero; MoveSelection(Direction.Left); } if (_elapsedRightTime >= _delay) { _elapsedRightTime = TimeSpan.Zero; MoveSelection(Direction.Right); } } else { //We know for sure it is DPad. if (_lastState.DPad.Left == ButtonState.Released && current.DPad.Left == ButtonState.Pressed) { MoveSelection(Direction.Left); } if (_lastState.DPad.Right == ButtonState.Released && current.DPad.Right == ButtonState.Pressed) { MoveSelection(Direction.Right); } if (_lastState.DPad.Up == ButtonState.Released && current.DPad.Up == ButtonState.Pressed) { MoveSelection(Direction.Top); } if (_lastState.DPad.Down == ButtonState.Released && current.DPad.Down == ButtonState.Pressed) { MoveSelection(Direction.Bottom); } } if (_allButtons[_rowCurrent, _columnCurrent].Visible && _lastState.IsButtonUp(_submitButton) && current.IsButtonDown(_submitButton)) { if (this.FireTextSpritePressed) { _allButtons[_rowCurrent, _columnCurrent].FireClicked(); } else if (ButtonPress != null) { ButtonPress(_allButtons[_rowCurrent, _columnCurrent], EventArgs.Empty); } } _lastState = current; }