xoreos
0.0.5
|
The events manager. More...
#include <events.h>
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... | |
Joystick * | getJoystickByIndex (size_t index) const |
Return the joystick with that index. More... | |
Joystick * | getJoystickByName (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< Joystick > | Joysticks |
typedef std::list< Event > | EventQueue |
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 () |
|
private |
|
private |
|
private |
Events::EventsManager::EventsManager | ( | ) |
Definition at line 60 of file events.cpp.
void Events::EventsManager::deinit | ( | ) |
Deinitialize the events subsystem.
Definition at line 92 of file events.cpp.
References _ready, deinitJoysticks(), and RequestMan.
|
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().
void Events::EventsManager::delay | ( | uint32 | ms | ) |
Sleep that number of milliseconds.
Definition at line 131 of file events.cpp.
References _quitRequested.
void Events::EventsManager::doQuit | ( | ) |
Initiate the actual quitting process.
Definition at line 327 of file events.cpp.
References _doQuit.
void Events::EventsManager::enableKeyRepeat | ( | bool | repeat = true | ) |
Enable/Disable repeated key events.
Definition at line 273 of file events.cpp.
References _repeat, and _repeatCounter.
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().
bool Events::EventsManager::fatalErrorRaised | ( | ) | const |
void Events::EventsManager::flushEvents | ( | ) |
Clear the event queue, ignore all unhandled events.
Definition at line 241 of file events.cpp.
References _eventQueue, and _eventQueueMutex.
Joystick * Events::EventsManager::getJoystickByIndex | ( | size_t | index | ) | const |
Return the joystick with that index.
Definition at line 377 of file events.cpp.
References _joysticks.
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.
size_t Events::EventsManager::getJoystickCount | ( | ) | const |
Return the number of available joysticks.
Definition at line 373 of file events.cpp.
References _joysticks.
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.
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().
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.
|
private |
Initialize the available joysticks/gamepads.
Definition at line 353 of file events.cpp.
References _joysticks, and deinitJoysticks().
Referenced by init(), and reset().
bool Events::EventsManager::isQueueFull | ( | ) | const |
|
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().
|
private |
Look for quit events.
Definition at line 140 of file events.cpp.
References Events::kEventKeyDown, Events::kEventQuit, and requestQuit().
Referenced by processEvents().
|
private |
Look for inter-thread communication.
Definition at line 186 of file events.cpp.
References _requestHandler, Events::kEventITC, and Events::kITCEventMAX.
Referenced by processEvents().
bool Events::EventsManager::pollEvent | ( | Event & | event | ) |
Get an event from the events queue.
event | Where to store the polled event. |
Definition at line 247 of file events.cpp.
References _eventQueue, and _eventQueueMutex.
|
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().
bool Events::EventsManager::pushEvent | ( | Event & | event | ) |
Push an event onto the events queue.
event | The event to push. |
Definition at line 260 of file events.cpp.
References _eventQueueMutex, _queueProcessed, _queueSize, Common::isMainThread(), and Common::Condition::wait().
bool Events::EventsManager::quitRequested | ( | ) | const |
void Events::EventsManager::raiseFatalError | ( | ) |
Raise a fatal engine error.
Definition at line 335 of file events.cpp.
References _doQuit, _fatalError, and _quitRequested.
bool Events::EventsManager::ready | ( | ) | const |
Was the events subsystem successfully initialized?
Definition at line 123 of file events.cpp.
References _ready.
|
private |
Definition at line 392 of file events.cpp.
References Events::Request::_callInMainThread, and Events::RequestCallInMainThread::caller.
|
private |
Definition at line 400 of file events.cpp.
References Events::Request::_glContainer, Graphics::GLContainer::destroy(), and Events::RequestDataGLContainer::glContainer.
void Events::EventsManager::requestQuit | ( | ) |
Request an engine quit.
Definition at line 323 of file events.cpp.
References _quitRequested.
Referenced by parseEventQuit().
|
private |
Definition at line 396 of file events.cpp.
References Events::Request::_glContainer, Events::RequestDataGLContainer::glContainer, and Graphics::GLContainer::rebuild().
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().
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().
|
friend |
|
private |
Are we currently in the process of quitting?
Definition at line 165 of file events.h.
Referenced by doQuit(), raiseFatalError(), and runMainLoop().
|
private |
Definition at line 171 of file events.h.
Referenced by flushEvents(), pollEvent(), processEvents(), and reset().
|
private |
Definition at line 172 of file events.h.
Referenced by flushEvents(), pollEvent(), processEvents(), pushEvent(), and reset().
|
private |
Definition at line 167 of file events.h.
Referenced by fatalErrorRaised(), and raiseFatalError().
|
private |
Definition at line 176 of file events.h.
Referenced by init(), isQueueFull(), and processEvents().
|
private |
Definition at line 169 of file events.h.
Referenced by deinitJoysticks(), getJoystickByIndex(), getJoystickByName(), getJoystickCount(), and initJoysticks().
|
private |
Definition at line 177 of file events.h.
Referenced by pushEvent(), and runMainLoop().
|
private |
Definition at line 174 of file events.h.
Referenced by init(), processEvents(), and pushEvent().
|
private |
Was an engine quit requested?
Definition at line 164 of file events.h.
Referenced by delay(), quitRequested(), raiseFatalError(), and requestQuit().
|
private |
|
private |
Definition at line 179 of file events.h.
Referenced by enableKeyRepeat(), and processEvents().
|
private |
Definition at line 180 of file events.h.
Referenced by enableKeyRepeat(), init(), and reset().
|
staticprivate |
Pointer to the request handler.
Definition at line 160 of file events.h.
Referenced by parseITC().
|
private |
Definition at line 182 of file events.h.
Referenced by enableTextInput(), init(), and reset().