xoreos  0.0.5
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Events::EventsManager Class Reference

The events manager. More...

#include <events.h>

Inheritance diagram for Events::EventsManager:
Inheritance graph
[legend]
Collaboration diagram for Events::EventsManager:
Collaboration graph
[legend]

Public Member Functions

 EventsManager ()
 
void init ()
 Initialize the events subsystem. More...
 
void deinit ()
 Deinitialize the events subsystem. More...
 
void reset ()
 Completely reset the events manager. More...
 
bool ready () const
 Was the events subsystem successfully initialized? More...
 
bool quitRequested () const
 Was an engine quit requested? More...
 
void requestQuit ()
 Request an engine quit. More...
 
void doQuit ()
 Initiate the actual quitting process. More...
 
bool fatalErrorRaised () const
 Was a fatal engine error raised? More...
 
void raiseFatalError ()
 Raise a fatal engine error. More...
 
void delay (uint32 ms)
 Sleep that number of milliseconds. More...
 
uint32 getTimestamp () const
 Return the number of milliseconds the application is running. More...
 
void flushEvents ()
 Clear the event queue, ignore all unhandled events. More...
 
bool pollEvent (Event &event)
 Get an event from the events queue. More...
 
bool pushEvent (Event &event)
 Push an event onto the events queue. More...
 
void enableKeyRepeat (bool repeat=true)
 Enable/Disable repeated key events. More...
 
void enableTextInput (bool textInput=true)
 Enable/Disable the text input. More...
 
Common::UString getTextInput (const Event &event)
 Return the text that was input with keyboard, in UTF-8 encoding. More...
 
size_t getJoystickCount () const
 Return the number of available joysticks. More...
 
JoystickgetJoystickByIndex (size_t index) const
 Return the joystick with that index. More...
 
JoystickgetJoystickByName (const Common::UString &name) const
 Return the first joystick with that name. More...
 
bool isQueueFull () const
 Is the event queue full? More...
 
void runMainLoop ()
 Run the main loop. More...
 

Private Types

typedef Common::PtrVector< JoystickJoysticks
 
typedef std::list< EventEventQueue
 
typedef void(EventsManager::* RequestHandler) (Request &)
 

Private Member Functions

void initJoysticks ()
 Initialize the available joysticks/gamepads. More...
 
void deinitJoysticks ()
 Deinitialize the available joysticks/gamepads. More...
 
bool parseEventQuit (const Event &event)
 Look for quit events. More...
 
bool parseEventGraphics (const Event &event)
 Look for graphics events. More...
 
bool parseITC (const Event &event)
 Look for inter-thread communication. More...
 
void requestCallInMainThread (Request &request)
 
void requestRebuildGLContainer (Request &request)
 
void requestDestroyGLContainer (Request &request)
 
void processEvents ()
 

Private Attributes

bool _ready
 Was the events subsystem successfully initialized? More...
 
bool _quitRequested
 Was an engine quit requested? More...
 
bool _doQuit
 Are we currently in the process of quitting? More...
 
bool _fatalError
 
Joysticks _joysticks
 
EventQueue _eventQueue
 
Common::Mutex _eventQueueMutex
 
size_t _queueSize
 
bool _fullQueue
 
Common::Condition _queueProcessed
 
bool _repeat
 
uint _repeatCounter
 
uint _textInputCounter
 

Static Private Attributes

static const RequestHandler _requestHandler [kITCEventMAX]
 Pointer to the request handler. More...
 

Friends

class RequestManager
 

Additional Inherited Members

- Static Public Member Functions inherited from Common::Singleton< EventsManager >
static EventsManager & instance ()
 
static void destroy ()
 
- Protected Types inherited from Common::Singleton< EventsManager >
typedef EventsManager SingletonBaseType
 
- Protected Member Functions inherited from Common::Singleton< EventsManager >
 Singleton ()
 
virtual ~Singleton ()
 

Detailed Description

The events manager.

Definition at line 48 of file events.h.

Member Typedef Documentation

◆ EventQueue

typedef std::list<Event> Events::EventsManager::EventQueue
private

Definition at line 156 of file events.h.

◆ Joysticks

Definition at line 154 of file events.h.

◆ RequestHandler

typedef void(EventsManager::* Events::EventsManager::RequestHandler) (Request &)
private

Definition at line 157 of file events.h.

Constructor & Destructor Documentation

◆ EventsManager()

Events::EventsManager::EventsManager ( )

Definition at line 60 of file events.cpp.

Member Function Documentation

◆ deinit()

void Events::EventsManager::deinit ( )

Deinitialize the events subsystem.

Definition at line 92 of file events.cpp.

References _ready, deinitJoysticks(), and RequestMan.

Here is the call graph for this function:

◆ deinitJoysticks()

void Events::EventsManager::deinitJoysticks ( )
private

Deinitialize the available joysticks/gamepads.

Definition at line 367 of file events.cpp.

References _joysticks, and Common::PtrVector< T, Deallocator >::clear().

Referenced by deinit(), initJoysticks(), and reset().

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

◆ delay()

