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

Class to handle input. More...

#include <input_manager.hpp>

Inheritance diagram for InputManager:
Inheritance graph
[legend]

Public Types

enum  InputDriverMode {
  MENU = 0 , INGAME , INPUT_SENSE_KEYBOARD , INPUT_SENSE_GAMEPAD ,
  BOOTSTRAP
}
 

Public Member Functions

 InputManager ()
 Initialise input.
 
 ~InputManager ()
 Destructor.
 
GUIEngine::EventPropagation input (const irr::SEvent &event)
 Called on keyboard events [indirectly] by irrLicht.
 
DeviceManagergetDeviceManager ()
 
void setMode (InputDriverMode)
 Sets the mode of the input driver.
 
bool isInMode (InputDriverMode)
 Queries the input driver whether it is in the given expected mode.
 
InputDriverMode getMode ()
 
void setMasterPlayerOnly (bool enabled)
 When this mode is enabled, only the master player will be able to play with menus (only works in 'assign' mode)
 
bool masterPlayerOnly () const
 Returns whether only the master player should be allowed to perform changes in menus.
 
void update (float dt)
 
int getPlayerKeyboardID () const
 Returns the ID of the player that plays with the keyboard, or -1 if none.
 
size_t getGamepadCount () const
 Returns number of active connected gamepad (with SDL), notice the disconnected gamepad will not be removed from device manager to allow re-plugging later with the same ID.
 
const irr::SEvent & getEventForGamePad (unsigned i) const
 Returns irrlicht joystick for gamepad visualization.
 
void handleJoystick (SDL_Event &event)
 
SDLControllergetSDLController (unsigned i)
 
void dispatchInput (Input::InputType, int deviceID, int btnID, Input::AxisDirection direction, int value, bool shift_mask=false)
 Handles the conversion from some input to a GameAction and its distribution to the currently active menu.
 
void addJoystick ()
 

Public Attributes

std::map< int, float > m_gamepads_timer
 

Private Member Functions

void handleStaticAction (int id0, int value)
 
void inputSensing (Input::InputType type, int deviceID, int btnID, Input::AxisDirection axisDirection, int value)
 Handles input when an input sensing mode (when configuring input)
 

Private Attributes

DeviceManagerm_device_manager
 
std::set< std::tuple< int, int > > m_sensed_input_high_gamepad
 
std::set< int > m_sensed_input_high_kbd
 
std::set< int > m_sensed_input_zero_gamepad
 
InputDriverMode m_mode
 
bool m_master_player_only
 When at true, only the master player can play with menus.
 
int m_mouse_val_x
 
int m_mouse_val_y
 
std::map< int, std::unique_ptr< SDLController > > m_sdl_controller
 

Detailed Description

Class to handle input.

Constructor & Destructor Documentation

◆ ~InputManager()

InputManager::~InputManager ( )

Destructor.

Frees all data structures.

Member Function Documentation

◆ dispatchInput()

void InputManager::dispatchInput ( Input::InputType  type,
int  deviceID,
int  button,
Input::AxisDirection  axisDirection,
int  value,
bool  shift_mask = false 
)

Handles the conversion from some input to a GameAction and its distribution to the currently active menu.

It also handles whether the game is currently sensing input. It does so by suppressing the distribution of the input as a GameAction. Instead the input is stored in 'm_sensed_input' and GA_SENSE_COMPLETE is distributed. If however the input in question has resolved to GA_LEAVE this is treated as an attempt of the user to cancel the sensing. In that case GA_SENSE_CANCEL is distributed.

Note: It is the obligation of the called menu to switch of the sense mode.

◆ input()

EventPropagation InputManager::input ( const irr::SEvent &  event)

Called on keyboard events [indirectly] by irrLicht.

Analog axes can have any value from [-32768, 32767].

There are no negative values. Instead this is reported as an axis with a negative direction. This simplifies input configuration and allows greater flexibility (= treat 4 directions as four buttons).

Returns whether to halt the event's propagation here

◆ setMode()

void InputManager::setMode ( InputDriverMode  new_mode)

Sets the mode of the input driver.

Switching of the input driver's modes is only needed for special menus (those who need typing or input sensing) and the MenuManager (switch to ingame/menu mode). Therefore there is a limited amount of legal combinations of current and next input driver modes: From the menu mode you can switch to any other mode and from any other mode only back to the menu mode.

In input sense mode the pointer is invisible (any movement reports are suppressed). If an input happens it is stored internally and can be retrieved through drv_getm_sensed_input() after GA_SENSE_COMPLETE has been distributed to a menu (Normally the menu that received GA_SENSE_COMPLETE will request the sensed input ...). If GA_SENSE_CANCEL is received instead the user decided to cancel input sensing. No other game action values are distributed in this mode.

And there is the bootstrap mode. You cannot switch to it and only leave it once per application instance. It is the state the input driver is first.


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