FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FIFE::EventManager Class Reference

Event Manager manages all events related to FIFE. More...

#include <eventmanager.h>

+ Inheritance diagram for FIFE::EventManager:
+ Collaboration diagram for FIFE::EventManager:

Public Member Functions

 EventManager ()
 Constructor. More...
 
virtual ~EventManager ()
 Destructor. More...
 
void addCommandListener (ICommandListener *listener)
 Adds a listener to the back of the listener deque Listener will be notified via the corresponding events. More...
 
void addCommandListenerFront (ICommandListener *listener)
 Adds a listener to the front of the listener deque Listener will be notified via the corresponding events. More...
 
void removeCommandListener (ICommandListener *listener)
 Removes an added listener from the controller. More...
 
void dispatchCommand (Command &command)
 Use this method to send command to command listeners. More...
 
void addKeyListener (IKeyListener *listener)
 Adds a listener to the back of the listener deque Listener will be notified via the corresponding events. More...
 
void addKeyListenerFront (IKeyListener *listener)
 Adds a listener to the front of the listener deque Listener will be notified via the corresponding events. More...
 
void removeKeyListener (IKeyListener *listener)
 Removes an added listener from the controller. More...
 
void addMouseListener (IMouseListener *listener)
 Adds a listener to the back of the listener deque Listener will be notified via the corresponding events. More...
 
void addMouseListenerFront (IMouseListener *listener)
 Adds a listener to the front of the listener deque Listener will be notified via the corresponding events. More...
 
void removeMouseListener (IMouseListener *listener)
 Removes an added listener from the controller. More...
 
void addSdlEventListener (ISdlEventListener *listener)
 Adds a listener to the back of the listener deque Listener will be notified via the corresponding events. More...
 
void addSdlEventListenerFront (ISdlEventListener *listener)
 Adds a listener to the front of the listener deque Listener will be notified via the corresponding events. More...
 
void removeSdlEventListener (ISdlEventListener *listener)
 Removes an added listener from the controller. More...
 
EventSourceType getEventSourceType ()
 Gets the source type of this event. More...
 
void processEvents ()
 Process the SDL event queue. More...
 
void setKeyFilter (IKeyFilter *keyFilter)
 
void setMouseFilter (IMouseFilter *mouseFilter)
 
void setMouseSensitivity (float sensitivity)
 Sets mouse sensitivity The sensitivity is limited to the range -0.99 - 10.0. More...
 
float getMouseSensitivity () const
 Gets mouse sensitivity. More...
 
void setMouseAccelerationEnabled (bool acceleration)
 Sets mouse acceleration if mouse acceleration is enabled, then the mouse sensitivity is used as speed max. More...
 
bool isMouseAccelerationEnabled () const
 Returns if mouse acceleration is enabled or not. More...
 
- Public Member Functions inherited from FIFE::ICommandController
virtual ~ICommandController ()
 
- Public Member Functions inherited from FIFE::IKeyController
virtual ~IKeyController ()
 
- Public Member Functions inherited from FIFE::IMouseController
virtual ~IMouseController ()
 
- Public Member Functions inherited from FIFE::ISdlEventController
virtual ~ISdlEventController ()
 
- Public Member Functions inherited from FIFE::IEventSource
virtual ~IEventSource ()
 

Private Member Functions

void processActiveEvent (SDL_Event event)
 
void processKeyEvent (SDL_Event event)
 
void processMouseEvent (SDL_Event event)
 
bool combineEvents (SDL_Event &event1, const SDL_Event &event2)
 
bool dispatchSdlEvent (SDL_Event &evt)
 
void dispatchKeyEvent (KeyEvent &evt)
 
void dispatchMouseEvent (MouseEvent &evt)
 
void fillModifiers (InputEvent &evt)
 
void fillKeyEvent (const SDL_Event &sdlevt, KeyEvent &keyevt)
 
void fillMouseEvent (const SDL_Event &sdlevt, MouseEvent &mouseevt)
 

Private Attributes

std::deque< ICommandListener * > m_commandlisteners
 
std::deque< ICommandListener * > m_pending_commandlisteners
 
std::deque< ICommandListener * > m_pending_commandlisteners_front
 
std::deque< ICommandListener * > m_pending_cldeletions
 
std::deque< IKeyListener * > m_keylisteners
 
std::deque< IKeyListener * > m_pending_keylisteners
 
std::deque< IKeyListener * > m_pending_keylisteners_front
 
std::deque< IKeyListener * > m_pending_kldeletions
 
std::deque< IMouseListener * > m_mouselisteners
 
std::deque< IMouseListener * > m_pending_mouselisteners
 
std::deque< IMouseListener * > m_pending_mouselisteners_front
 
std::deque< IMouseListener * > m_pending_mldeletions
 
