aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/maemo
diff options
context:
space:
mode:
Diffstat (limited to 'backends/platform/maemo')
-rw-r--r--backends/platform/maemo/maemo-common.h19
-rw-r--r--backends/platform/maemo/maemo.cpp112
-rw-r--r--backends/platform/maemo/maemo.h13
3 files changed, 131 insertions, 13 deletions
diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h
index f33aa24278..0442b9c0ae 100644
--- a/backends/platform/maemo/maemo-common.h
+++ b/backends/platform/maemo/maemo-common.h
@@ -28,9 +28,10 @@
namespace Maemo {
enum ModelType {
- kModelTypeN800 = 1,
- kModelTypeN810 = 2,
- kModelTypeN900 = 4,
+ kModelType770 = 1 << 0,
+ kModelTypeN800 = 1 << 1,
+ kModelTypeN810 = 1 << 2,
+ kModelTypeN900 = 1 << 3,
kModelTypeInvalid = 0
};
@@ -38,15 +39,13 @@ struct Model {
const char *hwId;
ModelType modelType;
const char *hwAlias;
- bool hwKeyboard;
+ bool hasHwKeyboard;
+ bool hasMenuKey;
};
-static const Model models[] = {
- {"RX-34", kModelTypeN800, "N800", false},
- {"RX-44", kModelTypeN810, "N810", true},
- {"RX-48", kModelTypeN810, "N810W", true},
- {"RX-51", kModelTypeN900, "N900", true},
- {0, kModelTypeInvalid, 0, true}
+enum CustomEventType {
+ kEventClickMode = 1,
+ kEventInvalid = 0
};
} // namespace Maemo
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
diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h
index 32b52470bc..43bc262ade 100644
--- a/backends/platform/maemo/maemo.h
+++ b/backends/platform/maemo/maemo.h
@@ -29,25 +29,36 @@
#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();
virtual void fatalError();
virtual void setWindowCaption(const char *caption);
virtual void setupIcon();
+#ifdef ENABLE_KEYMAPPER
+ virtual Common::HardwareInputSet *getHardwareInputSet();
+ virtual Common::Keymap *getGlobalKeymap();
+ virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return _keymapperDefaultBindings; }
+#endif
Model getModel() { return _model; }
private:
virtual void setXWindowName(const char *caption);
+ void initObserver();
const Model detectModel();
Model _model;
-
+ MaemoSdlEventObserver *_eventObserver;
+#ifdef ENABLE_KEYMAPPER
+ Common::KeymapperDefaultBindings *_keymapperDefaultBindings;
+#endif
};
} // namespace Maemo