SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Friends | List of all members
DeviceConfig Class Referenceabstract

contains the key bindings information related to one input device More...

#include <device_config.hpp>

Inheritance diagram for DeviceConfig:
Inheritance graph
[legend]

Public Member Functions

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.
 

Static Public Member Functions

static DeviceConfigcreate (const XMLNode *config)
 A simple factory that creates either a gamepad or a keyboard configuration.
 

Protected Member Functions

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

Binding m_bindings [PA_COUNT]
 

Private Attributes

bool m_enabled
 If set to false, this device will be ignored.
 
int m_plugged
 How many devices connected to the system which uses this config?
 
std::string m_name
 Internal name of this configuration.
 
irr::core::stringw m_config_name
 Name of this configuration (given by the user).
 

Friends

class GamePadDevice
 Those two classes need to be able to call getGameAction.
 
class KeyboardDevice
 

Detailed Description

contains the key bindings information related to one input device

Member Function Documentation

◆ create()

DeviceConfig * DeviceConfig::create ( const XMLNode config)
static

A simple factory that creates either a gamepad or a keyboard configuration.

Parameters
type"gamepad" or "keyboard".
configThe XML node with additional configuration parameters.

◆ desensitize()

virtual bool DeviceConfig::desensitize ( ) const
inlinevirtual

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

Reimplemented in GamepadConfig.

◆ getBindingAsString()

irr::core::stringw DeviceConfig::getBindingAsString ( const PlayerAction  action) const
virtual

Get a user-readable string describing the bound action.

Reimplemented in GamepadConfig.

◆ getGameAction()

bool DeviceConfig::getGameAction ( Input::InputType  type,
const int  id,
int *  value,
PlayerAction action 
)
protected

Searches for a game actions associated with the given input event.

Note
Don't call this directly unless you are KeyboardDevice or GamepadDevice.
Parameters
[out]actionthe result, only set if method returned true.
Returns
whether finding an action associated to this input was successful.

◆ getMappingIdString()

irr::core::stringw DeviceConfig::getMappingIdString ( const PlayerAction  action) const

Get an internal unique string describing the bound action.

Parameters
actionThe action for which to get the string.

◆ getMenuAction()

bool DeviceConfig::getMenuAction ( Input::InputType  type,
const int  id,
int *  value,
PlayerAction action 
)

Searches for a game actions associated with the given input event.

Note
Don't call this directly unless you are KeyboardDevice or GamepadDevice.
Parameters
[out]actionThe result, only set if method returned true.
Returns
Whether finding an action associated to this input was successful

◆ getNumberOfAxes()

virtual int DeviceConfig::getNumberOfAxes ( ) const
inlinevirtual

Should only be called for gamepads, which has its own implementation.

of this function.

Reimplemented in GamepadConfig.

◆ getNumberOfButtons()

virtual int DeviceConfig::getNumberOfButtons ( ) const
inlinevirtual

Should only be called for gamepads, which has its own implementation.

of this function.

Reimplemented in GamepadConfig.

◆ isAnalog()

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

Returns true if this device has analog axis, so that steering values will not be affected by time-full-steer delays.

Reimplemented in GamepadConfig.

◆ load()

bool DeviceConfig::load ( const XMLNode config)
virtual

Reads a device configuration from input.xml.

Parameters
configThe XML Node of the configuration.
Returns
False if an error occurred.

Reimplemented in GamepadConfig.

◆ save()

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

Saves the configuration to a file.

The calling node must have written the beginning of the xml node, so that this function can immediately start writing attributes.

Parameters
streamThe stream to save to.

Reimplemented in KeyboardConfig, and GamepadConfig.

◆ setBinding()

void DeviceConfig::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.

Parameters
actionThe action to be bound.
typeInput type (stick button, stick motion, ...).
idAn id for this binding.
directionIn which direction the stick is moved.

Member Data Documentation

◆ m_enabled

bool DeviceConfig::m_enabled
private

If set to false, this device will be ignored.

Currently for gamepads only.


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