Robot Devastation
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Private Attributes | List of all members
rd::InputManager Class Referenceabstract

User input manager (keyboard, mouse, joysticks, etc) More...

#include <InputManager.hpp>

Inheritance diagram for rd::InputManager:
rd::MockInputManager rd::SDLInputManager

Public Member Functions

virtual bool start ()=0
 Start to capture input events. More...
 
virtual bool stop ()=0
 Stop capturing input events.
 
virtual bool isStopped () const =0
 True if the manager is not active.
 
bool addInputEventListener (InputEventListener *listener)
 Adds a InputEventListener to the list of observers to be notified of events.
 
bool removeInputEventListeners ()
 Unregisters all the InputEventListener stored.
 
virtual bool configure (const std::string &parameter, const std::string &value)
 Configures a parameter with a value.
 
virtual bool refreshEvents ()
 Get system info about input events.
 

Static Public Member Functions

static InputManagergetInputManager ()
 Get a reference to the InputManager. More...
 
static InputManagergetInputManager (const std::string &id)
 Get a reference to the InputManager. More...
 
static bool destroyInputManager ()
 Deallocate all the registered InputManager.
 

Static Protected Member Functions

static bool Register (InputManager *manager, const std::string &id)
 This function allows subclasses to install their unique instances in the singleton register to be selected later by the user.
 

Protected Attributes

std::vector< InputEventListener * > listeners
 Observers registered to be notified of input events.
 

Static Private Attributes

static InputManagerinputManagerInstance = NULL
 Stores the unique instance of the InputManager.
 
static std::string currentId = ""
 Stores the id of the current unique instance used.
 
static std::map< std::string, InputManager * > inputManagerRegistry = std::map<std::string, rd::InputManager *>()
 Stores all the InputManager that have been registered.
 

Detailed Description

InputManager is a singleton text (only one instance of this object can exist, that is is shared by all the users). To use this class, we first get the reference to the InputManager with getInputManager() and then we access the manager with that reference.

When the program finishes, the InputManager can be deallocated using destroyInputManager().

InputManager acts as a façade, offering a unified interface to the different managers for the mouse, keyboard, etc.

Input events are broadcasted to the registered listeners, along with the data relevant to the event triggered (i.e. what key was pressed).

Member Function Documentation

◆ getInputManager() [1/2]

rd::InputManager * rd::InputManager::getInputManager ( )
static
Returns
By default, if no id is specified, this will return a reference to the first InputManager that it can find in the registry, or NULL if no InputManager was registered.

◆ getInputManager() [2/2]

rd::InputManager * rd::InputManager::getInputManager ( const std::string &  id)
static
Returns
The InputManager registered with the given id, NULL if the id is not found in the registry.

◆ start()

virtual bool rd::InputManager::start ( )
pure virtual

This function is supposed to be called after InputManager configuration.

Implemented in rd::MockInputManager, and rd::SDLInputManager.


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