SuperTuxKart
|
This class holds the list of all known devices (ands their configurations), as well as the list of currently plugged (used) devices. More...
#include <device_manager.hpp>
Public Member Functions | |
PlayerAssignMode | getAssignMode () const |
void | setAssignMode (const PlayerAssignMode assignMode) |
void | addGamepad (GamePadDevice *d) |
int | getGamePadAmount () const |
int | getGamePadConfigAmount () const |
GamePadDevice * | getGamePad (const int i) |
GamepadConfig * | getGamepadConfig (const int i) |
GamePadDevice * | getGamePadFromIrrID (const int i) |
void | clearGamepads () |
bool | getConfigForGamepad (const int sdl_id, const std::string &name, GamepadConfig **config) |
Returns the keyboard that has a binding for this button, or NULL if none. | |
void | addEmptyKeyboard () |
void | addKeyboard (KeyboardDevice *d) |
void | clearKeyboard () |
int | getKeyboardAmount () |
int | getActiveKeyboardAmount () |
int | getKeyboardConfigAmount () const |
KeyboardDevice * | getKeyboard (const int i) |
KeyboardConfig * | getKeyboardConfig (const int i) |
KeyboardDevice * | getKeyboardFromBtnID (const int btnID) |
MultitouchDevice * | getMultitouchDevice () |
void | clearMultitouchDevices () |
void | updateMultitouchDevice () |
bool | deleteConfig (DeviceConfig *config) |
Delete the given config and removes DeviceManager references to it. | |
bool | translateInput (Input::InputType type, int deviceID, int btnID, int axisDir, int *value, InputManager::InputDriverMode mode, StateManager::ActivePlayer **player, PlayerAction *action) |
Given some input, finds to which device it belongs and, using the corresponding device object, maps this input to the corresponding player and game action. | |
void | clearLatestUsedDevice () |
InputDevice * | getLatestUsedDevice () |
bool | initialize () |
void | save () |
StateManager::ActivePlayer * | getSinglePlayer () |
Returns the active player if there is only a single local player. | |
void | setSinglePlayer (StateManager::ActivePlayer *p) |
Sets the ActivePlayer if there is only a single local player. | |
void | mapFireToSelect (bool v) |
Sets or reset the 'map fire to select' option. | |
Private Member Functions | |
InputDevice * | mapGamepadInput (Input::InputType type, int deviceID, int btnID, int axisDir, int *value, InputManager::InputDriverMode mode, StateManager::ActivePlayer **player, PlayerAction *action) |
Helper method, only used internally. | |
InputDevice * | mapKeyboardInput (int button_id, InputManager::InputDriverMode mode, StateManager::ActivePlayer **player, PlayerAction *action) |
Helper method, only used internally. | |
bool | load () |
Loads the configuration from the user's input.xml file. | |
void | shutdown () |
Private Attributes | |
PtrVector< KeyboardDevice, HOLD > | m_keyboards |
PtrVector< GamePadDevice, HOLD > | m_gamepads |
PtrVector< KeyboardConfig, HOLD > | m_keyboard_configs |
PtrVector< GamepadConfig, HOLD > | m_gamepad_configs |
MultitouchDevice * | m_multitouch_device |
InputDevice * | m_latest_used_device |
PlayerAssignMode | m_assign_mode |
StateManager::ActivePlayer * | m_single_player |
Will be non-null in single-player mode. | |
bool | m_map_fire_to_select |
If this is flag is set the next fire event (if the fire key is not mapped to anything else) will be mapped to 'select'. | |
This class holds the list of all known devices (ands their configurations), as well as the list of currently plugged (used) devices.
It thus takes care of finding to which device any given input belongs, and what action each keypress is bound to, if any (and, since each device is associated to a player, it also finds which player triggered this action) These input mapping capabilities should only be used through the InputManager, not directly.
The device manager starts in "no-assign" mode, which means no input configuration is associated to any player. So all devices will react. This is used in menus before player set-up is done. Switching back to no-assign mode will also clear anything in devices that was associated with players in assign mode.
bool DeviceManager::getConfigForGamepad | ( | const int | irr_id, |
const std::string & | name, | ||
GamepadConfig ** | config | ||
) |
Returns the keyboard that has a binding for this button, or NULL if none.
Check if we already have a config object for gamepad 'irr_id' as reported by irrLicht, If no, create one.
Returns true if new configuration was created, otherwise false.
|
inline |
Returns the active player if there is only a single local player.
It returns NULL if multiplayer is active.
|
private |
Helper method, only used internally.
Takes care of analyzing gamepad input.
[in] | type | Type of gamepad event (IT_STICKMOTION etc). |
[out] | player | Which player this input belongs to (only set in ASSIGN mode) |
[out] | action | Which action is related to this input trigger |
mode | Used to determine whether to determine menu actions or game actions |
|
private |
Helper method, only used internally.
Takes care of analyzing keyboard input.
[in] | button_id | Id of the key pressed. |
[in] | mode | Used to determine whether to determine menu actions or game actions |
[out] | player | Which player this input belongs to (only set in ASSIGN mode). |
[out] | action | Which action is related to this input trigger. |
|
inline |
Sets the ActivePlayer if there is only a single local player.
p must be NULL in case of splitscreen. A single player will receive events from all connected devices. This allows for example a single player to select a kart with the keyboard, but then use a gamepad for the actual racing. In splitscreen each player will only receive events from the device used to connect in the kart selection screen.
bool DeviceManager::translateInput | ( | Input::InputType | type, |
int | deviceID, | ||
int | btnID, | ||
int | axisDir, | ||
int * | value, | ||
InputManager::InputDriverMode | mode, | ||
StateManager::ActivePlayer ** | player, | ||
PlayerAction * | action | ||
) |
Given some input, finds to which device it belongs and, using the corresponding device object, maps this input to the corresponding player and game action.
mode | used to determine whether to map game actions or menu actions |
|
private |
If this is flag is set the next fire event (if the fire key is not mapped to anything else) will be mapped to 'select'.
This is used in the kart select GUI to support the old way of adding players by pressing fire.