overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Types | Public Member Functions
gameplay::Gamepad Class Reference

#include <Gamepad.h>

List of all members.

Public Types

enum  GamepadEvent { CONNECTED_EVENT, DISCONNECTED_EVENT }
enum  ButtonMapping {
  BUTTON_A, BUTTON_B, BUTTON_X, BUTTON_Y,
  BUTTON_L1, BUTTON_L2, BUTTON_L3, BUTTON_R1,
  BUTTON_R2, BUTTON_R3, BUTTON_UP, BUTTON_DOWN,
  BUTTON_LEFT, BUTTON_RIGHT, BUTTON_MENU1, BUTTON_MENU2,
  BUTTON_MENU3
}

Public Member Functions

unsigned int getButtonCount () const
bool isButtonDown (ButtonMapping button) const
unsigned int getJoystickCount () const
void getJoystickValues (unsigned int joystickId, Vector2 *outValues) const
unsigned int getTriggerCount () const
float getTriggerValue (unsigned int triggerId) const
const char * getName () const
bool isVirtual () const
FormgetForm () const
void update (float elapsedTime)
void draw ()

Detailed Description

Defines a gamepad interface for handling input from joysticks and buttons.

A gamepad can be either physical or virtual. Most platform support up to 4 gamepad controllers connected simulataneously.


Member Enumeration Documentation

Gamepad buttons.

Gamepad events.


Member Function Documentation

Draws the gamepad if it is based on a form and if the form is enabled.

unsigned int gameplay::Gamepad::getButtonCount ( ) const

Gets the number of buttons on this gamepad.

Returns:
The number of buttons on this gamepad.

Gets the Form used to represent this gamepad.

Returns:
the Form used to represent this gamepad. NULL if the gamepad is not represented with a Form.
unsigned int gameplay::Gamepad::getJoystickCount ( ) const

Gets the number of joysticks on the gamepad.

Returns:
the number of joysticks on the gamepad.
void gameplay::Gamepad::getJoystickValues ( unsigned int  joystickId,
Vector2 outValues 
) const

Returns the specified joystick's value as a Vector2.

Parameters:
joystickIdThe index of the joystick to get the value for.
outValuesThe current x-axis and y-axis values of the joystick.
const char* gameplay::Gamepad::getName ( ) const

Get this gamepad's device/product name.

Returns:
This gamepad's device/product name.
unsigned int gameplay::Gamepad::getTriggerCount ( ) const

Returns the number of analog triggers (as opposed to digital shoulder buttons) on this gamepad.

Returns:
The number of analog triggers on this gamepad.
float gameplay::Gamepad::getTriggerValue ( unsigned int  triggerId) const

Returns the value of an analog trigger on this gamepad. This value will be a number between 0 and 1, where 0 means the trigger is in its resting (unpressed) state and 1 means the trigger has been completely pressed down.

Parameters:
triggerIdThe trigger to query.
Returns:
The value of the given trigger.

Gets whether the given button is currently pressed down.

Parameters:
buttonThe enum of the button on the gamepad to get the state for.
Returns:
Whether the button is currently pressed or not.

Returns whether the gamepad is currently represented with a UI form or not.

Returns:
true if the gamepad is currently represented by a UI form; false if the gamepad is not represented by a UI form.
void gameplay::Gamepad::update ( float  elapsedTime)

Updates the gamepad's state. For a virtual gamepad, this results in calling update() on the gamepad's form. For physical gamepads, this polls the gamepad's state at the platform level. Either way, this should be called once a frame before getting and using a gamepad's current state.

Parameters:
elapsedTimeThe elapsed game time.
 All Classes Functions Variables Typedefs Enumerations Enumerator