Annwvyn::AnnEventManager Class Reference

Event Manager : Object that handle the event system. More...

#include <AnnEventManager.hpp>

Inheritance diagram for Annwvyn::AnnEventManager:
Collaboration diagram for Annwvyn::AnnEventManager:

Public Member Functions

 AnnEventManager (Ogre::RenderWindow *w)
 Construct the event manager. More...
 
 ~AnnEventManager ()
 Destroy the event manager. More...
 
void useDefaultEventListener ()
 
AnnEventListenerPtr getDefaultEventListener () const
 Return the default event listener. More...
 
void addListener (AnnEventListenerPtr listener)
 
template<class ListenerType , class... Args>
decltype(auto) addListener (Args &&... args)
 Utility class to construct-add a listener to the event manager. More...
 
void clearListenerList ()
 
void removeListener (AnnEventListenerPtr listener=nullptr)
 
AnnTimerID fireTimer (double delay)
 Create a timer that will timeout after "delay" seconds. More...
 
AnnTimerID fireTimerMillisec (double millisecDelay)
 Create a timer that will timeout after "delay" milliseconds. More...
 
size_t getControllerCount () const
 Get the number of available sticks. More...
 
AnnTextInputergetTextInputer () const
 Get the text inputer object. More...
 
void keyboardUsedForText (bool state=true)
 set the "shouldIgnore" flag to keyboard event More...
 
OIS::InputManager * _getOISInputManager () const
 
- Public Member Functions inherited from Annwvyn::AnnSubSystem
 AnnSubSystem (const std::string &systemName)
 Construct a SubSystem. More...
 
virtual ~AnnSubSystem ()
 Destruct a SubSystem. More...
 

Private Member Functions

void userSpaceDispatchEvent (AnnUserSpaceEventPtr e, AnnUserSpaceEventLauncher *sender)
 Send the given event to the listeners. More...
 
void update () override
 Engine call for refreshing the event system. More...
 
void captureEvents ()
 Capture the event from OIS. More...
 
void processKeyboardEvents ()
 Process keyboard events. More...
 
void processMouseEvents ()
 Process mouse events. More...
 
void processJoystickEvents ()
 Process joystick events. More...
 
void processHandControllerEvents ()
 Process hand controller events. More...
 
void pushEventsToListeners ()
 Set the content of the event buffers to all registered listeners. More...
 
void processInput ()
 Process user inputs. More...
 
void processTimers ()
 Process timers. More...
 
void processTriggerEvents ()
 Process triggers. More...
 
void processCollisionEvents ()
 Process collisions. More...
 
void processUserSpaceEvents ()
 Process user event dispatch() More...
 
void detectedCollision (void *a, void *b, AnnVect3 worldPosition, AnnVect3 normalOnB)
 Hook for the physics engine to signal collisions. More...
 
void playerCollision (void *object)
 Hook for the physics engine to signal player collision. More...
 

Private Attributes

std::vector< AnnEventListenerWeakPtrlisteners
 
std::vector< AnnKeyEventkeyEventBuffer
 Buffer of keyboard events. More...
 
std::vector< AnnMouseEventmouseEventBuffer
 Buffer of mouse events. More...
 
std::vector< AnnControllerEventstickEventBuffer
 Buffer of stick events. More...
 
std::vector< AnnHandControllerEventhandControllerEventBuffer
 Buffer of hand controller events. More...
 
OIS::InputManager * InputManager
 OIS Event Manager. More...
 
OIS::Keyboard * Keyboard
 Pointer that holds the keyboard. More...
 
OIS::Mouse * Mouse
 Pointer that holds the Mouse. More...
 
std::vector< AnnControllerBufferJoysticks
 Array of poiners to OIS Joystick. More...
 
std::array< bool, KeyCode::SIZEpreviousKeyStates
 Array for remembering the key states at last update. More...
 
std::array< bool, ButtonCountpreviousMouseButtonStates
 Array for remembering the button states at last update. More...
 
AnnTimerID lastTimerCreated
 Dynamically sized array for remembering the joystick button state at last update. More...
 
std::vector< AnnTimeractiveTimers
 List of timers. More...
 
std::vector< AnnTimerfutureTimers
 List of timer that will timeout in a future frame. More...
 
std::vector< AnnTriggerEventtriggerEventBuffer
 List of trigger event to process. More...
 