void Events::EventsManager::delay ( uint32  ms)

Sleep that number of milliseconds.

Definition at line 131 of file events.cpp.

References _quitRequested.

◆ doQuit()

void Events::EventsManager::doQuit ( )

Initiate the actual quitting process.

Definition at line 327 of file events.cpp.

References _doQuit.

◆ enableKeyRepeat()

void Events::EventsManager::enableKeyRepeat ( bool  repeat = true)

Enable/Disable repeated key events.

Definition at line 273 of file events.cpp.

References _repeat, and _repeatCounter.

◆ enableTextInput()

void Events::EventsManager::enableTextInput ( bool  textInput = true)

Enable/Disable the text input.

While text input is enabled, we will receive TextInput event containing UTF-8 encoded strings containing text the user has entered. See getTextInput().

Enabling text input will also activate the screen keyboard on some systems.

Definition at line 285 of file events.cpp.

References _textInputCounter.

Referenced by init().

Here is the caller graph for this function:

◆ fatalErrorRaised()

bool Events::EventsManager::fatalErrorRaised ( ) const

Was a fatal engine error raised?

Definition at line 331 of file events.cpp.

References _fatalError.

◆ flushEvents()

void Events::EventsManager::flushEvents ( )

Clear the event queue, ignore all unhandled events.

Definition at line 241 of file events.cpp.

References _eventQueue, and _eventQueueMutex.

◆ getJoystickByIndex()

Joystick * Events::EventsManager::getJoystickByIndex ( size_t  index) const

Return the joystick with that index.

Definition at line 377 of file events.cpp.

References _joysticks.

◆ getJoystickByName()

Joystick * Events::EventsManager::getJoystickByName ( const Common::UString name) const

Return the first joystick with that name.

Definition at line 384 of file events.cpp.

References _joysticks.

◆ getJoystickCount()

size_t Events::EventsManager::getJoystickCount ( ) const

Return the number of available joysticks.

Definition at line 373 of file events.cpp.

References _joysticks.

◆ getTextInput()

Common::UString Events::EventsManager::getTextInput ( const Event event)

Return the text that was input with keyboard, in UTF-8 encoding.

The event must be a TextInput or KeyDown event. For better i18n support, TextInput is preferred.

Definition at line 300 of file events.cpp.

References Common::UString::isCntrl(), Events::kEventKeyDown, and Events::kEventTextInput.

Here is the call graph for this function:

◆ getTimestamp()

uint32 Events::EventsManager::getTimestamp ( ) const

Return the number of milliseconds the application is running.

Definition at line 136 of file events.cpp.

Referenced by init().

Here is the caller graph for this function:

◆ init()

void Events::EventsManager::init ( )

Initialize the events subsystem.

Definition at line 66 of file events.cpp.

References _fullQueue, _queueSize, _ready, _repeatCounter, _textInputCounter, enableTextInput(), getTimestamp(), GfxMan, initJoysticks(), NotificationMan, RequestMan, and TimerMan.

Here is the call graph for this function:

◆ initJoysticks()

void Events::EventsManager::initJoysticks ( )
private

Initialize the available joysticks/gamepads.

Definition at line 353 of file events.cpp.

References _joysticks, and deinitJoysticks().

Referenced by init(), and reset().

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

◆ isQueueFull()

bool Events::EventsManager::isQueueFull ( ) const

Is the event queue full?

Definition at line 127 of file events.cpp.

References _fullQueue.

◆ parseEventGraphics()

bool Events::EventsManager::parseEventGraphics ( const Event event)
private

Look for graphics events.

Definition at line 161 of file events.cpp.

References GfxMan, Events::kEventKeyDown, Events::kEventWindow, Events::kEventWindowRestored, and WindowMan.

Referenced by processEvents().

Here is the caller graph for this function:

◆ parseEventQuit()

bool Events::EventsManager::parseEventQuit ( const Event event)
private

Look for quit events.

Definition at line 140 of file events.cpp.

References Events::kEventKeyDown, Events::kEventQuit, and requestQuit().

Referenced by processEvents().

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

◆ parseITC()

bool Events::EventsManager::parseITC ( const Event event)
private

Look for inter-thread communication.

Definition at line 186 of file events.cpp.

References _requestHandler, Events::kEventITC, and Events::kITCEventMAX.

Referenced by processEvents().

Here is the caller graph for this function:

◆ pollEvent()

bool Events::EventsManager::pollEvent ( Event event)

Get an event from the events queue.

Parameters
eventWhere to store the polled event.
Returns
true if there was an event to poll, false if not.

Definition at line 247 of file events.cpp.

References _eventQueue, and _eventQueueMutex.

◆ processEvents()

void Events::EventsManager::processEvents ( )
private

Definition at line 210 of file events.cpp.

References _eventQueue, _eventQueueMutex, _fullQueue, _queueSize, _repeat, Common::enforceMainThread(), Events::kEventKeyDown, Events::kEventKeyUp, parseEventGraphics(), parseEventQuit(), and parseITC().

Referenced by runMainLoop().

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

◆ pushEvent()

