Robot Devastation
|
User input manager (keyboard, mouse, joysticks, etc) More...
#include <InputManager.hpp>
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 ¶meter, const std::string &value) |
Configures a parameter with a value. | |
virtual bool | refreshEvents () |
Get system info about input events. | |
Static Public Member Functions | |
static InputManager * | getInputManager () |
Get a reference to the InputManager. More... | |
static InputManager * | getInputManager (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 InputManager * | inputManagerInstance = 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. | |
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).
|
static |
|
static |
|
pure virtual |
This function is supposed to be called after InputManager configuration.
Implemented in rd::MockInputManager, and rd::SDLInputManager.