Controller class

The controller class provides a wrapper around XNA's GamePadState, but adds the following abilities:
  • Test whether a button was released since the last update.
  • Test whether a button has been held down for a certain period of time.
  • Vibrate the controller for a certain period of time.

Constructors

public Controller(PlayerIndex index)
Create a controller object that uses the selected index.

Fields / Properties

public GamePadState State
Allows access to the underlying GamePadState class. This is updated every time the Update method is called.

public Dictionary<Buttons, Boolean> ButtonReleased
Returns a list of values that tell if specific buttons were released since the last time Update was called.

public Dictionary<Buttons, Boolean> TimedButtonTriggered
Returns a list of values that return true if:
  • The button is currently being held down and
  • A specified amount of time has passed since the button was first pressed, or since the timer was last triggered.
The amount of time can be changed for the class by calling SetTimerThreshold, and this function can be reset by calling ResetTimerThreshold.

Methods

public void ClearVibrate()
Clears any vibration that was set on the controller.

public void ResetTimerThreshold()
Clears all timers for timed button triggers.

public void SetTimerThreshold(double seconds)
Sets the amount of time between timed button triggers.

public void Update(GameTime gameTime)
Updates the state of the controller, including the GamePadState, ButtonReleased, and TimedButtonTriggered properties.

public void VibratePulse(Double seconds, Double delay, float leftMotor, float rightMotor)
Vibrates the controller at the specified levels (leftMotor, rightMotor) for the specified amount of time (seconds). If delay is set, it will delay the vibration for the specified number of seconds after the method call.

Last edited Jan 4, 2010 at 4:45 AM by dylanwolf, version 1

Comments

No comments yet.