SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GamepadConfig Class Reference

specialisation of DeviceConfig for gamepad type devices More...

#include <gamepad_config.hpp>

Inheritance diagram for GamepadConfig:
Inheritance graph
[legend]

Public Member Functions

 GamepadConfig (const std::string &name, const int axis_count=0, const int button_ount=0)
 
core::stringw toString ()
 Converts the configuration to a string.
 
virtual void save (std::ofstream &stream) OVERRIDE
 Saves the configuration to a file.
 
void setDefaultBinds ()
 
virtual core::stringw getBindingAsString (const PlayerAction action) const OVERRIDE
 Get a user-readable string describing the bound action.
 
virtual bool load (const XMLNode *config) OVERRIDE
 Loads this configuration from the given XML node.
 
virtual bool isAnalog (Input::InputType type, int id) const OVERRIDE
 Returns if this device uses analog axes.
 
virtual bool desensitize () const OVERRIDE
 Returns true if this device should desensitize its input at values close to 0 (to avoid 'oversteering').
 
virtual int getNumberOfButtons () const OVERRIDE
 Returns the number of buttons in this configuration.
 
void setNumberOfButtons (int count)
 Sets the number of buttons this device has.
 
virtual int getNumberOfAxes () const OVERRIDE
 Returns the number of axis of this configufation.
 
void setNumberOfAxis (int count)
 Sets the number of axis this device has.
 
int getDeadzone () const
 Return deadzone of this configuration.
 
virtual bool isGamePad () const OVERRIDE
 
virtual bool isKeyboard () const OVERRIDE
 
void initSDLController (const std::string &mapping, int buttons, int axes, int hats)
 
void initSDLMapping ()
 
bool useForceFeedback () const
 
void setForceFeedback (bool val)
 
int getAutoCenterStrength () const
 
void setAutoCenter (bool val)
 
- Public Member Functions inherited from DeviceConfig
irr::core::stringw toString ()
 
bool hasBindingFor (const int buttonID) const
 
bool hasBindingFor (const int buttonID, PlayerAction from, PlayerAction to) const
 
void setBinding (const PlayerAction action, const Input::InputType type, const int id, Input::AxisDirection direction=Input::AD_NEUTRAL, Input::AxisRange range=Input::AR_HALF)
 Sets the bindings for an action.
 
bool getMenuAction (Input::InputType type, const int id, int *value, PlayerAction *action)
 Searches for a game actions associated with the given input event.
 
irr::core::stringw getMappingIdString (const PlayerAction action) const
 Get an internal unique string describing the bound action.
 
virtual irr::core::stringw getBindingAsString (const PlayerAction action) const
 Get a user-readable string describing the bound action.
 
virtual bool isGamePad () const =0
 
virtual bool isKeyboard () const =0
 
virtual void save (std::ofstream &stream)
 Saves the configuration to a file.
 
virtual bool load (const XMLNode *config)
 Reads a device configuration from input.xml.
 
virtual bool isAnalog (Input::InputType type, int id) const
 Returns true if this device has analog axis, so that steering values will not be affected by time-full-steer delays.
 
virtual bool desensitize () const
 Returns true if this device should desensitize its input at values close to 0 (to avoid 'oversteering').
 
virtual int getNumberOfButtons () const
 Should only be called for gamepads, which has its own implementation.
 
virtual int getNumberOfAxes () const
 Should only be called for gamepads, which has its own implementation.
 
void setName (const std::string &name)
 Sets the internal name of this device.
 
const std::string & getName () const
 Returns the internal name for this device configuration.
 
void setPlugged ()
 Increase ref counter.
 
bool isPlugged () const
 Returns if this config is sed by any devices.
 
void unPlugged ()
 Decrease ref counter.
 
int getNumberOfDevices () const
 Returns the number of devices using this configuration.
 
const BindinggetBinding (int i) const
 Returns the binding of a given index.
 
