SuperTuxKart
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GamePadDevice Class Reference

specialisation of Inputdevice for gamepad type devices More...

#include <gamepad_device.hpp>

Inheritance diagram for GamePadDevice:
Inheritance graph
[legend]

Public Member Functions

 GamePadDevice (const int irrIndex, const std::string &name, const int axis_number, const int button_count, GamepadConfig *configuration)
 Constructor for GamePadDevice from a connected gamepad for which no configuration existed (defaults will be used) More...
 
virtual ~GamePadDevice ()
 Destructor for GamePadDevice.
 
bool isButtonPressed (const int i)
 
void setButtonPressed (const int i, bool isButtonPressed)
 
virtual bool processAndMapInput (Input::InputType type, const int id, InputManager::InputDriverMode mode, PlayerAction *action, int *value=NULL) OVERRIDE
 Invoked when this device it used. More...
 
int getNumberOfButtons () const
 Returns the number of buttons of this gamepad. More...
 
bool moved (int value) const
 Returns if the specified value is larger than the deadzone. More...
 
int getIrrIndex () const
 Returns the irrlicht index of this gamepad. More...
 
- Public Member Functions inherited from InputDevice
void setPlayer (StateManager::ActivePlayer *owner)
 Sets which players uses this device; or pass NULL to say no player uses it. More...
 
void setConfiguration (DeviceConfig *config)
 Sets the configuration to be used by this input device. More...
 
DeviceConfiggetConfiguration ()
 Returns the configuration for this device. More...
 
DeviceType getType () const
 Returns the type of this device. More...
 
StateManager::ActivePlayergetPlayer ()
 Returns the player using this device. More...
 
const std::string & getName () const
 Returns the name of this device. More...
 

Private Member Functions

void resetAxisDirection (const int axis, Input::AxisDirection direction)
 

Private Attributes

std::vector< bool > m_button_pressed
 
std::vector< Input::AxisDirection > m_prev_axis_directions
 
std::vector< int > m_prev_axis_value
 used to determine if an axis is valid; an axis is considered valid when at least 2 different values are read from this axis (if an axis keeps on sending the exact same value continuously, chances are that it's not meant by the user - for instance some gamepads have hats or analog switches that get reported as axis, we even had a report that on linux some hard disks may be reported as gamepads with uninteresting axis values)
 
std::vector< bool > m_axis_ok
 
int m_irr_index
 Irrlicht index of this gamepad. More...
 

Additional Inherited Members

- Protected Attributes inherited from InputDevice
DeviceType m_type
 Device type (keyboard, gamepad). More...
 
StateManager::ActivePlayerm_player
 Which player is using this device. More...
 
DeviceConfigm_configuration
 The configuration for this device. More...
 
std::string m_name
 If device has a name; unused for keyboards since AFAIK we can't tell keyboards apart. More...
 

Detailed Description

specialisation of Inputdevice for gamepad type devices

Constructor & Destructor Documentation

◆ GamePadDevice()

GamePadDevice::GamePadDevice ( const int  irr_index,
const std::string &  name,
const int  axis_count,
const int  button_count,
GamepadConfig configuration 
)

Constructor for GamePadDevice from a connected gamepad for which no configuration existed (defaults will be used)

Parameters
irrIndexIndex of stick as given by irrLicht.

Member Function Documentation

◆ getIrrIndex()

int GamePadDevice::getIrrIndex ( ) const
inline

Returns the irrlicht index of this gamepad.

◆ getNumberOfButtons()

int GamePadDevice::getNumberOfButtons ( ) const

Returns the number of buttons of this gamepad.

◆ moved()

bool GamePadDevice::moved ( int  value) const

Returns if the specified value is larger than the deadzone.

◆ processAndMapInput()

bool GamePadDevice::processAndMapInput ( Input::InputType  type,
const int  id,
InputManager::InputDriverMode  mode,
PlayerAction action,
int *  value = NULL 
)
virtual

Invoked when this device it used.

Verifies if the key/button that was pressed is associated with a binding. If yes, sets action and returns true; otherwise returns false. It can also modify the value used.

Parameters
typeType of input (e.g. IT_STICKMOTION, ...).
idID of the key that was pressed or of the axis that was triggered (depending on the value of the 'type' parameter).
modeUsed to determine whether to map menu actions or game actions
[out]actionThe action associated to this input (only check this value if method returned true)
[in,out]valueThe value associated with this type (typically how far a gamepad axis is moved).
Returns
Whether the pressed key/button is bound with an action

Implements InputDevice.

Member Data Documentation

◆ m_axis_ok

std::vector<bool> GamePadDevice::m_axis_ok
private

◆ m_irr_index

int GamePadDevice::m_irr_index
private

Irrlicht index of this gamepad.


The documentation for this class was generated from the following files: