aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorTarek Soliman2012-02-09 01:26:42 -0600
committerTarek Soliman2012-02-12 13:28:13 -0600
commitc2640ed33a1b9c28e58b04877b7c4bf7b5fff570 (patch)
tree86f7356cf37d6fa80984a99bb51fcc78444655f0 /backends
parentd90d4d10a09e1bab04154aa81162aac9c994f23c (diff)
downloadscummvm-rg350-c2640ed33a1b9c28e58b04877b7c4bf7b5fff570.tar.gz
scummvm-rg350-c2640ed33a1b9c28e58b04877b7c4bf7b5fff570.tar.bz2
scummvm-rg350-c2640ed33a1b9c28e58b04877b7c4bf7b5fff570.zip
MAEMO: Use custom event Click Mode keymap action
Diffstat (limited to 'backends')
-rw-r--r--backends/events/maemosdl/maemosdl-events.cpp16
-rw-r--r--backends/events/maemosdl/maemosdl-events.h9
-rw-r--r--backends/platform/maemo/maemo-common.h5
-rw-r--r--backends/platform/maemo/maemo.cpp22
-rw-r--r--backends/platform/maemo/maemo.h5
5 files changed, 52 insertions, 5 deletions
diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp
index d7bda8c8d5..acca1a3c02 100644
--- a/backends/events/maemosdl/maemosdl-events.cpp
+++ b/backends/events/maemosdl/maemosdl-events.cpp
@@ -164,6 +164,22 @@ bool MaemoSdlEventSource::toggleClickMode() {
return _clickEnabled;
}
+MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) {
+ assert(_eventSource);
+ _eventSource = eventSource;
+}
+
+bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) {
+ if (event.type != Common::EVENT_CUSTOM_BACKEND)
+ return false;
+ if (event.customType == kEventClickMode) {
+ assert(_eventSource);
+ _eventSource->toggleClickMode();
+ return true;
+ }
+ return false;
+}
+
} // namespace Maemo
#endif // if defined(MAEMO)
diff --git a/backends/events/maemosdl/maemosdl-events.h b/backends/events/maemosdl/maemosdl-events.h
index f7b2bbf70b..f3f05feeca 100644
--- a/backends/events/maemosdl/maemosdl-events.h
+++ b/backends/events/maemosdl/maemosdl-events.h
@@ -47,6 +47,15 @@ protected:
bool _clickEnabled;
};
+class MaemoSdlEventObserver : public Common::EventObserver {
+public:
+ MaemoSdlEventObserver(MaemoSdlEventSource *eventSource);
+
+ virtual bool notifyEvent(const Common::Event &event);
+private:
+ MaemoSdlEventSource *_eventSource;
+};
+
} // namespace Maemo
#endif // include guard
diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h
index 5f8645a6b7..cd4bb3b027 100644
--- a/backends/platform/maemo/maemo-common.h
+++ b/backends/platform/maemo/maemo-common.h
@@ -51,6 +51,11 @@ static const Model models[] = {
{0, kModelTypeInvalid, 0, true}
};
+enum CustomEventType {
+ kEventClickMode = 1,
+ kEventInvalid = 0
+};
+
} // namespace Maemo
#endif // ifndef PLATFORM_SDL_MAEMO_COMMON_H
diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp
index eae18cc4fd..fe60bdc042 100644
--- a/backends/platform/maemo/maemo.cpp
+++ b/backends/platform/maemo/maemo.cpp
@@ -46,6 +46,10 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo()
OSystem_POSIX() {
}
+OSystem_SDL_Maemo::~OSystem_SDL_Maemo() {
+ delete _eventObserver;
+}
+
void OSystem_SDL_Maemo::initBackend() {
// Create the events manager
if (_eventSource == 0)
@@ -54,12 +58,16 @@ void OSystem_SDL_Maemo::initBackend() {
if (_graphicsManager == 0)
_graphicsManager = new MaemoSdlGraphicsManager(_eventSource);
+ if (_eventObserver == 0)
+ _eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource);
+
ConfMan.set("vkeybdpath", DATA_PATH);
_model = Model(detectModel());
// Call parent implementation of this method
OSystem_POSIX::initBackend();
+ initObserver();
}
void OSystem_SDL_Maemo::quit() {
@@ -136,8 +144,11 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() {
Action *act;
-// act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType);
-// act->addCustomEvent(CLICK_MODE);
+ act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType);
+ Event evt = Event();
+ evt.type = EVENT_CUSTOM_BACKEND;
+ evt.customType = Maemo::kEventClickMode;
+ act->addEvent(evt);
act = new Action(globalMap, "LCLK", _("Left Click"), kKeyRemapActionType);
act->addLeftClickEvent();
@@ -154,8 +165,11 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() {
#endif
}
-} //namespace Maemo
-
+void OSystem_SDL_Maemo::initObserver() {
+ assert(_eventManager);
+ _eventManager->getEventDispatcher()->registerObserver(_eventObserver, 10, false);
+}
+} //namespace Maemo
#endif
diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h
index e94c6c603b..821f3526e8 100644
--- a/backends/platform/maemo/maemo.h
+++ b/backends/platform/maemo/maemo.h
@@ -29,10 +29,12 @@
#include "backends/platform/maemo/maemo-common.h"
namespace Maemo {
+class MaemoSdlEventObserver;
class OSystem_SDL_Maemo : public OSystem_POSIX {
public:
OSystem_SDL_Maemo();
+ ~OSystem_SDL_Maemo();
virtual void initBackend();
virtual void quit();
@@ -46,10 +48,11 @@ public:
private:
virtual void setXWindowName(const char *caption);
+ void initObserver();
const Model detectModel();
Model _model;
-
+ MaemoSdlEventObserver *_eventObserver;
};
} // namespace Maemo