aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/keymapper/keymapper.cpp16
-rw-r--r--backends/keymapper/keymapper.h5
2 files changed, 17 insertions, 4 deletions
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index f950b1f4a2..38711343c2 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -163,9 +163,19 @@ void Keymapper::pushKeymap(Keymap *newMap, bool transparent, bool global) {
_activeMaps.push(mr);
}
-void Keymapper::popKeymap() {
- if (!_activeMaps.empty())
- _activeMaps.pop();
+void Keymapper::popKeymap(const char *name) {
+ if (!_activeMaps.empty()) {
+ if (name) {
+ String topKeymapName = _activeMaps.top().keymap->getName();
+ if (topKeymapName.equals(name))
+ _activeMaps.pop();
+ else
+ warning("An attempt to pop wrong keymap was blocked (expected %s but was %s)", name, topKeymapName.c_str());
+ } else {
+ _activeMaps.pop();
+ }
+ }
+
}
bool Keymapper::notifyEvent(const Common::Event &ev) {
diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h
index cd060a413c..d2aa89cad6 100644
--- a/backends/keymapper/keymapper.h
+++ b/backends/keymapper/keymapper.h
@@ -131,8 +131,11 @@ public:
/**
* Pop the top keymap off the active stack.
+ * @param name (optional) name of keymap expected to be popped
+ * if provided, will not pop unless name is the same
+ * as the top keymap
*/
- void popKeymap();
+ void popKeymap(const char *name = 0);
// Implementation of the EventMapper interface
bool notifyEvent(const Common::Event &ev);