std::deque< ISdlEventListener * > m_sdleventlisteners
 
std::deque< ISdlEventListener * > m_pending_sdleventlisteners
 
std::deque< ISdlEventListener * > m_pending_sdleventlisteners_front
 
std::deque< ISdlEventListener * > m_pending_sdldeletions
 
std::map< int32_t, bool > m_keystatemap
 
IKeyFilterm_keyfilter
 
IMouseFilterm_mousefilter
 
int32_t m_mousestate
 
MouseEvent::MouseButtonType m_mostrecentbtn
 
float m_mousesensitivity
 
bool m_acceleration
 
bool m_warp
 
bool m_enter
 
uint16_t m_oldx
 
uint16_t m_oldy
 
uint32_t m_lastticks
 
float m_oldvelocity
 

Detailed Description

Event Manager manages all events related to FIFE.

Definition at line 67 of file eventmanager.h.

Constructor & Destructor Documentation

FIFE::EventManager::EventManager ( )

Constructor.

Definition at line 47 of file eventmanager.cpp.

FIFE::EventManager::~EventManager ( )
virtual

Destructor.

Definition at line 67 of file eventmanager.cpp.

Member Function Documentation

void FIFE::EventManager::addCommandListener ( ICommandListener listener)
virtual

Adds a listener to the back of the listener deque Listener will be notified via the corresponding events.

Parameters
listenerlistener to add

Implements FIFE::ICommandController.

Definition at line 80 of file eventmanager.cpp.

References m_pending_commandlisteners.

void FIFE::EventManager::addCommandListenerFront ( ICommandListener listener)
virtual

Adds a listener to the front of the listener deque Listener will be notified via the corresponding events.

Parameters
listenerlistener to add

Implements FIFE::ICommandController.

Definition at line 84 of file eventmanager.cpp.

References m_pending_commandlisteners_front.

void FIFE::EventManager::addKeyListener ( IKeyListener listener)
virtual

Adds a listener to the back of the listener deque Listener will be notified via the corresponding events.

Parameters
listenerlistener to add

Implements FIFE::IKeyController.

Definition at line 92 of file eventmanager.cpp.

References m_pending_keylisteners.

void FIFE::EventManager::addKeyListenerFront ( IKeyListener listener)
virtual

Adds a listener to the front of the listener deque Listener will be notified via the corresponding events.

Parameters
listenerlistener to add

Implements FIFE::IKeyController.

Definition at line 96 of file eventmanager.cpp.

References m_pending_keylisteners_front.

void FIFE::EventManager::addMouseListener ( IMouseListener listener)
virtual

Adds a listener to the back of the listener deque Listener will be notified via the corresponding events.

Parameters
listenerlistener to add

Implements FIFE::IMouseController.

Definition at line 104 of file eventmanager.cpp.

References m_pending_mouselisteners.

void FIFE::EventManager::addMouseListenerFront ( IMouseListener listener)
virtual

Adds a listener to the front of the listener deque Listener will be notified via the corresponding events.

Parameters
listenerlistener to add

Implements FIFE::IMouseController.

Definition at line 108 of file eventmanager.cpp.

References m_pending_mouselisteners_front.

void FIFE::EventManager::addSdlEventListener ( ISdlEventListener listener)
virtual

Adds a listener to the back of the listener deque Listener will be notified via the corresponding events.

Parameters
listenerlistener to add

Implements FIFE::ISdlEventController.

Definition at line 116 of file eventmanager.cpp.

References m_pending_sdleventlisteners.

void FIFE::EventManager::addSdlEventListenerFront ( ISdlEventListener listener)
virtual

Adds a listener to the front of the listener deque Listener will be notified via the corresponding events.

Parameters
listenerlistener to add

Implements FIFE::ISdlEventController.

Definition at line 120 of file eventmanager.cpp.

References m_pending_sdleventlisteners_front.

bool FIFE::EventManager::combineEvents ( SDL_Event &  event1,
const SDL_Event &  event2 
)
private

Definition at line 343 of file eventmanager.cpp.

Referenced by processEvents().

+ Here is the caller graph for this function:

void FIFE::EventManager::dispatchCommand ( Command command)
virtual

Use this method to send command to command listeners.

Parameters
commandcommand to dispatch

Implements FIFE::ICommandController.

Definition at line 128 of file eventmanager.cpp.

References FIFE::Command::isConsumed(), m_commandlisteners, m_pending_cldeletions, m_pending_commandlisteners, and m_pending_commandlisteners_front.

Referenced by processActiveEvent(), and processEvents().

+ Here is the caller graph for this function:

void FIFE::EventManager::dispatchKeyEvent ( KeyEvent evt)
private
bool FIFE::EventManager::dispatchSdlEvent ( SDL_Event &  evt)
private

