diff options
Diffstat (limited to 'backends/platform/maemo')
| -rw-r--r-- | backends/platform/maemo/maemo-common.h | 26 | ||||
| -rw-r--r-- | backends/platform/maemo/maemo-keys.h | 139 | ||||
| -rw-r--r-- | backends/platform/maemo/maemo.cpp | 91 | ||||
| -rw-r--r-- | backends/platform/maemo/maemo.h | 13 |
4 files changed, 258 insertions, 11 deletions
diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index f33aa24278..453c70c45f 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,22 @@ 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} + {"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} +}; + +enum CustomEventType { + kEventClickMode = 1, + kEventInvalid = 0 }; } // namespace Maemo diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h new file mode 100644 index 0000000000..e1337515a7 --- /dev/null +++ b/backends/platform/maemo/maemo-keys.h @@ -0,0 +1,139 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#if defined(MAEMO) +#if defined(ENABLE_KEYMAPPER) + +#ifndef PLATFORM_SDL_MAEMO_KEYS_H +#define PLATFORM_SDL_MAEMO_KEYS_H + +#include "common/keyboard.h" + +#include "backends/keymapper/hardware-key.h" + +namespace Common { + +static const ModifierTableEntry maemoModifiers[] = { + { 0, "", "", false }, + { KBD_CTRL, "C+", "Ctrl+", false }, + { KBD_SHIFT, "", "", true }, + { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, + { 0, 0, 0, false } +}; + +static const KeyTableEntry maemoKeys[] = { + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, + {"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, + {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "MCenter", false}, + {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, + {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, + {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, + {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, + {"HASH", KEYCODE_HASH, '#', "#", false}, + {"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, + {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, + {"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, + {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, + {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, + {"PLUS", KEYCODE_PLUS, '+', "+", false}, + {"COMMA", KEYCODE_COMMA, ',', ",", false}, + {"MINUS", KEYCODE_MINUS, '-', "-", false}, + {"PERIOD", KEYCODE_PERIOD, '.', ".", false}, + {"SLASH", KEYCODE_SLASH, '/', "/", false}, + {"0", KEYCODE_0, '0', "0", false}, + {"1", KEYCODE_1, '1', "1", false}, + {"2", KEYCODE_2, '2', "2", false}, + {"3", KEYCODE_3, '3', "3", false}, + {"4", KEYCODE_4, '4', "4", false}, + {"5", KEYCODE_5, '5', "5", false}, + {"6", KEYCODE_6, '6', "6", false}, + {"7", KEYCODE_7, '7', "7", false}, + {"8", KEYCODE_8, '8', "8", false}, + {"9", KEYCODE_9, '9', "9", false}, + {"COLON", KEYCODE_COLON, ':', ":", false}, + {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, + {"LESS", KEYCODE_LESS, '<', "<", false}, + {"EQUALS", KEYCODE_EQUALS, '=', "=", false}, + {"GREATER", KEYCODE_GREATER, '>', ">", false}, + {"QUESTION", KEYCODE_QUESTION, '?', "?", false}, + {"AT", KEYCODE_AT, '@', "@", false}, + + {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, + {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, + {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, + {"CARET", KEYCODE_CARET, '^', "^", false}, + {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, + {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, + {"a", KEYCODE_a, 'a', "a", true}, + {"b", KEYCODE_b, 'b', "b", true}, + {"c", KEYCODE_c, 'c', "c", true}, + {"d", KEYCODE_d, 'd', "d", true}, + {"e", KEYCODE_e, 'e', "e", true}, + {"f", KEYCODE_f, 'f', "f", true}, + {"g", KEYCODE_g, 'g', "g", true}, + {"h", KEYCODE_h, 'h', "h", true}, + {"i", KEYCODE_i, 'i', "i", true}, + {"j", KEYCODE_j, 'j', "j", true}, + {"k", KEYCODE_k, 'k', "k", true}, + {"l", KEYCODE_l, 'l', "l", true}, + {"m", KEYCODE_m, 'm', "m", true}, + {"n", KEYCODE_n, 'n', "n", true}, + {"o", KEYCODE_o, 'o', "o", true}, + {"p", KEYCODE_p, 'p', "p", true}, + {"q", KEYCODE_q, 'q', "q", true}, + {"r", KEYCODE_r, 'r', "r", true}, + {"s", KEYCODE_s, 's', "s", true}, + {"t", KEYCODE_t, 't', "t", true}, + {"u", KEYCODE_u, 'u', "u", true}, + {"v", KEYCODE_v, 'v', "v", true}, + {"w", KEYCODE_w, 'w', "w", true}, + {"x", KEYCODE_x, 'x', "x", true}, + {"y", KEYCODE_y, 'y', "y", true}, + {"z", KEYCODE_z, 'z', "z", true}, + {"DELETE", KEYCODE_DELETE, 0, "Del", false}, + + {"KP_ENTER", KEYCODE_KP_ENTER, 0, "Enter", false}, + + // Arrows + Home/End pad + {"UP", KEYCODE_UP, 0, "Up", false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", false}, + + // Function keys + {"MENU", KEYCODE_F11, 0, "Menu", false}, + {"HOME", KEYCODE_F12, 0, "Home", false}, + {"FULLSCREEN", KEYCODE_F13, 0, "FullScreen", false}, + {"ZOOMPLUS", KEYCODE_F14, 0, "Zoom+", false}, + {"ZOOMMINUS", KEYCODE_F15, 0, "Zoom-", false}, + + {0, KEYCODE_INVALID, 0, 0, false} +}; + +} // namespace Common + +#endif // ifndef PLATFORM_SDL_MAEMO_KEYS_H + +#endif // if defined(ENABLE_KEYMAPPER) +#endif // if defined(MAEMO) 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 diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index 32b52470bc..4b84ae573a 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::HardwareKeySet *getHardwareKeySet(); + 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 |