std::vector< std::tuple< void *, void *, AnnVect3, AnnVect3 > > collisionBuffers
 Collision reported by the physics engine to consider. More...
 
std::vector< AnnGameObject * > playerCollisionBuffer
 Player collision reported by the physics engine to consider. More...
 
std::unique_ptr< AnnTextInputertextInputer
 The text inputer object itself. More...
 
std::shared_ptr< AnnDefaultEventListenerdefaultEventListener
 Default event listener. More...
 
std::vector< std::pair< AnnUserSpaceEventPtr, AnnUserSpaceEventLauncher * > > userSpaceEventBuffer
 Using a shared ptr to keep ownership of the event object until the event is dealt with. Also, polymorphism. More...
 
ControllerID xboxID
 ID of an eventual Xbox controller. More...
 
bool knowXbox
 True if we detected an xbox controller. More...
 
bool keyboardIgnore
 True if keyboard event should be ignored (keyboard used for "text input") More...
 

Friends

class AnnEngine
 
class AnnPhysicsEngine
 
class AnnUserSpaceEventLauncher
 

Additional Inherited Members

- Protected Member Functions inherited from Annwvyn::AnnSubSystem
virtual bool needUpdate ()
 To be called by AnnEngine : Return if the subsystem wants to be updated. More...
 
- Protected Attributes inherited from Annwvyn::AnnSubSystem
std::string name
 Name of the subsystem. More...
 

Detailed Description

Event Manager : Object that handle the event system.

Definition at line 44 of file AnnEventManager.hpp.

Constructor & Destructor Documentation

◆ AnnEventManager()

AnnEventManager::AnnEventManager ( Ogre::RenderWindow *  w)

Construct the event manager.

Definition at line 16 of file AnnEventManager.cpp.

◆ ~AnnEventManager()

AnnEventManager::~AnnEventManager ( )

Destroy the event manager.

Definition at line 77 of file AnnEventManager.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ _getOISInputManager()

OIS::InputManager * AnnEventManager::_getOISInputManager ( ) const

Definition at line 403 of file AnnEventManager.cpp.

◆ addListener() [1/2]

void AnnEventManager::addListener ( AnnEventListenerPtr  listener)

Add a listener to the event manager

Parameters
listenerPointer to a listener object

Definition at line 111 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ addListener() [2/2]

template<class ListenerType , class... Args>
decltype(auto) Annwvyn::AnnEventManager::addListener ( Args &&...  args)
inline

Utility class to construct-add a listener to the event manager.

Definition at line 69 of file AnnEventManager.hpp.

◆ captureEvents()

void AnnEventManager::captureEvents ( )
private

Capture the event from OIS.

Definition at line 151 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ clearListenerList()

void AnnEventManager::clearListenerList ( )

Remove every listener known from the EventManager. This doesn't clear any memory

Definition at line 118 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ detectedCollision()

void AnnEventManager::detectedCollision ( void *  a,
void *  b,
AnnVect3  worldPosition,
AnnVect3  normalOnB 
)
private

Hook for the physics engine to signal collisions.

Definition at line 356 of file AnnEventManager.cpp.

Here is the call graph for this function:

◆ fireTimer()

AnnTimerID AnnEventManager::fireTimer ( double  delay)

Create a timer that will timeout after "delay" seconds.

Definition at line 292 of file AnnEventManager.cpp.

Here is the call graph for this function:

◆ fireTimerMillisec()

AnnTimerID AnnEventManager::fireTimerMillisec ( double  millisecDelay)

Create a timer that will timeout after "delay" milliseconds.

Definition at line 285 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ getControllerCount()

size_t AnnEventManager::getControllerCount ( ) const

Get the number of available sticks.

Definition at line 351 of file AnnEventManager.cpp.

◆ getDefaultEventListener()

shared_ptr< AnnEventListener > AnnEventManager::getDefaultEventListener ( ) const

Return the default event listener.

Definition at line 106 of file AnnEventManager.cpp.

◆ getTextInputer()

AnnTextInputer * AnnEventManager::getTextInputer ( ) const

Get the text inputer object.

Definition at line 72 of file AnnEventManager.cpp.

◆ keyboardUsedForText()

void AnnEventManager::keyboardUsedForText ( bool  state = true)

set the "shouldIgnore" flag to keyboard event

Definition at line 384 of file AnnEventManager.cpp.