Definition at line 299 of file eventmanager.cpp.

References m_pending_sdldeletions, m_pending_sdleventlisteners, m_pending_sdleventlisteners_front, and m_sdleventlisteners.

Referenced by processActiveEvent(), processKeyEvent(), and processMouseEvent().

+ Here is the caller graph for this function:

void FIFE::EventManager::fillKeyEvent ( const SDL_Event &  sdlevt,
KeyEvent keyevt 
)
private
EventSourceType FIFE::EventManager::getEventSourceType ( )
virtual

Gets the source type of this event.

Returns
source type of this event

Implements FIFE::IEventSource.

Definition at line 631 of file eventmanager.cpp.

References FIFE::ES_ENGINE.

float FIFE::EventManager::getMouseSensitivity ( ) const

Gets mouse sensitivity.

Definition at line 652 of file eventmanager.cpp.

References m_mousesensitivity.

bool FIFE::EventManager::isMouseAccelerationEnabled ( ) const

Returns if mouse acceleration is enabled or not.

Returns
True if mouse acceleration is enabled, false if not.

Definition at line 660 of file eventmanager.cpp.

References m_acceleration.

void FIFE::EventManager::processActiveEvent ( SDL_Event  event)
private
void FIFE::EventManager::processEvents ( )

Process the SDL event queue.

This is to be called only by the engine itself once per frame. It passes appropriate events to their listeners

Definition at line 360 of file eventmanager.cpp.

References FIFE::CMD_QUIT_GAME, combineEvents(), dispatchCommand(), processActiveEvent(), processKeyEvent(), processMouseEvent(), FIFE::Command::setCommandType(), and FIFE::Command::setSource().

Referenced by FIFE::Engine::initializePumping(), and FIFE::Engine::pump().

+ Here is the caller graph for this function:

void FIFE::EventManager::processKeyEvent ( SDL_Event  event)
private
void FIFE::EventManager::removeCommandListener ( ICommandListener listener)
virtual

Removes an added listener from the controller.

Listener will not be notified anymore via the corresponding events

Parameters
listenerlistener to remove

Implements FIFE::ICommandController.

Definition at line 88 of file eventmanager.cpp.

References m_pending_cldeletions.

void FIFE::EventManager::removeKeyListener ( IKeyListener listener)
virtual

Removes an added listener from the controller.

Listener will not be notified anymore via the corresponding events

Parameters
listenerlistener to remove

Implements FIFE::IKeyController.

Definition at line 100 of file eventmanager.cpp.

References m_pending_kldeletions.

void FIFE::EventManager::removeMouseListener ( IMouseListener listener)
virtual

Removes an added listener from the controller.

Listener will not be notified anymore via the corresponding events

Parameters
listenerlistener to remove

Implements FIFE::IMouseController.

Definition at line 112 of file eventmanager.cpp.

References m_pending_mldeletions.

void FIFE::EventManager::removeSdlEventListener ( ISdlEventListener listener)
virtual

Removes an added listener from the controller.

Listener will not be notified anymore via the corresponding events

Parameters
listenerlistener to remove

Implements FIFE::ISdlEventController.

Definition at line 124 of file eventmanager.cpp.

References m_pending_sdldeletions.

void FIFE::EventManager::setKeyFilter ( IKeyFilter keyFilter)

Definition at line 635 of file eventmanager.cpp.

References m_keyfilter.

void FIFE::EventManager::setMouseAccelerationEnabled ( bool  acceleration)

Sets mouse acceleration if mouse acceleration is enabled, then the mouse sensitivity is used as speed max.

Definition at line 656 of file eventmanager.cpp.

References m_acceleration.

Referenced by FIFE::Engine::init().

+ Here is the caller graph for this function:

void FIFE::EventManager::setMouseFilter ( IMouseFilter mouseFilter)

Definition at line 639 of file eventmanager.cpp.

References m_mousefilter.

void FIFE::EventManager::setMouseSensitivity ( float  sensitivity)

Sets mouse sensitivity The sensitivity is limited to the range -0.99 - 10.0.

Definition at line 643 of file eventmanager.cpp.

References m_mousesensitivity.

Referenced by FIFE::Engine::init().

+ Here is the caller graph for this function:

Member Data Documentation

bool FIFE::EventManager::m_acceleration
private
std::deque<ICommandListener*> FIFE::EventManager::m_commandlisteners
private

Definition at line 150 of file eventmanager.h.

Referenced by dispatchCommand().

bool FIFE::EventManager::m_enter
private

Definition at line 182 of file eventmanager.h.

Referenced by processActiveEvent(), and processMouseEvent().

IKeyFilter* FIFE::EventManager::m_keyfilter
private

Definition at line 171 of file eventmanager.h.

Referenced by processKeyEvent(), and setKeyFilter().

