|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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
Form * | getForm () 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

enum gameplay::Gamepad::ButtonMapping

Gamepad buttons.

enum gameplay::Gamepad::GamepadEvent

Gamepad events.

## Member Function Documentation

void gameplay::Gamepad::draw | ( |  | ) |

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.

Form* gameplay::Gamepad::getForm | ( |  | ) | const

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:

  joystickId | The index of the joystick to get the value for.
  outValues | The 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:

  triggerId | The trigger to query.

Returns:
  The value of the given trigger.

bool gameplay::Gamepad::isButtonDown | ( | ButtonMapping | button | ) | const

Gets whether the given button is currently pressed down.

Parameters:

  button | The enum of the button on the gamepad to get the state for.

Returns:
  Whether the button is currently pressed or not.

bool gameplay::Gamepad::isVirtual | ( |  | ) | const

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:

  elapsedTime | The elapsed game time.

All Classes Functions Variables Typedefs Enumerations Enumerator