[Scummvm-cvs-logs] scummvm master -> 85c8c84804125599547f8408962656e2686543e9
tsoliman
tarek at bashasoliman.com
Thu Feb 16 00:34:32 CET 2012
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
974f5eb7b8 MAEMO: Drop the hardcoded keymap in favor of the keymapper
cce5be67dc KEYMAPPER: Allow ports to define default Keymap Action bindings
e55914c51b MAEMO: Register Keymapper Keymap Action default bindings
85c8c84804 KEYMAPPER: Add more warning signs
Commit: 974f5eb7b8291535ea34be5260607d6e383543a7
https://github.com/scummvm/scummvm/commit/974f5eb7b8291535ea34be5260607d6e383543a7
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-15T15:07:52-08:00
Commit Message:
MAEMO: Drop the hardcoded keymap in favor of the keymapper
Changed paths:
backends/events/maemosdl/maemosdl-events.cpp
backends/platform/maemo/maemo-keys.h
diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp
index 057205e..932be0d 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 6725b11..26ee375 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}
};
Commit: cce5be67dc3d171a5b30a9863f250471adecd5b0
https://github.com/scummvm/scummvm/commit/cce5be67dc3d171a5b30a9863f250471adecd5b0
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-15T15:07:52-08:00
Commit Message:
KEYMAPPER: Allow ports to define default Keymap Action bindings
Changed paths:
A backends/keymapper/keymapper-defaults.h
backends/keymapper/keymap.cpp
common/system.h
diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp
index bd02093..daf92e1 100644
--- a/backends/keymapper/keymap.cpp
+++ b/backends/keymapper/keymap.cpp
@@ -24,7 +24,10 @@
#ifdef ENABLE_KEYMAPPER
+#include "common/system.h"
+
#include "backends/keymapper/hardware-key.h"
+#include "backends/keymapper/keymapper-defaults.h"
#define KEYMAP_KEY_PREFIX "keymap_"
@@ -121,35 +124,50 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) {
if (!_configDomain)
return;
- ConfigManager::Domain::iterator it;
- String prefix = KEYMAP_KEY_PREFIX + _name + "_";
-
- for (it = _configDomain->begin(); it != _configDomain->end(); ++it) {
- const String& key = it->_key;
-
- if (!key.hasPrefix(prefix.c_str()))
- continue;
+ if (_actions.empty())
+ return;
- // parse Action ID
- const char *actionId = key.c_str() + prefix.size();
- Action *ua = getAction(actionId);
+ Common::KeymapperDefaultBindings *defaults = g_system->getKeymapperDefaultBindings();
- if (!ua) {
- warning("'%s' keymap does not contain Action with ID %s",
- _name.c_str(), actionId);
- _configDomain->erase(key);
+ HashMap<String, const HardwareKey *> mappedKeys;
+ List<Action*>::iterator it;
+ String prefix = KEYMAP_KEY_PREFIX + _name + "_";
- continue;
+ for (it = _actions.begin(); it != _actions.end(); ++it) {
+ Action* ua = *it;
+ String actionId(ua->id);
+ String confKey = prefix + actionId;
+
+ String hwKeyId = _configDomain->getVal(confKey);
+
+ bool defaulted = false;
+ // fall back to the platform-specific defaults
+ if (hwKeyId.empty() && defaults) {
+ hwKeyId = defaults->getDefaultBinding(_name, actionId);
+ if (!hwKeyId.empty())
+ defaulted = true;
}
+ // there's no mapping
+ if (hwKeyId.empty())
+ continue;
- const HardwareKey *hwKey = hwKeys->findHardwareKey(it->_value.c_str());
+ const HardwareKey *hwKey = hwKeys->findHardwareKey(hwKeyId.c_str());
if (!hwKey) {
- warning("HardwareKey with ID '%s' not known", it->_value.c_str());
- _configDomain->erase(key);
+ warning("HardwareKey with ID '%s' not known", hwKeyId.c_str());
continue;
}
+ if (defaulted) {
+ if (mappedKeys.contains(hwKeyId)) {
+ debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the key is in use", confKey.c_str(), hwKeyId.c_str());
+ continue;
+ }
+ warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwKeyId.c_str());
+ }
+
+ mappedKeys.setVal(hwKeyId, hwKey);
+ // map the key
ua->mapKey(hwKey);
}
}
diff --git a/backends/keymapper/keymapper-defaults.h b/backends/keymapper/keymapper-defaults.h
new file mode 100644
index 0000000..5b84ebe
--- /dev/null
+++ b/backends/keymapper/keymapper-defaults.h
@@ -0,0 +1,56 @@
+/* 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.
+*
+*/
+
+#ifdef ENABLE_KEYMAPPER
+
+#ifndef KEYMAPPER_DEFAULTS_H
+#define KEYMAPPER_DEFAULTS_H
+
+#include "common/scummsys.h"
+#include "common/hashmap.h"
+#include "common/str.h"
+#include "common/hash-str.h"
+
+namespace Common {
+
+class KeymapperDefaultBindings : HashMap<String, String> {
+public:
+ /**
+ * This sets a default hwKey for a given Keymap Action
+ * @param keymapId String representing Keymap id (Keymap.name)
+ * @param actionId String representing Action id (Action.id)
+ * @param hwKeyId String representing the HardwareKey id (HardwareKey.hwKeyId)
+ */
+ void setDefaultBinding(String keymapId, String actionId, String hwKeyId) { setVal(keymapId + "_" + actionId, hwKeyId); }
+ /**
+ * This retrieves the assigned default hwKey for a given Keymap Action
+ * @param keymapId String representing Keymap id (Keymap.name)
+ * @param actionId String representing Action id (Action.id)
+ * @return hwKeyId String representing the HardwareKey id (HardwareKey.hwKeyId)
+ */
+ String getDefaultBinding(String keymapId, String actionId) { return getVal(keymapId + "_" + actionId); }
+};
+
+} //namespace Common
+
+#endif // #ifndef KEYMAPPER_DEFAULTS_H
+#endif // #ifdef ENABLE_KEYMAPPER
diff --git a/common/system.h b/common/system.h
index c5e8214..34c987b 100644
--- a/common/system.h
+++ b/common/system.h
@@ -54,6 +54,7 @@ class WriteStream;
#ifdef ENABLE_KEYMAPPER
class HardwareKeySet;
class Keymap;
+class KeymapperDefaultBindings;
#endif
}
@@ -955,6 +956,15 @@ public:
* See keymapper documentation for further reference.
*/
virtual Common::Keymap *getGlobalKeymap() { return 0; }
+
+ /**
+ * Return platform-specific default keybindings
+ *
+ * @return KeymapperDefaultBindings populated with keybindings
+ *
+ * See keymapper documentation for further reference.
+ */
+ virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return 0; }
#endif
//@}
Commit: e55914c51b205a03879bc3b7c8c698cfc8858d39
https://github.com/scummvm/scummvm/commit/e55914c51b205a03879bc3b7c8c698cfc8858d39
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-15T15:12:52-08:00
Commit Message:
MAEMO: Register Keymapper Keymap Action default bindings
Changed paths:
backends/platform/maemo/maemo.cpp
backends/platform/maemo/maemo.h
diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp
index 77d630f..49fa929 100644
--- a/backends/platform/maemo/maemo.cpp
+++ b/backends/platform/maemo/maemo.cpp
@@ -32,6 +32,7 @@
#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"
@@ -48,6 +49,35 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo()
OSystem_SDL_Maemo::~OSystem_SDL_Maemo() {
delete _eventObserver;
+ delete _keymapperDefaultBindings;
+}
+
+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");
}
void OSystem_SDL_Maemo::initBackend() {
@@ -61,10 +91,15 @@ void OSystem_SDL_Maemo::initBackend() {
if (_eventObserver == 0)
_eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource);
+ if (_keymapperDefaultBindings == 0)
+ _keymapperDefaultBindings = new Common::KeymapperDefaultBindings();
+
ConfMan.set("vkeybdpath", DATA_PATH);
_model = Model(detectModel());
+ registerDefaultKeyBindings(_keymapperDefaultBindings, _model);
+
// Call parent implementation of this method
OSystem_POSIX::initBackend();
initObserver();
diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h
index 3827702..1f3c8b8 100644
--- a/backends/platform/maemo/maemo.h
+++ b/backends/platform/maemo/maemo.h
@@ -44,6 +44,7 @@ public:
#ifdef ENABLE_KEYMAPPER
virtual Common::HardwareKeySet *getHardwareKeySet();
virtual Common::Keymap *getGlobalKeymap();
+ virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return _keymapperDefaultBindings; }
#endif
Model getModel() { return _model; }
@@ -55,6 +56,7 @@ private:
const Model detectModel();
Model _model;
MaemoSdlEventObserver *_eventObserver;
+ Common::KeymapperDefaultBindings *_keymapperDefaultBindings;
};
} // namespace Maemo
Commit: 85c8c84804125599547f8408962656e2686543e9
https://github.com/scummvm/scummvm/commit/85c8c84804125599547f8408962656e2686543e9
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-15T15:22:41-08:00
Commit Message:
KEYMAPPER: Add more warning signs
Changed paths:
backends/events/default/default-events.h
common/system.h
diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h
index 3a8025f..4d89b78 100644
--- a/backends/events/default/default-events.h
+++ b/backends/events/default/default-events.h
@@ -92,6 +92,8 @@ public:
#endif
#ifdef ENABLE_KEYMAPPER
+ // IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use
+ // this, please talk to tsoliman and/or LordHoto.
virtual Common::Keymapper *getKeymapper() { return _keymapper; }
#endif
};
diff --git a/common/system.h b/common/system.h
index 34c987b..85a9f6a 100644
--- a/common/system.h
+++ b/common/system.h
@@ -939,6 +939,8 @@ public:
#ifdef ENABLE_KEYMAPPER
/**
* Register hardware keys with keymapper
+ * IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use
+ * this, please talk to tsoliman and/or LordHoto.
*
* @return HardwareKeySet with all keys and recommended mappings
*
@@ -948,6 +950,8 @@ public:
/**
* Return a platform-specific global keymap
+ * IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use
+ * this, please talk to tsoliman and/or LordHoto.
*
* @return Keymap with actions appropriate for the platform
*
@@ -959,6 +963,8 @@ public:
/**
* Return platform-specific default keybindings
+ * IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use
+ * this, please talk to tsoliman and/or LordHoto.
*
* @return KeymapperDefaultBindings populated with keybindings
*
More information about the Scummvm-git-logs
mailing list