Robot Devastation
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
rd::SDLInputManager Class Reference

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

#include <SDLInputManager.hpp>

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

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 &parameter, 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 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 Public Attributes

static const std::string id = "SDL"
 String that identifies this manager.
 

Private Member Functions

 SDLInputManager ()
 Constructor. More...
 
 SDLInputManager (const SDLInputManager &)
 
SDLInputManageroperator= (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 SDLInputManageruniqueInstance = 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.
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ SDLInputManager()

rd::SDLInputManager::SDLInputManager ( )
private

Constructor for this class is private, since the singleton can only be instantiated once, and the instantiation is done at the RegisterManager() method.

Member Function Documentation

◆ refreshEvents()

bool rd::SDLInputManager::refreshEvents ( )
virtual

In SDL, this function has to be called frequently, and in the same thread as the graphic output.

Reimplemented from rd::InputManager.

◆ RegisterManager()

bool rd::SDLInputManager::RegisterManager ( )
static

It ensures that only one manager of this type is created (unique instance).

◆ start()

bool rd::SDLInputManager::start ( )
virtual

This function is supposed to be called after InputManager configuration.

Implements rd::InputManager.


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