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.cpp112
1 files changed, 110 insertions, 2 deletions
diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp
index 454a13631c..e296d4787c 100644
--- a/backends/platform/maemo/maemo.cpp
+++ b/backends/platform/maemo/maemo.cpp
@@ -30,7 +30,10 @@
#include "backends/platform/maemo/maemo.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 +46,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 +91,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() {
@@ -102,10 +155,19 @@ void OSystem_SDL_Maemo::setWindowCaption(const char *caption) {
setXWindowName(cap.c_str());
}
+static const Model models[] = {
+ {"SU-18", kModelType770, "770", false, true},
+ {"RX-34", kModelTypeN800, "N800", false, true},
+ {"RX-44", kModelTypeN810, "N810", true, true},
+ {"RX-48", kModelTypeN810, "N810W", true, true},
+ {"RX-51", kModelTypeN900, "N900", true, false},
+ {0, kModelTypeInvalid, 0, true, true}
+};
+
const Maemo::Model OSystem_SDL_Maemo::detectModel() {
Common::String deviceHwId = Common::String(getenv("SCUMMVM_MAEMO_DEVICE"));
const Model *model;
- for (model = models; model->hwId; model++) {
+ for (model = models; model->hwId; ++model) {
if (deviceHwId.equals(model->hwId))
return *model;
}
@@ -118,6 +180,52 @@ void OSystem_SDL_Maemo::setupIcon() {
// http://bugzilla.libsdl.org/show_bug.cgi?id=586
}
+static const Common::KeyTableEntry maemoKeys[] = {
+ // Function keys
+ {"MENU", Common::KEYCODE_F11, 0, "Menu", false},
+ {"HOME", Common::KEYCODE_F12, 0, "Home", false},
+ {"FULLSCREEN", Common::KEYCODE_F13, 0, "FullScreen", false},
+ {"ZOOMPLUS", Common::KEYCODE_F14, 0, "Zoom+", false},
+ {"ZOOMMINUS", Common::KEYCODE_F15, 0, "Zoom-", false},
+
+ {0, Common::KEYCODE_INVALID, 0, 0, false}
+};
+
+#ifdef ENABLE_KEYMAPPER
+Common::HardwareInputSet *OSystem_SDL_Maemo::getHardwareInputSet() {
+ return new Common::HardwareInputSet(true, maemoKeys);
+}
+
+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_ACTION;
+ 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