std::deque<IKeyListener*> FIFE::EventManager::m_keylisteners
private

Definition at line 155 of file eventmanager.h.

Referenced by dispatchKeyEvent().

std::map<int32_t, bool> FIFE::EventManager::m_keystatemap
private

Definition at line 170 of file eventmanager.h.

Referenced by fillModifiers(), and processKeyEvent().

uint32_t FIFE::EventManager::m_lastticks
private

Definition at line 185 of file eventmanager.h.

Referenced by processMouseEvent().

MouseEvent::MouseButtonType FIFE::EventManager::m_mostrecentbtn
private

Definition at line 174 of file eventmanager.h.

Referenced by fillMouseEvent(), and processMouseEvent().

IMouseFilter* FIFE::EventManager::m_mousefilter
private

Definition at line 172 of file eventmanager.h.

Referenced by processMouseEvent(), and setMouseFilter().

std::deque<IMouseListener*> FIFE::EventManager::m_mouselisteners
private

Definition at line 160 of file eventmanager.h.

Referenced by dispatchMouseEvent().

float FIFE::EventManager::m_mousesensitivity
private

Definition at line 179 of file eventmanager.h.

Referenced by getMouseSensitivity(), processMouseEvent(), and setMouseSensitivity().

int32_t FIFE::EventManager::m_mousestate
private

Definition at line 173 of file eventmanager.h.

Referenced by fillMouseEvent(), and processMouseEvent().

float FIFE::EventManager::m_oldvelocity
private

Definition at line 186 of file eventmanager.h.

Referenced by processMouseEvent().

uint16_t FIFE::EventManager::m_oldx
private

Definition at line 183 of file eventmanager.h.

Referenced by processMouseEvent().

uint16_t FIFE::EventManager::m_oldy
private

Definition at line 184 of file eventmanager.h.

Referenced by processMouseEvent().

std::deque<ICommandListener*> FIFE::EventManager::m_pending_cldeletions
private

Definition at line 153 of file eventmanager.h.

Referenced by dispatchCommand(), and removeCommandListener().

std::deque<ICommandListener*> FIFE::EventManager::m_pending_commandlisteners
private

Definition at line 151 of file eventmanager.h.

Referenced by addCommandListener(), and dispatchCommand().

std::deque<ICommandListener*> FIFE::EventManager::m_pending_commandlisteners_front
private

Definition at line 152 of file eventmanager.h.

Referenced by addCommandListenerFront(), and dispatchCommand().

std::deque<IKeyListener*> FIFE::EventManager::m_pending_keylisteners
private

Definition at line 156 of file eventmanager.h.

Referenced by addKeyListener(), and dispatchKeyEvent().

std::deque<IKeyListener*> FIFE::EventManager::m_pending_keylisteners_front
private

Definition at line 157 of file eventmanager.h.

Referenced by addKeyListenerFront(), and dispatchKeyEvent().

std::deque<IKeyListener*> FIFE::EventManager::m_pending_kldeletions
private

Definition at line 158 of file eventmanager.h.

Referenced by dispatchKeyEvent(), and removeKeyListener().

std::deque<IMouseListener*> FIFE::EventManager::m_pending_mldeletions
private

Definition at line 163 of file eventmanager.h.

Referenced by dispatchMouseEvent(), and removeMouseListener().

std::deque<IMouseListener*> FIFE::EventManager::m_pending_mouselisteners
private

Definition at line 161 of file eventmanager.h.

Referenced by addMouseListener(), and dispatchMouseEvent().

std::deque<IMouseListener*> FIFE::EventManager::m_pending_mouselisteners_front
private

Definition at line 162 of file eventmanager.h.

Referenced by addMouseListenerFront(), and dispatchMouseEvent().

std::deque<ISdlEventListener*> FIFE::EventManager::m_pending_sdldeletions
private

Definition at line 168 of file eventmanager.h.

Referenced by dispatchSdlEvent(), and removeSdlEventListener().

std::deque<ISdlEventListener*> FIFE::EventManager::m_pending_sdleventlisteners
private

Definition at line 166 of file eventmanager.h.

Referenced by addSdlEventListener(), and dispatchSdlEvent().

std::deque<ISdlEventListener*> FIFE::EventManager::m_pending_sdleventlisteners_front
private

Definition at line 167 of file eventmanager.h.

Referenced by addSdlEventListenerFront(), and dispatchSdlEvent().

std::deque<ISdlEventListener*> FIFE::EventManager::m_sdleventlisteners
private

Definition at line 165 of file eventmanager.h.

Referenced by dispatchSdlEvent().

bool FIFE::EventManager::m_warp
private

Definition at line 181 of file eventmanager.h.

Referenced by fillMouseEvent(), and processMouseEvent().


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