FIFE
|
Event Manager manages all events related to FIFE. More...
#include <eventmanager.h>
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 | 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... | |
![]() | |
virtual | ~ICommandController () |
![]() | |
virtual | ~IKeyController () |
![]() | |
virtual | ~IMouseController () |
![]() | |
virtual | ~ISdlEventController () |
![]() | |
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) |
Event Manager manages all events related to FIFE.
Definition at line 66 of file eventmanager.h.
FIFE::EventManager::EventManager | ( | ) |
Constructor.
Definition at line 46 of file eventmanager.cpp.
|
virtual |
Destructor.
Definition at line 65 of file eventmanager.cpp.
|
virtual |
Adds a listener to the back of the listener deque Listener will be notified via the corresponding events.
listener | listener to add |
Implements FIFE::ICommandController.
Definition at line 78 of file eventmanager.cpp.
References m_pending_commandlisteners.
|
virtual |
Adds a listener to the front of the listener deque Listener will be notified via the corresponding events.
listener | listener to add |
Implements FIFE::ICommandController.
Definition at line 82 of file eventmanager.cpp.
References m_pending_commandlisteners.
|
virtual |
Adds a listener to the back of the listener deque Listener will be notified via the corresponding events.
listener | listener to add |
Implements FIFE::IKeyController.
Definition at line 90 of file eventmanager.cpp.
References m_pending_keylisteners.
|
virtual |
Adds a listener to the front of the listener deque Listener will be notified via the corresponding events.
listener | listener to add |
Implements FIFE::IKeyController.
Definition at line 94 of file eventmanager.cpp.
References m_pending_keylisteners_front.
|
virtual |
Adds a listener to the back of the listener deque Listener will be notified via the corresponding events.
listener | listener to add |
Implements FIFE::IMouseController.
Definition at line 102 of file eventmanager.cpp.
References m_pending_mouselisteners.
|
virtual |
Adds a listener to the front of the listener deque Listener will be notified via the corresponding events.
listener | listener to add |
Implements FIFE::IMouseController.
Definition at line 106 of file eventmanager.cpp.
References m_pending_mouselisteners.
|
virtual |
Adds a listener to the back of the listener deque Listener will be notified via the corresponding events.
listener | listener to add |
Implements FIFE::ISdlEventController.
Definition at line 114 of file eventmanager.cpp.
References m_pending_sdleventlisteners.
|
virtual |
Adds a listener to the front of the listener deque Listener will be notified via the corresponding events.
listener | listener to add |
Implements FIFE::ISdlEventController.
Definition at line 118 of file eventmanager.cpp.
References m_pending_sdleventlisteners.
|
private |
Definition at line 341 of file eventmanager.cpp.
Referenced by processEvents().
|
virtual |
Use this method to send command to command listeners.
command | command to dispatch |
Implements FIFE::ICommandController.
Definition at line 126 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().
|
private |
Definition at line 171 of file eventmanager.cpp.
References FIFE::KeyEvent::getType(), m_keylisteners, m_pending_keylisteners, m_pending_keylisteners_front, m_pending_kldeletions, FIFE::KeyEvent::PRESSED, and FIFE::KeyEvent::RELEASED.
Referenced by processKeyEvent().
|
private |
Definition at line 222 of file eventmanager.cpp.
References FIFE::MouseEvent::CLICKED, FIFE::MouseEvent::DRAGGED, FIFE::MouseEvent::ENTERED, FIFE::MouseEvent::EXITED, FIFE::MouseEvent::getType(), FIFE::MouseEvent::isConsumed(), m_mouselisteners, m_pending_mldeletions, m_pending_mouselisteners, m_pending_mouselisteners_front, FIFE::MouseEvent::MOVED, FIFE::MouseEvent::PRESSED, FIFE::MouseEvent::RELEASED, FIFE::MouseEvent::WHEEL_MOVED_DOWN, and FIFE::MouseEvent::WHEEL_MOVED_UP.
Referenced by processMouseEvent().
|
private |
Definition at line 297 of file eventmanager.cpp.
References m_pending_sdldeletions, m_pending_sdleventlisteners, m_pending_sdleventlisteners_front, and m_sdleventlisteners.
Referenced by processActiveEvent(), processKeyEvent(), and processMouseEvent().
|
private |
Definition at line 593 of file eventmanager.cpp.
References FIFE::_log, FL_WARN, FIFE::KeyEvent::PRESSED, FIFE::KeyEvent::RELEASED, FIFE::KeyEvent::setAltPressed(), FIFE::KeyEvent::setControlPressed(), FIFE::KeyEvent::setKey(), FIFE::KeyEvent::setMetaPressed(), FIFE::KeyEvent::setNumericPad(), FIFE::KeyEvent::setShiftPressed(), and FIFE::KeyEvent::setType().
Referenced by processKeyEvent().
|
private |
Definition at line 613 of file eventmanager.cpp.
References FIFE::Key::ALT_GR, FIFE::Key::LEFT_ALT, FIFE::Key::LEFT_CONTROL, FIFE::Key::LEFT_META, FIFE::Key::LEFT_SHIFT, m_keystatemap, FIFE::Key::RIGHT_ALT, FIFE::Key::RIGHT_CONTROL, FIFE::Key::RIGHT_META, FIFE::Key::RIGHT_SHIFT, FIFE::InputEvent::setAltPressed(), FIFE::InputEvent::setControlPressed(), FIFE::InputEvent::setMetaPressed(), and FIFE::InputEvent::setShiftPressed().
Referenced by processMouseEvent().
|
private |
Definition at line 544 of file eventmanager.cpp.
References FIFE::MouseEvent::DRAGGED, FIFE::MouseEvent::EMPTY, FIFE::MouseEvent::getType(), FIFE::MouseEvent::LEFT, m_mostrecentbtn, m_mousestate, m_warp, FIFE::MouseEvent::MIDDLE, FIFE::MouseEvent::MOVED, FIFE::MouseEvent::PRESSED, FIFE::MouseEvent::RELEASED, FIFE::MouseEvent::RIGHT, FIFE::MouseEvent::setButton(), FIFE::MouseEvent::setType(), FIFE::MouseEvent::setX(), FIFE::MouseEvent::setY(), FIFE::MouseEvent::UNKNOWN_BUTTON, FIFE::MouseEvent::WHEEL_MOVED_DOWN, and FIFE::MouseEvent::WHEEL_MOVED_UP.
Referenced by processMouseEvent().
|
virtual |
Gets the source type of this event.
Implements FIFE::IEventSource.
Definition at line 625 of file eventmanager.cpp.
References FIFE::ES_ENGINE.
float FIFE::EventManager::getMouseSensitivity | ( | ) | const |
Gets mouse sensitivity.
Definition at line 642 of file eventmanager.cpp.
References m_mousesensitivity.
bool FIFE::EventManager::isMouseAccelerationEnabled | ( | ) | const |
Returns if mouse acceleration is enabled or not.
Definition at line 650 of file eventmanager.cpp.
References m_acceleration.
|
private |
Definition at line 397 of file eventmanager.cpp.
References FIFE::CMD_APP_ICONIFIED, FIFE::CMD_APP_RESTORED, FIFE::CMD_INPUT_FOCUS_GAINED, FIFE::CMD_INPUT_FOCUS_LOST, FIFE::CMD_MOUSE_FOCUS_GAINED, FIFE::CMD_MOUSE_FOCUS_LOST, dispatchCommand(), dispatchSdlEvent(), m_enter, and FIFE::Command::setCommandType().
Referenced by processEvents().
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 358 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().
|
private |
Definition at line 441 of file eventmanager.cpp.
References dispatchKeyEvent(), dispatchSdlEvent(), fillKeyEvent(), FIFE::KeyEvent::getKey(), FIFE::KeyEvent::getType(), FIFE::Key::getValue(), FIFE::IKeyFilter::isFiltered(), FIFE::Key::isFunctionKey(), m_keyfilter, m_keystatemap, FIFE::KeyEvent::PRESSED, and FIFE::KeyEvent::setSource().
Referenced by processEvents().
|
private |
Definition at line 460 of file eventmanager.cpp.
References dispatchMouseEvent(), dispatchSdlEvent(), utf8::distance(), FIFE::Math< T >::Equal(), fillModifiers(), fillMouseEvent(), FIFE::RenderBackend::getArea(), FIFE::MouseEvent::getButton(), FIFE::RectType< T >::h, FIFE::DynamicSingleton< RenderBackend >::instance(), m_acceleration, m_enter, m_lastticks, m_mostrecentbtn, m_mousesensitivity, m_mousestate, m_oldvelocity, m_oldx, m_oldy, m_warp, FIFE::MouseEvent::setSource(), FIFE::Math< T >::Sqrt(), FIFE::RectType< T >::w, FIFE::RectType< T >::x, and FIFE::RectType< T >::y.
Referenced by processEvents().
|
virtual |
Removes an added listener from the controller.
Listener will not be notified anymore via the corresponding events
listener | listener to remove |
Implements FIFE::ICommandController.
Definition at line 86 of file eventmanager.cpp.
References m_pending_cldeletions.
|
virtual |
Removes an added listener from the controller.
Listener will not be notified anymore via the corresponding events
listener | listener to remove |
Implements FIFE::IKeyController.
Definition at line 98 of file eventmanager.cpp.
References m_pending_kldeletions.
|
virtual |
Removes an added listener from the controller.
Listener will not be notified anymore via the corresponding events
listener | listener to remove |
Implements FIFE::IMouseController.
Definition at line 110 of file eventmanager.cpp.
References m_pending_mldeletions.
|
virtual |
Removes an added listener from the controller.
Listener will not be notified anymore via the corresponding events
listener | listener to remove |
Implements FIFE::ISdlEventController.
Definition at line 122 of file eventmanager.cpp.
References m_pending_sdldeletions.
void FIFE::EventManager::setKeyFilter | ( | IKeyFilter * | keyFilter | ) |
Definition at line 629 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 646 of file eventmanager.cpp.
References m_acceleration.
Referenced by FIFE::Engine::init().
void FIFE::EventManager::setMouseSensitivity | ( | float | sensitivity | ) |
Sets mouse sensitivity The sensitivity is limited to the range -0.99 - 10.0.
Definition at line 633 of file eventmanager.cpp.
References m_mousesensitivity.
Referenced by FIFE::Engine::init().
|
private |
Definition at line 176 of file eventmanager.h.
Referenced by isMouseAccelerationEnabled(), processMouseEvent(), and setMouseAccelerationEnabled().
|
private |
Definition at line 147 of file eventmanager.h.
Referenced by dispatchCommand().
|
private |
Definition at line 178 of file eventmanager.h.
Referenced by processActiveEvent(), and processMouseEvent().
|
private |
Definition at line 168 of file eventmanager.h.
Referenced by processKeyEvent(), and setKeyFilter().
|
private |
Definition at line 152 of file eventmanager.h.
Referenced by dispatchKeyEvent().
|
private |
Definition at line 167 of file eventmanager.h.
Referenced by fillModifiers(), and processKeyEvent().
|
private |
Definition at line 181 of file eventmanager.h.
Referenced by processMouseEvent().
|
private |
Definition at line 170 of file eventmanager.h.
Referenced by fillMouseEvent(), and processMouseEvent().
|
private |
Definition at line 157 of file eventmanager.h.
Referenced by dispatchMouseEvent().
|
private |
Definition at line 175 of file eventmanager.h.
Referenced by getMouseSensitivity(), processMouseEvent(), and setMouseSensitivity().
|
private |
Definition at line 169 of file eventmanager.h.
Referenced by fillMouseEvent(), and processMouseEvent().
|
private |
Definition at line 182 of file eventmanager.h.
Referenced by processMouseEvent().
|
private |
Definition at line 179 of file eventmanager.h.
Referenced by processMouseEvent().
|
private |
Definition at line 180 of file eventmanager.h.
Referenced by processMouseEvent().
|
private |
Definition at line 150 of file eventmanager.h.
Referenced by dispatchCommand(), and removeCommandListener().
|
private |
Definition at line 148 of file eventmanager.h.
Referenced by addCommandListener(), addCommandListenerFront(), and dispatchCommand().
|
private |
Definition at line 149 of file eventmanager.h.
Referenced by dispatchCommand().
|
private |
Definition at line 153 of file eventmanager.h.
Referenced by addKeyListener(), and dispatchKeyEvent().
|
private |
Definition at line 154 of file eventmanager.h.
Referenced by addKeyListenerFront(), and dispatchKeyEvent().
|
private |
Definition at line 155 of file eventmanager.h.
Referenced by dispatchKeyEvent(), and removeKeyListener().
|
private |
Definition at line 160 of file eventmanager.h.
Referenced by dispatchMouseEvent(), and removeMouseListener().
|
private |
Definition at line 158 of file eventmanager.h.
Referenced by addMouseListener(), addMouseListenerFront(), and dispatchMouseEvent().
|
private |
Definition at line 159 of file eventmanager.h.
Referenced by dispatchMouseEvent().
|
private |
Definition at line 165 of file eventmanager.h.
Referenced by dispatchSdlEvent(), and removeSdlEventListener().
|
private |
Definition at line 163 of file eventmanager.h.
Referenced by addSdlEventListener(), addSdlEventListenerFront(), and dispatchSdlEvent().
|
private |
Definition at line 164 of file eventmanager.h.
Referenced by dispatchSdlEvent().
|
private |
Definition at line 162 of file eventmanager.h.
Referenced by dispatchSdlEvent().
|
private |
Definition at line 177 of file eventmanager.h.
Referenced by fillMouseEvent(), and processMouseEvent().