aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2011-06-06 15:51:46 +0200
committerMax Horn2011-06-06 16:13:57 +0200
commitc81e94b25214d258e0789f51b0ad0236ba1bf9c0 (patch)
tree41e1a0a9e9c121e58f1379db19d0faf743d80fcd /common
parent848079b66de84cec7559bfbd009d664098ea42ac (diff)
downloadscummvm-rg350-c81e94b25214d258e0789f51b0ad0236ba1bf9c0.tar.gz
scummvm-rg350-c81e94b25214d258e0789f51b0ad0236ba1bf9c0.tar.bz2
scummvm-rg350-c81e94b25214d258e0789f51b0ad0236ba1bf9c0.zip
BACKENDS: Unify EventManager setup
Diffstat (limited to 'common')
-rw-r--r--common/system.cpp13
-rw-r--r--common/system.h19
2 files changed, 30 insertions, 2 deletions
diff --git a/common/system.cpp b/common/system.cpp
index 298f1d7d0d..2a0dfd8dfd 100644
--- a/common/system.cpp
+++ b/common/system.cpp
@@ -26,8 +26,9 @@
#define FORBIDDEN_SYMBOL_EXCEPTION_fflush
#include "common/system.h"
-#include "common/str.h"
+#include "common/events.h"
#include "common/fs.h"
+#include "common/str.h"
#include "common/textconsole.h"
#include "backends/audiocd/default/default-audiocd.h"
@@ -36,19 +37,29 @@ OSystem *g_system = 0;
OSystem::OSystem() {
_audiocdManager = 0;
+ _eventManager = 0;
}
OSystem::~OSystem() {
delete _audiocdManager;
+ _audiocdManager = 0;
+
+ delete _eventManager;
+ _eventManager = 0;
}
void OSystem::initBackend() {
+ // Init AudioCD manager
#ifndef DISABLE_DEFAULT_AUDIOCD_MANAGER
if (!_audiocdManager)
_audiocdManager = new DefaultAudioCDManager();
#endif
if (!_audiocdManager)
error("Backend failed to instantiate AudioCD manager");
+
+ // Verify Event manager has been set
+ if (!_eventManager)
+ error("Backend failed to instantiate Event manager");
}
bool OSystem::setGraphicsMode(const char *name) {
diff --git a/common/system.h b/common/system.h
index 85771cf982..87e74d928c 100644
--- a/common/system.h
+++ b/common/system.h
@@ -113,6 +113,21 @@ protected:
*/
AudioCDManager *_audiocdManager;
+ /**
+ * For backend authors only, this pointer may be set by OSystem
+ * subclasses to an EventManager instance. This is only useful
+ * if your backend does not want to use the DefaultEventManager.
+ *
+ * This instance is returned by OSystem::getEventManager(),
+ * and it is deleted by the OSystem destructor.
+ *
+ * A backend may set this pointer in its initBackend() method,
+ * its constructor or somewhere in between; but it must
+ * set it no later than in its initBackend() implementation, because
+ * OSystem::initBackend() will by default create a DefaultEventManager
+ * instance if _eventManager has not yet been set.
+ */
+ Common::EventManager *_eventManager;
public:
/**
@@ -848,7 +863,9 @@ public:
* Return the event manager singleton. For more information, refer
* to the EventManager documentation.
*/
- virtual Common::EventManager *getEventManager() = 0;
+ inline Common::EventManager *getEventManager() {
+ return _eventManager;
+ }
/**
* Register hardware keys with keymapper