SuperTuxKart
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, wchar_t character=0)
 Sets the bindings for an action. More...
 
bool getMenuAction (Input::InputType type, const int id, int *value, PlayerAction *action)
 Searches for a game actions associated with the given input event. More...
 
irr::core::stringw getMappingIdString (const PlayerAction action) const
 Get an internal unique string describing the bound action. More...
 
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 isGamePadAndroid () const =0
 
virtual bool isKeyboard () const =0
 
virtual void save (std::ofstream &stream)
 Saves the configuration to a file. More...
 
virtual bool load (const XMLNode *config)
 Reads a device configuration from input.xml. More...
 
virtual bool isAnalog () const
 Returns true if this device has analog axis, so that steering values will not be affected by time-full-steer delays. More...
 
virtual bool desensitize () const
 Returns true if this device should desensitize its input at values close to 0 (to avoid 'oversteering'). More...
 
virtual int getNumberOfButtons () const
 Should only be called for gamepads, which has its own implementation. More...
 
virtual int getNumberOfAxes () const
 Should only be called for gamepads, which has its own implementation. More...
 
void setName (const std::string &name)
 Sets the name of this device. More...
 
const std::string & getName () const
 Returns the name for this device configuration. More...
 
void setPlugged ()
 Increase ref counter. More...
 
bool isPlugged () const
 Returns if this config is sed by any devices. More...
 
int getNumberOfDevices () const
 Returns the number of devices using this configuration. More...
 
const BindinggetBinding (int i) const
 Returns the binding of a given index. More...
 
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. More...
 

Static Public Member Functions

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

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. More...
 

Protected Attributes

Binding m_bindings [PA_COUNT]
 

Private Attributes

bool m_enabled
 If set to false, this device will be ignored. More...
 
int m_plugged
 How many devices connected to the system which uses this config?
 
std::string m_name
 Name of this configuratiom. More...
 

Friends

class GamePadDevice
 Those two classes need to be able to call getGameAction. More...
 
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.

◆ getBinding()

const Binding& DeviceConfig::getBinding ( int  i) const
inline

Returns the binding of a given index.

◆ 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

◆ getName()

const std::string& DeviceConfig::getName ( ) const
inline

Returns the name for this device configuration.

◆ 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.

◆ getNumberOfDevices()

int DeviceConfig::getNumberOfDevices ( ) const
inline

Returns the number of devices using this configuration.

◆ isAnalog()

virtual bool DeviceConfig::isAnalog ( ) 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.

◆ isPlugged()

bool DeviceConfig::isPlugged ( ) const
inline

Returns if this config is sed by any devices.

◆ 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 GamepadConfig, GamepadAndroidConfig, and KeyboardConfig.

◆ 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,
wchar_t  character = 0 
)

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.

◆ setEnabled()

void DeviceConfig::setEnabled ( bool  new_value)
inline

Sets this config to be enabled or disabled.

◆ setName()

void DeviceConfig::setName ( const std::string &  name)
inline

Sets the name of this device.

◆ setPlugged()

void DeviceConfig::setPlugged ( )
inline

Increase ref counter.

Friends And Related Function Documentation

◆ GamePadDevice

friend class GamePadDevice
friend

Those two classes need to be able to call getGameAction.

Member Data Documentation

◆ m_enabled

bool DeviceConfig::m_enabled
private

If set to false, this device will be ignored.

Currently for gamepads only.

◆ m_name

std::string DeviceConfig::m_name
private

Name of this configuratiom.


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