◆ playerCollision()

void AnnEventManager::playerCollision ( void *  object)
private

Hook for the physics engine to signal player collision.

Definition at line 368 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ processCollisionEvents()

void AnnEventManager::processCollisionEvents ( )
private

Process collisions.

Definition at line 324 of file AnnEventManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processHandControllerEvents()

void AnnEventManager::processHandControllerEvents ( )
private

Process hand controller events.

Definition at line 246 of file AnnEventManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processInput()

void AnnEventManager::processInput ( )
private

Process user inputs.

Definition at line 275 of file AnnEventManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processJoystickEvents()

void AnnEventManager::processJoystickEvents ( )
private

Process joystick events.

Definition at line 194 of file AnnEventManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processKeyboardEvents()

void AnnEventManager::processKeyboardEvents ( )
private

Process keyboard events.

Definition at line 161 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ processMouseEvents()

void AnnEventManager::processMouseEvents ( )
private

Process mouse events.

Definition at line 178 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ processTimers()

void AnnEventManager::processTimers ( )
private

Process timers.

Definition at line 297 of file AnnEventManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processTriggerEvents()

void AnnEventManager::processTriggerEvents ( )
private

Process triggers.

Definition at line 314 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ processUserSpaceEvents()

void AnnEventManager::processUserSpaceEvents ( )
private

Process user event dispatch()

Definition at line 394 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ pushEventsToListeners()

void AnnEventManager::pushEventsToListeners ( )
private

Set the content of the event buffers to all registered listeners.

Definition at line 256 of file AnnEventManager.cpp.

Here is the caller graph for this function:

◆ removeListener()

void AnnEventManager::removeListener ( AnnEventListenerPtr  listener = nullptr)

Make the event manager forget about the listener

Parameters
listenerA listener object. If NULL (default), it will remove every listener form the manager (see clearListenerList())

Definition at line 124 of file AnnEventManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

void AnnEventManager::update ( )
overrideprivatevirtual

Engine call for refreshing the event system.

Reimplemented from Annwvyn::AnnSubSystem.

Definition at line 140 of file AnnEventManager.cpp.

Here is the call graph for this function:

◆ useDefaultEventListener()

void AnnEventManager::useDefaultEventListener ( )

