diff options
author | Tarek Soliman | 2012-02-09 01:27:55 -0600 |
---|---|---|
committer | Tarek Soliman | 2012-02-15 17:07:52 -0600 |
commit | 974f5eb7b8291535ea34be5260607d6e383543a7 (patch) | |
tree | 8fb077a9f5d80a4398234b81fb370bfcd9ab6ef8 | |
parent | 66aff9c4d81f842b6f5d66adedf9dd0f524d4cec (diff) | |
download | scummvm-rg350-974f5eb7b8291535ea34be5260607d6e383543a7.tar.gz scummvm-rg350-974f5eb7b8291535ea34be5260607d6e383543a7.tar.bz2 scummvm-rg350-974f5eb7b8291535ea34be5260607d6e383543a7.zip |
MAEMO: Drop the hardcoded keymap in favor of the keymapper
-rw-r--r-- | backends/events/maemosdl/maemosdl-events.cpp | 30 | ||||
-rw-r--r-- | backends/platform/maemo/maemo-keys.h | 14 |
2 files changed, 35 insertions, 9 deletions
diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 057205ee2c..932be0dc47 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -33,6 +33,21 @@ MaemoSdlEventSource::MaemoSdlEventSource() : SdlEventSource(), _clickEnabled(tru } +struct KeymapEntry { + SDLKey sym; + Common::KeyCode keycode; + uint16 ascii; +}; + +static const KeymapEntry keymapEntries[] = { + {SDLK_F4, Common::KEYCODE_F11, 0}, + {SDLK_F5, Common::KEYCODE_F12, 0}, + {SDLK_F6, Common::KEYCODE_F13, 0}, + {SDLK_F7, Common::KEYCODE_F14, 0}, + {SDLK_F8, Common::KEYCODE_F15, 0}, + {SDLK_LAST, Common::KEYCODE_INVALID, 0} +}; + bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { Model model = Model(((OSystem_SDL_Maemo *)g_system)->getModel()); @@ -45,6 +60,20 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { // SDLK_F7 -> zoom + // SDLK_F8 -> zoom - +#ifdef ENABLE_KEYMAPPER + if (ev.type == SDL_KEYDOWN || ev.type == SDL_KEYUP) { + const KeymapEntry *entry; + for (entry = keymapEntries; entry->sym != SDLK_LAST; ++entry) { + if (ev.key.keysym.sym == entry->sym) { + SDLModToOSystemKeyFlags(SDL_GetModState(), event); + event.type = ev.type == SDL_KEYDOWN ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; + event.kbd.keycode = entry->keycode; + event.kbd.ascii = entry->ascii; + return true; + } + } + } +#else switch (ev.type) { case SDL_KEYDOWN:{ if (ev.key.keysym.sym == SDLK_F4 @@ -132,6 +161,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { break; } } +#endif // Invoke parent implementation of this method return SdlEventSource::remapKey(ev, event); } diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h index 6725b1164d..26ee375625 100644 --- a/backends/platform/maemo/maemo-keys.h +++ b/backends/platform/maemo/maemo-keys.h @@ -122,15 +122,11 @@ static const KeyTableEntry maemoKeys[] = { {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, // Function keys - {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false}, - {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false}, - {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false}, - {"F4", KEYCODE_F4, ASCII_F4, "Menu", kActionKeyType, false}, - {"F5", KEYCODE_F5, ASCII_F5, "Home", kActionKeyType, false}, - {"F6", KEYCODE_F6, ASCII_F6, "FullScreen", kActionKeyType, false}, - {"F7", KEYCODE_F7, ASCII_F7, "Zoom+", kActionKeyType, false}, - {"F8", KEYCODE_F8, ASCII_F8, "Zoom-", kActionKeyType, false}, - {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false}, + {"MENU", KEYCODE_F11, 0, "Menu", kActionKeyType, false}, + {"HOME", KEYCODE_F12, 0, "Home", kActionKeyType, false}, + {"FULLSCREEN", KEYCODE_F13, 0, "FullScreen", kActionKeyType, false}, + {"ZOOMPLUS", KEYCODE_F14, 0, "Zoom+", kActionKeyType, false}, + {"ZOOMMINUS", KEYCODE_F15, 0, "Zoom-", kActionKeyType, false}, {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} }; |