bool isEnabled () const
 At this time only relevant for gamepads, keyboards are always enabled.
 
void setEnabled (bool new_value)
 Sets this config to be enabled or disabled.
 
irr::core::stringw getConfigName () const
 Sets the name of this device configuration.
 
void setConfigName (irr::core::stringw config_name)
 Returns the name of this device configuration.
 

Private Member Functions

bool getMappingTuple (const std::string &rhs, std::tuple< int, Input::AxisDirection > &t)
 
void setBindingFromTuple (const PlayerAction action, std::tuple< int, Input::AxisDirection > &t)
 

Private Attributes

int m_axis_count
 Number of axis this device has.
 
int m_hat_count
 Number of hat this device has.
 
int m_button_count
 Number of buttons this device has.
 
int m_deadzone
 Deadzone of this gamepad.
 
bool m_desensitize
 If set to true, map any analog axis from x in [0,1] to x^x --> at values close to 0 the joystick will react less sensitive.
 
bool m_use_force_feedback
 
int m_auto_center
 
std::map< std::tuple< int, Input::AxisDirection >, int > m_sdl_mapping
 
std::set< int > m_digital_axes
 

Additional Inherited Members

- Static Public Member Functions inherited from DeviceConfig
static DeviceConfigcreate (const XMLNode *config)
 A simple factory that creates either a gamepad or a keyboard configuration.
 
- Protected Member Functions inherited from DeviceConfig
bool doGetAction (Input::InputType type, const int id, int *value, const PlayerAction firstActionToCheck, const PlayerAction lastActionToCheck, PlayerAction *action)
 internal helper method for DeviceConfig::getGameAction and DeviceConfig::getMenuAction
 
bool getGameAction (Input::InputType type, const int id, int *value, PlayerAction *action)
 Searches for a game actions associated with the given input event.
 
- Protected Attributes inherited from DeviceConfig
Binding m_bindings [PA_COUNT]
 

Detailed Description

specialisation of DeviceConfig for gamepad type devices

Member Function Documentation

◆ desensitize()

virtual bool GamepadConfig::desensitize ( ) const
inlinevirtual

Returns true if this device should desensitize its input at values close to 0 (to avoid 'oversteering').

Reimplemented from DeviceConfig.

◆ getBindingAsString()

core::stringw GamepadConfig::getBindingAsString ( const PlayerAction  action) const
virtual

Get a user-readable string describing the bound action.

Reimplemented from DeviceConfig.

◆ getNumberOfAxes()

virtual int GamepadConfig::getNumberOfAxes ( ) const
inlinevirtual

Returns the number of axis of this configufation.

Reimplemented from DeviceConfig.

◆ getNumberOfButtons()

virtual int GamepadConfig::getNumberOfButtons ( ) const
inlinevirtual

Returns the number of buttons in this configuration.

Reimplemented from DeviceConfig.

◆ isAnalog()

bool GamepadConfig::isAnalog ( Input::InputType  type,
int  id 
) const
virtual

Returns if this device uses analog axes.

Reimplemented from DeviceConfig.

◆ isGamePad()

virtual bool GamepadConfig::isGamePad ( ) const
inlinevirtual

Implements DeviceConfig.

◆ isKeyboard()

virtual bool GamepadConfig::isKeyboard ( ) const
inlinevirtual

Implements DeviceConfig.

◆ load()

bool GamepadConfig::load ( const XMLNode config)
virtual

Loads this configuration from the given XML node.

Parameters
configThe XML tree.
Returns
False in case of an error.

Reimplemented from DeviceConfig.

◆ save()

void GamepadConfig::save ( std::ofstream &  stream)
virtual

Saves the configuration to a file.

It writes the name for a gamepad config, saves the device specific parameters, and calls DeviceConfig::save() to save the rest.

Parameters
streamThe stream to save to.

Reimplemented from DeviceConfig.


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