Set the engine to use the "default" event listener. This will create an instance of AnnDefaultEventListener (if it doesn't already exist inside of AnnEngine) This will also unregister all listeners known by AnnEventListener The default event listener implement a simple "FPS-like" control scheme WASD for walking Horizontal view with mouse X relative movement That event listener is designed as an example of an event listener, and for exploring the environment without having to write a custom event listener

Definition at line 90 of file AnnEventManager.cpp.

Here is the call graph for this function:

◆ userSpaceDispatchEvent()

void AnnEventManager::userSpaceDispatchEvent ( AnnUserSpaceEventPtr  e,
AnnUserSpaceEventLauncher sender 
)
private

Send the given event to the listeners.

Definition at line 389 of file AnnEventManager.cpp.

Friends And Related Function Documentation

◆ AnnEngine

friend class AnnEngine
friend

Definition at line 108 of file AnnEventManager.hpp.

◆ AnnPhysicsEngine

friend class AnnPhysicsEngine
friend

Definition at line 109 of file AnnEventManager.hpp.

◆ AnnUserSpaceEventLauncher

friend class AnnUserSpaceEventLauncher
friend

Definition at line 110 of file AnnEventManager.hpp.

Member Data Documentation

◆ activeTimers

std::vector<AnnTimer> Annwvyn::AnnEventManager::activeTimers
private

List of timers.

Definition at line 174 of file AnnEventManager.hpp.

◆ collisionBuffers

std::vector<std::tuple<void*, void*, AnnVect3, AnnVect3> > Annwvyn::AnnEventManager::collisionBuffers
private

Collision reported by the physics engine to consider.

Definition at line 183 of file AnnEventManager.hpp.

◆ defaultEventListener

std::shared_ptr<AnnDefaultEventListener> Annwvyn::AnnEventManager::defaultEventListener
private

Default event listener.

Definition at line 191 of file AnnEventManager.hpp.

◆ futureTimers

std::vector<AnnTimer> Annwvyn::AnnEventManager::futureTimers
private

List of timer that will timeout in a future frame.

Definition at line 176 of file AnnEventManager.hpp.

◆ handControllerEventBuffer

std::vector<AnnHandControllerEvent> Annwvyn::AnnEventManager::handControllerEventBuffer
private

Buffer of hand controller events.

Definition at line 150 of file AnnEventManager.hpp.

◆ InputManager

OIS::InputManager* Annwvyn::AnnEventManager::InputManager
private

OIS Event Manager.

Definition at line 154 of file AnnEventManager.hpp.

◆ Joysticks

std::vector<AnnControllerBuffer> Annwvyn::AnnEventManager::Joysticks
private

Array of poiners to OIS Joystick.

Definition at line 160 of file AnnEventManager.hpp.

◆ Keyboard

OIS::Keyboard* Annwvyn::AnnEventManager::Keyboard
private

Pointer that holds the keyboard.

Definition at line 156 of file AnnEventManager.hpp.

◆ keyboardIgnore

bool Annwvyn::AnnEventManager::keyboardIgnore
private

True if keyboard event should be ignored (keyboard used for "text input")

Definition at line 200 of file AnnEventManager.hpp.

◆ keyEventBuffer

std::vector<AnnKeyEvent> Annwvyn::AnnEventManager::keyEventBuffer
private

Buffer of keyboard events.

Definition at line 144 of file AnnEventManager.hpp.

◆ knowXbox

bool Annwvyn::AnnEventManager::knowXbox
private

True if we detected an xbox controller.

Definition at line 198 of file AnnEventManager.hpp.

◆ lastTimerCreated

AnnTimerID Annwvyn::AnnEventManager::lastTimerCreated
private

Dynamically sized array for remembering the joystick button state at last update.

Definition at line 172 of file AnnEventManager.hpp.

◆ listeners

std::vector<AnnEventListenerWeakPtr> Annwvyn::AnnEventManager::listeners
private

List of pointer to the listeners. The use of weak pointers permit to keep access to the listeners without having to own them. This permit to use any classes of the engine (like levels) to be themselves event listener.

Definition at line 106 of file AnnEventManager.hpp.

◆ Mouse

OIS::Mouse* Annwvyn::AnnEventManager::Mouse
private

Pointer that holds the Mouse.

Definition at line 158 of file AnnEventManager.hpp.

◆ mouseEventBuffer

std::vector<AnnMouseEvent> Annwvyn::AnnEventManager::mouseEventBuffer
private

Buffer of mouse events.

Definition at line 146 of file AnnEventManager.hpp.

◆ playerCollisionBuffer

std::vector<AnnGameObject*> Annwvyn::AnnEventManager::playerCollisionBuffer
private

Player collision reported by the physics engine to consider.

Definition at line 185 of file AnnEventManager.hpp.

◆ previousKeyStates

std::array<bool, KeyCode::SIZE> Annwvyn::AnnEventManager::previousKeyStates
private

Array for remembering the key states at last update.

Definition at line 165 of file AnnEventManager.hpp.

◆ previousMouseButtonStates

std::array<bool, ButtonCount> Annwvyn::AnnEventManager::previousMouseButtonStates
private

Array for remembering the button states at last update.

Definition at line 167 of file AnnEventManager.hpp.

◆ stickEventBuffer

std::vector<AnnControllerEvent> Annwvyn::AnnEventManager::stickEventBuffer
private

Buffer of stick events.

Definition at line 148 of file AnnEventManager.hpp.

◆ textInputer

std::unique_ptr<AnnTextInputer> Annwvyn::AnnEventManager::textInputer
private

The text inputer object itself.

Definition at line 189 of file AnnEventManager.hpp.

◆ triggerEventBuffer

std::vector<AnnTriggerEvent> Annwvyn::AnnEventManager::triggerEventBuffer
private

List of trigger event to process.

Definition at line 178 of file AnnEventManager.hpp.

◆ userSpaceEventBuffer

std::vector<std::pair<AnnUserSpaceEventPtr, AnnUserSpaceEventLauncher*> > Annwvyn::AnnEventManager::userSpaceEventBuffer
private

Using a shared ptr to keep ownership of the event object until the event is dealt with. Also, polymorphism.

Definition at line 193 of file AnnEventManager.hpp.

◆ xboxID

ControllerID Annwvyn::AnnEventManager::xboxID
private

ID of an eventual Xbox controller.

Definition at line 195 of file AnnEventManager.hpp.


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