VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Types | Public Member Functions | List of all members
ControllerEvent Class Reference

A platform independent event generated by controller device. More...

Public Types

typedef std::map< KeyCode, bool > KeyStates
 Map of keys to their changes in pressed state. More...
 
typedef std::map
< JoystickAxisCode, float > 
JoystickAxisStates
 Map of joystick axes to their changes in [-1.0f, 1.0f] axis value. More...
 
typedef std::map
< TriggerAxisCode, float > 
TriggerAxisStates
 Map of trigger axes to their changes in [0.0f, 1.0f] axis value. More...
 

Public Member Functions

 ControllerEvent (int deviceId=-1)
 Constructs a ControllerEvent for a controller identified by the specified deviceId. More...
 
bool hasDeviceId () const
 Returns whether or not this ControllerEvent has a valid (non-zero) deviceId. More...
 
int getDeviceId () const
 Returns the deviceId for this ControllerEvent, or a negative number if it is "deviceless". More...
 
void setDeviceId (int deviceId)
 Sets the deviceId for this ControllerEvent. More...
 
bool hasKeyInfo () const
 Returns whether or not this ControllerEvent contains any key press information. More...
 
bool hasKeyInfo (const KeyCode &keyCode) const
 Returns whether or not this ControllerEvent contains any key press information for the specified key. More...
 
bool isKeyPressed (const KeyCode &keyCode) const
 Returns whether or not the specified key is pressed. More...
 
const KeyStatesgetKeyStates () const
 Returns pressed state changes for all keys contained in this event. More...
 
void setKeyState (const KeyCode &keyCode, bool isPressed)
 Sets whether or not the key has been pressed or released. More...
 
bool hasJoystickAxisInfo () const
 Returns whether or not this ControllerEvent contains any axis information for the specified joystick axis. More...
 
bool hasJoystickAxisInfo (const JoystickAxisCode &axis) const
 Returns whether or not this ControllerEvent contains any axis information. More...
 
float getJoystickAxisValue (const JoystickAxisCode &axis) const
 Returns the [-1.0f, 1.0f] axis value for the specified joystick axis. More...
 
const JoystickAxisStatesgetJoystickAxisStates () const
 Returns joystick axis value changes for all joystick axes contained in this event. More...
 
void setJoystickAxisValue (const JoystickAxisCode &axis, float value)
 Sets the [-1.0f, 1.0f]joystick axis value for the specified joystick axis. More...
 
bool hasTriggerAxisInfo () const
 Returns whether or not this ControllerEvent contains any axis information for the specified trigger axis. More...
 
bool hasTriggerAxisInfo (const TriggerAxisCode &axis) const
 Returns the [0.0, 1.0] axis value for the specified trigger axis. More...
 
float getTriggerAxisValue (const TriggerAxisCode &axis) const
 Returns the [0.0, 1.0] axis value for the specified trigger axis. More...
 
const TriggerAxisStatesgetTriggerAxisStates () const
 Returns trigger axis value changes for all trigger axes contained in this event. More...
 
void setTriggerAxisValue (const TriggerAxisCode &axis, float value)
 Sets the [0.0, 1.0] trigger axis value for the specified trigger axis. More...
 

Detailed Description

A platform independent event generated by controller device.

This event can represent input events from any type of controller without respect to platform.

Note
The event represents changes in the state of the controller, and not necessarily the current state of the full controller.

Member Typedef Documentation

Map of joystick axes to their changes in [-1.0f, 1.0f] axis value.

typedef std::map<KeyCode, bool> ControllerEvent::KeyStates

Map of keys to their changes in pressed state.

Map of trigger axes to their changes in [0.0f, 1.0f] axis value.

Constructor & Destructor Documentation

ControllerEvent::ControllerEvent ( int  deviceId = -1)

Constructs a ControllerEvent for a controller identified by the specified deviceId.

Parameters
deviceIdId that uniquely identifies a controller

Member Function Documentation

int ControllerEvent::getDeviceId ( ) const
inline

Returns the deviceId for this ControllerEvent, or a negative number if it is "deviceless".

const JoystickAxisStates& ControllerEvent::getJoystickAxisStates ( ) const
inline

Returns joystick axis value changes for all joystick axes contained in this event.

float ControllerEvent::getJoystickAxisValue ( const JoystickAxisCode axis) const

Returns the [-1.0f, 1.0f] axis value for the specified joystick axis.

Parameters
axisCode of the joystick axis to query for axis value
const KeyStates& ControllerEvent::getKeyStates ( ) const
inline

Returns pressed state changes for all keys contained in this event.

const TriggerAxisStates& ControllerEvent::getTriggerAxisStates ( ) const
inline

Returns trigger axis value changes for all trigger axes contained in this event.

float ControllerEvent::getTriggerAxisValue ( const TriggerAxisCode axis) const

Returns the [0.0, 1.0] axis value for the specified trigger axis.

Parameters
axisCode of the trigger axis to query for axis value
bool ControllerEvent::hasDeviceId ( ) const
inline

Returns whether or not this ControllerEvent has a valid (non-zero) deviceId.

bool ControllerEvent::hasJoystickAxisInfo ( ) const
inline

Returns whether or not this ControllerEvent contains any axis information for the specified joystick axis.

bool ControllerEvent::hasJoystickAxisInfo ( const JoystickAxisCode axis) const
inline

Returns whether or not this ControllerEvent contains any axis information.

Parameters
axisCode of the joystick axis to query for presence of axis information
bool ControllerEvent::hasKeyInfo ( ) const
inline

Returns whether or not this ControllerEvent contains any key press information.

bool ControllerEvent::hasKeyInfo ( const KeyCode keyCode) const
inline

Returns whether or not this ControllerEvent contains any key press information for the specified key.

Parameters
keyCodeCode of key to query for presence of pressed state information
bool ControllerEvent::hasTriggerAxisInfo ( ) const
inline

Returns whether or not this ControllerEvent contains any axis information for the specified trigger axis.

bool ControllerEvent::hasTriggerAxisInfo ( const TriggerAxisCode axis) const
inline

Returns the [0.0, 1.0] axis value for the specified trigger axis.

Parameters
axisCode of the trigger axis to query for axis value
bool ControllerEvent::isKeyPressed ( const KeyCode keyCode) const

Returns whether or not the specified key is pressed.

Parameters
keyCodeCode of key to query for pressed state information
void ControllerEvent::setDeviceId ( int  deviceId)
inline

Sets the deviceId for this ControllerEvent.

void ControllerEvent::setJoystickAxisValue ( const JoystickAxisCode axis,
float  value 
)

Sets the [-1.0f, 1.0f]joystick axis value for the specified joystick axis.

Parameters
axisCode of joystick axis whose state has changed
value[-1.0f, 1.0f] new axis value
void ControllerEvent::setKeyState ( const KeyCode keyCode,
bool  isPressed 
)
inline

Sets whether or not the key has been pressed or released.

Parameters
keyCodeCode of key whose state has changed
isPressedWhether or the key is pressed
void ControllerEvent::setTriggerAxisValue ( const TriggerAxisCode axis,
float  value 
)

Sets the [0.0, 1.0] trigger axis value for the specified trigger axis.

Parameters
axisCode of trigger axis whose state has changed
value[0.0, 1.0] new axis value