aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/maemo/maemo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/maemo/maemo.cpp')
-rw-r--r--backends/platform/maemo/maemo.cpp91
1 files changed, 90 insertions, 1 deletions
diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp
index 454a13631c..209e527e3f 100644
--- a/backends/platform/maemo/maemo.cpp
+++ b/backends/platform/maemo/maemo.cpp
@@ -28,9 +28,13 @@
#include "common/config-manager.h"
#include "backends/platform/maemo/maemo.h"
+#include "backends/platform/maemo/maemo-keys.h"
#include "backends/events/maemosdl/maemosdl-events.h"
#include "backends/graphics/maemosdl/maemosdl-graphics.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/keymapper-defaults.h"
#include "common/textconsole.h"
+#include "common/translation.h"
#include <SDL/SDL_syswm.h>
@@ -43,6 +47,43 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo()
OSystem_POSIX() {
}
+OSystem_SDL_Maemo::~OSystem_SDL_Maemo() {
+ delete _eventObserver;
+#ifdef ENABLE_KEYMAPPER
+ delete _keymapperDefaultBindings;
+#endif
+}
+
+#ifdef ENABLE_KEYMAPPER
+static void registerDefaultKeyBindings(Common::KeymapperDefaultBindings *_keymapperDefaultBindings, Model _model) {
+ _keymapperDefaultBindings->setDefaultBinding("gui", "REM", "HOME");
+ _keymapperDefaultBindings->setDefaultBinding("global", "REM", "HOME");
+
+ if (_model.hasMenuKey && _model.hasHwKeyboard) {
+ _keymapperDefaultBindings->setDefaultBinding("gui", "FUL", "FULLSCREEN");
+ _keymapperDefaultBindings->setDefaultBinding("global", "FUL", "FULLSCREEN");
+ }
+
+ if (_model.hasHwKeyboard) {
+ _keymapperDefaultBindings->setDefaultBinding("gui", "VIR", "C+ZOOMMINUS");
+ _keymapperDefaultBindings->setDefaultBinding("global", "VIR", "C+ZOOMMINUS");
+ } else {
+ _keymapperDefaultBindings->setDefaultBinding("gui", "VIR", "FULLSCREEN");
+ _keymapperDefaultBindings->setDefaultBinding("global", "VIR", "FULLSCREEN");
+ }
+
+ if (_model.hasMenuKey )
+ _keymapperDefaultBindings->setDefaultBinding("global", "MEN", "MENU");
+ else
+ _keymapperDefaultBindings->setDefaultBinding("global", "MEN", "S+C+M");
+
+ _keymapperDefaultBindings->setDefaultBinding("gui", "CLO", "ESCAPE");
+
+ _keymapperDefaultBindings->setDefaultBinding("maemo", "RCL", "ZOOMPLUS");
+ _keymapperDefaultBindings->setDefaultBinding("maemo", "CLK", "ZOOMMINUS");
+}
+#endif
+
void OSystem_SDL_Maemo::initBackend() {
// Create the events manager
if (_eventSource == 0)
@@ -51,12 +92,25 @@ void OSystem_SDL_Maemo::initBackend() {
if (_graphicsManager == 0)
_graphicsManager = new MaemoSdlGraphicsManager(_eventSource);
+ if (_eventObserver == 0)
+ _eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource);
+
+#ifdef ENABLE_KEYMAPPER
+ if (_keymapperDefaultBindings == 0)
+ _keymapperDefaultBindings = new Common::KeymapperDefaultBindings();
+#endif
+
ConfMan.set("vkeybdpath", DATA_PATH);
- _model = Model(detectModel());
+ _model = detectModel();
+
+#ifdef ENABLE_KEYMAPPER
+ registerDefaultKeyBindings(_keymapperDefaultBindings, _model);
+#endif
// Call parent implementation of this method
OSystem_POSIX::initBackend();
+ initObserver();
}
void OSystem_SDL_Maemo::quit() {
@@ -118,6 +172,41 @@ void OSystem_SDL_Maemo::setupIcon() {
// http://bugzilla.libsdl.org/show_bug.cgi?id=586
}
+#ifdef ENABLE_KEYMAPPER
+Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() {
+ return new Common::HardwareKeySet(Common::maemoKeys, Common::maemoModifiers);
+}
+
+Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() {
+ using namespace Common;
+ Keymap *globalMap = new Keymap("maemo");
+
+ Action *act;
+
+ act = new Action(globalMap, "CLKM", _("Click Mode"));
+ Event evt = Event();
+ evt.type = EVENT_CUSTOM_BACKEND;
+ evt.customType = Maemo::kEventClickMode;
+ act->addEvent(evt);
+
+ act = new Action(globalMap, "LCLK", _("Left Click"));
+ act->addLeftClickEvent();
+
+ act = new Action(globalMap, "MCLK", _("Middle Click"));
+ act->addMiddleClickEvent();
+
+ act = new Action(globalMap, "RCLK", _("Right Click"));
+ act->addRightClickEvent();
+
+ return globalMap;
+}
+#endif
+
+void OSystem_SDL_Maemo::initObserver() {
+ assert(_eventManager);
+ _eventManager->getEventDispatcher()->registerObserver(_eventObserver, 10, false);
+}
+
} //namespace Maemo
#endif