Robot Devastation
|
User input manager (keyboard, mouse, joysticks, etc) using SDL. More...
#include <SDLInputManager.hpp>
Public Member Functions | |
virtual bool | start () |
Start to capture input events. More... | |
virtual bool | stop () |
Stop capturing input events. | |
virtual bool | isStopped () const |
True if the manager is not active. | |
virtual bool | configure (const std::string ¶meter, const std::string &value) |
Configures a parameter with a value. | |
~SDLInputManager () | |
Destructor. Used to reset the local static reference after destroying this manager. | |
virtual bool | refreshEvents () |
Get SDL info about input events. More... | |
Public Member Functions inherited from rd::InputManager | |
bool | addInputEventListener (InputEventListener *listener) |
Adds a InputEventListener to the list of observers to be notified of events. | |
bool | removeInputEventListeners () |
Unregisters all the InputEventListener stored. | |
Static Public Member Functions | |
static bool | RegisterManager () |
Register this manager in the InputManager registry so that can be used. More... | |
Static Public Member Functions inherited from rd::InputManager | |
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 Public Attributes | |
static const std::string | id = "SDL" |
String that identifies this manager. | |
Private Member Functions | |
SDLInputManager () | |
Constructor. More... | |
SDLInputManager (const SDLInputManager &) | |
SDLInputManager & | operator= (const SDLInputManager &) |
bool | inputCallback (SDL_Event *event) |
Static Private Member Functions | |
static int | staticInputCallback (void *userdata, SDL_Event *event) |
Private Attributes | |
bool | stopped |
Static Private Attributes | |
static SDLInputManager * | uniqueInstance = NULL |
Reference to this manager (unique instance) | |
Additional Inherited Members | |
Static Protected Member Functions inherited from rd::InputManager | |
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 inherited from rd::InputManager | |
std::vector< InputEventListener * > | listeners |
Observers registered to be notified of input events. | |
SDLInputManager 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 SDLInputManager can be deallocated using destroyInputManager().
SDLInputManager 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).
|
private |
Constructor for this class is private, since the singleton can only be instantiated once, and the instantiation is done at the RegisterManager() method.
|
virtual |
In SDL, this function has to be called frequently, and in the same thread as the graphic output.
Reimplemented from rd::InputManager.
|
static |
It ensures that only one manager of this type is created (unique instance).
|
virtual |
This function is supposed to be called after InputManager configuration.
Implements rd::InputManager.