bool Events::EventsManager::pushEvent ( Event event)

Push an event onto the events queue.

Parameters
eventThe event to push.
Returns
true on success, false otherwise.

Definition at line 260 of file events.cpp.

References _eventQueueMutex, _queueProcessed, _queueSize, Common::isMainThread(), and Common::Condition::wait().

Here is the call graph for this function:

◆ quitRequested()

bool Events::EventsManager::quitRequested ( ) const

Was an engine quit requested?

Definition at line 319 of file events.cpp.

References _quitRequested.

◆ raiseFatalError()

void Events::EventsManager::raiseFatalError ( )

Raise a fatal engine error.

Definition at line 335 of file events.cpp.

References _doQuit, _fatalError, and _quitRequested.

◆ ready()

bool Events::EventsManager::ready ( ) const

Was the events subsystem successfully initialized?

Definition at line 123 of file events.cpp.

References _ready.

◆ requestCallInMainThread()

void Events::EventsManager::requestCallInMainThread ( Request request)
private

◆ requestDestroyGLContainer()

void Events::EventsManager::requestDestroyGLContainer ( Request request)
private

Definition at line 400 of file events.cpp.

References Events::Request::_glContainer, Graphics::GLContainer::destroy(), and Events::RequestDataGLContainer::glContainer.

Here is the call graph for this function:

◆ requestQuit()

void Events::EventsManager::requestQuit ( )

Request an engine quit.

Definition at line 323 of file events.cpp.

References _quitRequested.

Referenced by parseEventQuit().

Here is the caller graph for this function:

◆ requestRebuildGLContainer()

void Events::EventsManager::requestRebuildGLContainer ( Request request)
private

Definition at line 396 of file events.cpp.

References Events::Request::_glContainer, Events::RequestDataGLContainer::glContainer, and Graphics::GLContainer::rebuild().

Here is the call graph for this function:

◆ reset()

void Events::EventsManager::reset ( )

Completely reset the events manager.

Definition at line 103 of file events.cpp.

References _eventQueue, _eventQueueMutex, _ready, _repeatCounter, _textInputCounter, deinitJoysticks(), and initJoysticks().

Here is the call graph for this function:

◆ runMainLoop()

void Events::EventsManager::runMainLoop ( )

Run the main loop.

Definition at line 341 of file events.cpp.

References _doQuit, _queueProcessed, GfxMan, processEvents(), and Common::Condition::signal().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ RequestManager

friend class RequestManager
friend

Definition at line 204 of file events.h.

Member Data Documentation

◆ _doQuit

bool Events::EventsManager::_doQuit
private

Are we currently in the process of quitting?

Definition at line 165 of file events.h.

Referenced by doQuit(), raiseFatalError(), and runMainLoop().

◆ _eventQueue

EventQueue Events::EventsManager::_eventQueue
private

Definition at line 171 of file events.h.

Referenced by flushEvents(), pollEvent(), processEvents(), and reset().

◆ _eventQueueMutex

Common::Mutex Events::EventsManager::_eventQueueMutex
private

Definition at line 172 of file events.h.

Referenced by flushEvents(), pollEvent(), processEvents(), pushEvent(), and reset().

◆ _fatalError

bool Events::EventsManager::_fatalError
private

Definition at line 167 of file events.h.

Referenced by fatalErrorRaised(), and raiseFatalError().

◆ _fullQueue

bool Events::EventsManager::_fullQueue
private

Definition at line 176 of file events.h.

Referenced by init(), isQueueFull(), and processEvents().

◆ _joysticks

Joysticks Events::EventsManager::_joysticks
private

◆ _queueProcessed

Common::Condition Events::EventsManager::_queueProcessed
private

Definition at line 177 of file events.h.

Referenced by pushEvent(), and runMainLoop().

◆ _queueSize

size_t Events::EventsManager::_queueSize
private

Definition at line 174 of file events.h.

Referenced by init(), processEvents(), and pushEvent().

◆ _quitRequested

bool Events::EventsManager::_quitRequested
private

Was an engine quit requested?

Definition at line 164 of file events.h.

Referenced by delay(), quitRequested(), raiseFatalError(), and requestQuit().

◆ _ready

bool Events::EventsManager::_ready
private

Was the events subsystem successfully initialized?

Definition at line 162 of file events.h.

Referenced by deinit(), init(), ready(), and reset().

◆ _repeat

bool Events::EventsManager::_repeat
private

Definition at line 179 of file events.h.

Referenced by enableKeyRepeat(), and processEvents().

◆ _repeatCounter

uint Events::EventsManager::_repeatCounter
private

Definition at line 180 of file events.h.

Referenced by enableKeyRepeat(), init(), and reset().

◆ _requestHandler

const EventsManager::RequestHandler Events::EventsManager::_requestHandler
staticprivate
Initial value:

Pointer to the request handler.

Definition at line 160 of file events.h.

Referenced by parseITC().

◆ _textInputCounter

uint Events::EventsManager::_textInputCounter
private

Definition at line 182 of file events.h.

Referenced by enableTextInput(), init(), and reset().


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