[Scummvm-cvs-logs] scummvm master -> 3f6d549b0e891be33ef48926629d6e626009fc8f

tsoliman tarek at bashasoliman.com
Mon Feb 20 13:57:02 CET 2012


This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e7ade8ae05 KEYMAPPER: EventMapper must now eat all events
5c3e48fddf KEYMAPPER: Create a DefaultEventMapper when Keymapper isn't enabled
c0b04fdcaa KEYMAPPER: Having a mapper is no longer optional
a0ba4eb569 KEYMAPPER: Rewrite the EventMapper API
3c918bb378 KEYMAPPER: Move DefaultEventMapper implementation to its own cpp file
cfe91c8d44 KEYMAPPER: Move CTRL-F5 handling to DefaultEventMapper
3f6d549b0e KEYMAPPER: Move F7 and F8 handling to DefaultEventMapper


Commit: e7ade8ae05aff3669059e6003e046d1ef6e914a3
    https://github.com/scummvm/scummvm/commit/e7ade8ae05aff3669059e6003e046d1ef6e914a3
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-20T04:49:21-08:00

Commit Message:
KEYMAPPER: EventMapper must now eat all events

Changed paths:
    backends/keymapper/keymapper.cpp
    backends/keymapper/keymapper.h
    common/EventDispatcher.cpp



diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 1c83bb8..cda34ff 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -181,12 +181,24 @@ void Keymapper::popKeymap(const char *name) {
 }
 
 bool Keymapper::notifyEvent(const Common::Event &ev) {
+	bool mapped = false;
+
 	if (ev.type == Common::EVENT_KEYDOWN)
-		return mapKeyDown(ev.kbd);
+		mapped = mapKeyDown(ev.kbd);
 	else if (ev.type == Common::EVENT_KEYUP)
-		return mapKeyUp(ev.kbd);
+		mapped = mapKeyUp(ev.kbd);
+
+	if (mapped)
+		return true;
 	else
-		return false;
+		return mapEvent(ev);
+}
+
+bool Keymapper::mapEvent(const Common::Event &ev) {
+	// pass through - copy the event
+	Event evt = ev;
+	addEvent(evt);
+	return true;
 }
 
 bool Keymapper::mapKeyDown(const KeyState& key) {
diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h
index 27e9819..626df01 100644
--- a/backends/keymapper/keymapper.h
+++ b/backends/keymapper/keymapper.h
@@ -164,6 +164,12 @@ public:
 	bool mapKeyUp(const KeyState& key);
 
 	/**
+	 * Map non-key incoming events
+	 * @param ev incoming event
+	 */
+	bool mapEvent(const Common::Event &ev);
+
+	/**
 	 * Enable/disable the keymapper
 	 */
 	void setEnabled(bool enabled) { _enabled = enabled; }
diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp
index 4e3f671..55eea9c 100644
--- a/common/EventDispatcher.cpp
+++ b/common/EventDispatcher.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "common/events.h"
+#include "common/textconsole.h"
 
 namespace Common {
 
@@ -54,18 +55,20 @@ void EventDispatcher::dispatch() {
 			// We only try to process the events via the setup event mapper, when
 			// we have a setup mapper and when the event source allows mapping.
 			if (_mapper && allowMapping) {
-				if (_mapper->notifyEvent(event)) {
-					// We allow the event mapper to create multiple events, when
-					// eating an event.
-					while (_mapper->pollEvent(event))
-						dispatchEvent(event);
-
-					// Try getting another event from the current EventSource.
-					continue;
-				}
+				bool mapped = _mapper->notifyEvent(event);
+				// EventMappers must map all events
+				if (!mapped)
+					error("Event [%u] was not mapped by the EventMapper!", event.type);
+				// We allow the event mapper to create multiple events, when
+				// eating an event.
+				while (_mapper->pollEvent(event))
+					dispatchEvent(event);
+
+				// Try getting another event from the current EventSource.
+				continue;
+			} else {
+				dispatchEvent(event);
 			}
-
-			dispatchEvent(event);
 		}
 	}
 }


Commit: 5c3e48fddf2f021d51e41db1672d7ff543c52426
    https://github.com/scummvm/scummvm/commit/5c3e48fddf2f021d51e41db1672d7ff543c52426
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-20T04:49:22-08:00

Commit Message:
KEYMAPPER: Create a DefaultEventMapper when Keymapper isn't enabled

This allows migration to unconditional mapping

Changed paths:
    backends/events/default/default-events.cpp
    common/events.h



diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp
index 78072b0..074c42f 100644
--- a/backends/events/default/default-events.cpp
+++ b/backends/events/default/default-events.cpp
@@ -60,6 +60,8 @@ DefaultEventManager::DefaultEventManager(Common::EventSource *boss) :
 	// EventDispatcher will automatically free the keymapper
 	_dispatcher.registerMapper(_keymapper);
 	_remap = false;
+#else
+	_dispatcher.registerMapper(new Common::DefaultEventMapper());
 #endif
 }
 
diff --git a/common/events.h b/common/events.h
index ab0c0a5..48854b2 100644
--- a/common/events.h
+++ b/common/events.h
@@ -219,6 +219,11 @@ public:
 	bool allowMapping() const { return false; }
 };
 
+class DefaultEventMapper : public EventMapper, private ArtificialEventSource {
+	bool notifyEvent(const Event &ev) { ArtificialEventSource::addEvent(Event(ev)); return true; }
+	bool pollEvent(Event &ev) { return ArtificialEventSource::pollEvent(ev); }
+};
+
 /**
  * Dispatches events from various sources to various observers.
  *


Commit: c0b04fdcaa0d357a0565a16ea7be74994e55da07
    https://github.com/scummvm/scummvm/commit/c0b04fdcaa0d357a0565a16ea7be74994e55da07
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-20T04:49:22-08:00

Commit Message:
KEYMAPPER: Having a mapper is no longer optional

Changed paths:
    common/EventDispatcher.cpp



diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp
index 55eea9c..6f36ee5 100644
--- a/common/EventDispatcher.cpp
+++ b/common/EventDispatcher.cpp
@@ -54,7 +54,8 @@ void EventDispatcher::dispatch() {
 		while (i->source->pollEvent(event)) {
 			// We only try to process the events via the setup event mapper, when
 			// we have a setup mapper and when the event source allows mapping.
-			if (_mapper && allowMapping) {
+			assert(_mapper);
+			if (allowMapping) {
 				bool mapped = _mapper->notifyEvent(event);
 				// EventMappers must map all events
 				if (!mapped)
@@ -67,7 +68,7 @@ void EventDispatcher::dispatch() {
 				// Try getting another event from the current EventSource.
 				continue;
 			} else {
-				dispatchEvent(event);
+				dispatchEvent(Event(event));
 			}
 		}
 	}


Commit: a0ba4eb569ae9ec0e05a7ba8532ab304e6852f84
    https://github.com/scummvm/scummvm/commit/a0ba4eb569ae9ec0e05a7ba8532ab304e6852f84
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-20T04:49:22-08:00

Commit Message:
KEYMAPPER: Rewrite the EventMapper API

Changed paths:
    backends/keymapper/keymapper.cpp
    backends/keymapper/keymapper.h
    common/EventDispatcher.cpp
    common/events.h



diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index cda34ff..7ada676 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -180,38 +180,35 @@ void Keymapper::popKeymap(const char *name) {
 
 }
 
-bool Keymapper::notifyEvent(const Common::Event &ev) {
-	bool mapped = false;
+List<Event> Keymapper::mapEvent(const Event &ev, EventSource *source) {
+	if (source && !source->allowMapping()) {
+		return DefaultEventMapper::mapEvent(ev, source);
+	}
+
+	List<Event> mappedEvents;
 
 	if (ev.type == Common::EVENT_KEYDOWN)
-		mapped = mapKeyDown(ev.kbd);
+		mappedEvents = mapKeyDown(ev.kbd);
 	else if (ev.type == Common::EVENT_KEYUP)
-		mapped = mapKeyUp(ev.kbd);
+		mappedEvents = mapKeyUp(ev.kbd);
 
-	if (mapped)
-		return true;
+	if (!mappedEvents.empty())
+		return mappedEvents;
 	else
-		return mapEvent(ev);
-}
-
-bool Keymapper::mapEvent(const Common::Event &ev) {
-	// pass through - copy the event
-	Event evt = ev;
-	addEvent(evt);
-	return true;
+		return DefaultEventMapper::mapEvent(ev, source);
 }
 
-bool Keymapper::mapKeyDown(const KeyState& key) {
+List<Event> Keymapper::mapKeyDown(const KeyState& key) {
 	return mapKey(key, true);
 }
 
-bool Keymapper::mapKeyUp(const KeyState& key) {
+List<Event> Keymapper::mapKeyUp(const KeyState& key) {
 	return mapKey(key, false);
 }
 
-bool Keymapper::mapKey(const KeyState& key, bool keyDown) {
+List<Event> Keymapper::mapKey(const KeyState& key, bool keyDown) {
 	if (!_enabled || _activeMaps.empty())
-		return false;
+		return List<Event>();
 
 	Action *action = 0;
 
@@ -238,11 +235,9 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) {
 	}
 
 	if (!action)
-		return false;
+		return List<Event>();
 
-	executeAction(action, keyDown);
-
-	return true;
+	return executeAction(action, keyDown);
 }
 
 Action *Keymapper::getAction(const KeyState& key) {
@@ -251,7 +246,8 @@ Action *Keymapper::getAction(const KeyState& key) {
 	return action;
 }
 
-void Keymapper::executeAction(const Action *action, bool keyDown) {
+List<Event> Keymapper::executeAction(const Action *action, bool keyDown) {
+	List<Event> mappedEvents;
 	List<Event>::const_iterator it;
 
 	for (it = action->events.begin(); it != action->events.end(); ++it) {
@@ -291,8 +287,9 @@ void Keymapper::executeAction(const Action *action, bool keyDown) {
 		}
 
 		evt.mouse = _eventMan->getMousePos();
-		addEvent(evt);
+		mappedEvents.push_back(evt);
 	}
+	return mappedEvents;
 }
 
 const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) {
diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h
index 626df01..31bfcbc 100644
--- a/backends/keymapper/keymapper.h
+++ b/backends/keymapper/keymapper.h
@@ -39,7 +39,7 @@ namespace Common {
 const char *const kGuiKeymapName = "gui";
 const char *const kGlobalKeymapName = "global";
 
-class Keymapper : public Common::EventMapper, private Common::ArtificialEventSource {
+class Keymapper : public Common::DefaultEventMapper {
 public:
 
 	struct MapRecord {
@@ -77,6 +77,9 @@ public:
 	Keymapper(EventManager *eventMan);
 	~Keymapper();
 
+	// EventMapper interface
+	virtual List<Event> mapEvent(const Event &ev, EventSource *source);
+
 	/**
 	 * Registers a HardwareKeySet with the Keymapper
 	 * @note should only be called once (during backend initialisation)
@@ -137,37 +140,27 @@ public:
 	 */
 	void popKeymap(const char *name = 0);
 
-	// Implementation of the EventMapper interface
-	bool notifyEvent(const Common::Event &ev);
-	bool pollEvent(Common::Event &ev) { return Common::ArtificialEventSource::pollEvent(ev); }
-
 	/**
 	 * @brief Map a key press event.
 	 * If the active keymap contains a Action mapped to the given key, then
 	 * the Action's events are pushed into the EventManager's event queue.
 	 * @param key		key that was pressed
 	 * @param keyDown	true for key down, false for key up
-	 * @return			true if key was mapped
+	 * @return			mapped events
 	 */
-	bool mapKey(const KeyState& key, bool keyDown);
+	List<Event> mapKey(const KeyState& key, bool keyDown);
 
 	/**
 	 * @brief Map a key down event.
 	 * @see mapKey
 	 */
-	bool mapKeyDown(const KeyState& key);
+	List<Event> mapKeyDown(const KeyState& key);
 
 	/**
 	 * @brief Map a key up event.
 	 * @see mapKey
 	 */
-	bool mapKeyUp(const KeyState& key);
-
-	/**
-	 * Map non-key incoming events
-	 * @param ev incoming event
-	 */
-	bool mapEvent(const Common::Event &ev);
+	List<Event> mapKeyUp(const KeyState& key);
 
 	/**
 	 * Enable/disable the keymapper
@@ -195,7 +188,7 @@ private:
 	void pushKeymap(Keymap *newMap, bool transparent, bool global);
 
 	Action *getAction(const KeyState& key);
-	void executeAction(const Action *act, bool keyDown);
+	List<Event> executeAction(const Action *act, bool keyDown);
 
 	EventManager *_eventMan;
 
diff --git a/common/EventDispatcher.cpp b/common/EventDispatcher.cpp
index 6f36ee5..4c7286b 100644
--- a/common/EventDispatcher.cpp
+++ b/common/EventDispatcher.cpp
@@ -21,7 +21,6 @@
  */
 
 #include "common/events.h"
-#include "common/textconsole.h"
 
 namespace Common {
 
@@ -49,26 +48,15 @@ void EventDispatcher::dispatch() {
 	dispatchPoll();
 
 	for (List<SourceEntry>::iterator i = _sources.begin(); i != _sources.end(); ++i) {
-		const bool allowMapping = i->source->allowMapping();
-
 		while (i->source->pollEvent(event)) {
 			// We only try to process the events via the setup event mapper, when
 			// we have a setup mapper and when the event source allows mapping.
 			assert(_mapper);
-			if (allowMapping) {
-				bool mapped = _mapper->notifyEvent(event);
-				// EventMappers must map all events
-				if (!mapped)
-					error("Event [%u] was not mapped by the EventMapper!", event.type);
-				// We allow the event mapper to create multiple events, when
-				// eating an event.
-				while (_mapper->pollEvent(event))
-					dispatchEvent(event);
-
-				// Try getting another event from the current EventSource.
-				continue;
-			} else {
-				dispatchEvent(Event(event));
+			List<Event> mappedEvents = _mapper->mapEvent(event, i->source);
+
+			for (List<Event>::iterator j = mappedEvents.begin(); j != mappedEvents.end(); ++j) {
+				const Event mappedEvent = *j;
+				dispatchEvent(mappedEvent);
 			}
 		}
 	}
diff --git a/common/events.h b/common/events.h
index 48854b2..fec4d37 100644
--- a/common/events.h
+++ b/common/events.h
@@ -213,15 +213,25 @@ public:
  *
  * An example for this is the Keymapper.
  */
-class EventMapper : public EventSource, public EventObserver {
+class EventMapper {
 public:
-	/** For event mappers resulting events should never be mapped */
-	bool allowMapping() const { return false; }
+	virtual ~EventMapper() {}
+
+	/**
+	 * Map an incoming event to one or more action events
+	 */
+	virtual List<Event> mapEvent(const Event &ev, EventSource *source) = 0;
 };
 
-class DefaultEventMapper : public EventMapper, private ArtificialEventSource {
-	bool notifyEvent(const Event &ev) { ArtificialEventSource::addEvent(Event(ev)); return true; }
-	bool pollEvent(Event &ev) { return ArtificialEventSource::pollEvent(ev); }
+class DefaultEventMapper : public EventMapper {
+public:
+	// EventMapper interface
+	virtual List<Event> mapEvent(const Event &ev, EventSource *source) {
+		List<Event> events;
+		// just pass it through
+		events.push_back(ev);
+		return events;
+	}
 };
 
 /**


Commit: 3c918bb378b2204e38cfc16e10a3c2c0e130d9f4
    https://github.com/scummvm/scummvm/commit/3c918bb378b2204e38cfc16e10a3c2c0e130d9f4
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-20T04:49:22-08:00

Commit Message:
KEYMAPPER: Move DefaultEventMapper implementation to its own cpp file

Changed paths:
  A common/EventMapper.cpp
    common/events.h
    common/module.mk



diff --git a/common/EventMapper.cpp b/common/EventMapper.cpp
new file mode 100644
index 0000000..be55c6b
--- /dev/null
+++ b/common/EventMapper.cpp
@@ -0,0 +1,35 @@
+/* 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.
+ *
+ */
+
+#include "common/events.h"
+
+namespace Common {
+
+List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
+	List<Event> events;
+	// just pass it through
+	events.push_back(ev);
+	return events;
+}
+
+
+} // namespace Common
diff --git a/common/events.h b/common/events.h
index fec4d37..5e539f0 100644
--- a/common/events.h
+++ b/common/events.h
@@ -226,12 +226,7 @@ public:
 class DefaultEventMapper : public EventMapper {
 public:
 	// EventMapper interface
-	virtual List<Event> mapEvent(const Event &ev, EventSource *source) {
-		List<Event> events;
-		// just pass it through
-		events.push_back(ev);
-		return events;
-	}
+	virtual List<Event> mapEvent(const Event &ev, EventSource *source);
 };
 
 /**
diff --git a/common/module.mk b/common/module.mk
index 7434df7..ae5e41c 100644
--- a/common/module.mk
+++ b/common/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS := \
 	debug.o \
 	error.o \
 	EventDispatcher.o \
+	EventMapper.o \
 	EventRecorder.o \
 	file.o \
 	fs.o \


Commit: cfe91c8d444b8535c30d6766821ee4eeb4108b07
    https://github.com/scummvm/scummvm/commit/cfe91c8d444b8535c30d6766821ee4eeb4108b07
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-20T04:49:22-08:00

Commit Message:
KEYMAPPER: Move CTRL-F5 handling to DefaultEventMapper

Changed paths:
    backends/events/default/default-events.cpp
    common/EventMapper.cpp



diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp
index 074c42f..3930038 100644
--- a/backends/events/default/default-events.cpp
+++ b/backends/events/default/default-events.cpp
@@ -104,35 +104,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {
 
 			// Global Main Menu
 			if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_F5) {
-				if (g_engine && !g_engine->isPaused()) {
-					Common::Event menuEvent;
-					menuEvent.type = Common::EVENT_MAINMENU;
-
-					// FIXME: GSoC RTL branch passes the F6 key event to the
-					// engine, and also enqueues a EVENT_MAINMENU. For now,
-					// we just drop the key event and return an EVENT_MAINMENU
-					// instead. This way, we don't have to add special cases
-					// to engines (like it was the case for LURE in the RTL branch).
-					//
-					// However, this has other consequences, possibly negative ones.
-					// Like, what happens with key repeat for the trigger key?
-
-					//pushEvent(menuEvent);
-					event = menuEvent;
-
-					// FIXME: Since now we do not push another MAINMENU event onto
-					// our event stack, the GMM would never open, so we have to do
-					// that here. Of course when the engine would handle MAINMENU
-					// as an event now and open up the GMM itself it would open the
-					// menu twice.
-					if (g_engine && !g_engine->isPaused())
-						g_engine->openMainMenuDialog();
-
-					if (_shouldQuit)
-						event.type = Common::EVENT_QUIT;
-					else if (_shouldRTL)
-						event.type = Common::EVENT_RTL;
-				}
+				//do nothing - EventMapper handles this case for us
 			}
 #ifdef ENABLE_VKEYBD
 			else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.hasFlags(0)) {
diff --git a/common/EventMapper.cpp b/common/EventMapper.cpp
index be55c6b..6af27b8 100644
--- a/common/EventMapper.cpp
+++ b/common/EventMapper.cpp
@@ -26,8 +26,15 @@ namespace Common {
 
 List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
 	List<Event> events;
-	// just pass it through
-	events.push_back(ev);
+	Event mappedEvent;
+	if (ev.type == EVENT_KEYDOWN && ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F5) {
+		mappedEvent.type = EVENT_MAINMENU;
+	}
+	else {
+		// just pass it through
+		mappedEvent = ev;
+	}
+	events.push_back(mappedEvent);
 	return events;
 }
 


Commit: 3f6d549b0e891be33ef48926629d6e626009fc8f
    https://github.com/scummvm/scummvm/commit/3f6d549b0e891be33ef48926629d6e626009fc8f
Author: Tarek Soliman (tsoliman at scummvm.org)
Date: 2012-02-20T04:49:22-08:00

Commit Message:
KEYMAPPER: Move F7 and F8 handling to DefaultEventMapper

Changed paths:
    backends/events/default/default-events.cpp
    base/main.cpp
    common/EventMapper.cpp
    common/events.h
    gui/gui-manager.cpp



diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp
index 3930038..99d12c7 100644
--- a/backends/events/default/default-events.cpp
+++ b/backends/events/default/default-events.cpp
@@ -102,39 +102,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {
 			_currentKeyDown.flags = event.kbd.flags;
 			_keyRepeatTime = time + kKeyRepeatInitialDelay;
 
-			// Global Main Menu
-			if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_F5) {
-				//do nothing - EventMapper handles this case for us
-			}
-#ifdef ENABLE_VKEYBD
-			else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.hasFlags(0)) {
-				if (_vk->isDisplaying()) {
-					_vk->close(true);
-				} else {
-					if (g_engine)
-						g_engine->pauseEngine(true);
-					_vk->show();
-					if (g_engine)
-						g_engine->pauseEngine(false);
-					result = false;
-				}
-			}
-#endif
-#ifdef ENABLE_KEYMAPPER
-			else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.hasFlags(0)) {
-				if (!_remap) {
-					_remap = true;
-					Common::RemapDialog _remapDialog;
-					if (g_engine)
-						g_engine->pauseEngine(true);
-					_remapDialog.runModal();
-					if (g_engine)
-						g_engine->pauseEngine(false);
-					_remap = false;
-				}
-			}
-#endif
-			else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) {
+			if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) {
 				// WORKAROUND: Some engines incorrectly attempt to use the
 				// ascii value instead of the keycode to detect the backspace
 				// key (a non-portable behavior). This fails at least on
@@ -188,7 +156,34 @@ bool DefaultEventManager::pollEvent(Common::Event &event) {
 			else if (_shouldRTL)
 				event.type = Common::EVENT_RTL;
 			break;
-
+#ifdef ENABLE_VKEYBD
+		case Common::EVENT_VIRTUAL_KEYBOARD:
+			if (_vk->isDisplaying()) {
+				_vk->close(true);
+			} else {
+				if (g_engine)
+					g_engine->pauseEngine(true);
+				_vk->show();
+				if (g_engine)
+					g_engine->pauseEngine(false);
+				result = false;
+			}
+			break;
+#endif
+#ifdef ENABLE_KEYMAPPER
+		case Common::EVENT_KEYMAPPER_REMAP:
+			if (!_remap) {
+				_remap = true;
+				Common::RemapDialog _remapDialog;
+				if (g_engine)
+					g_engine->pauseEngine(true);
+				_remapDialog.runModal();
+				if (g_engine)
+					g_engine->pauseEngine(false);
+				_remap = false;
+			}
+			break;
+#endif
 		case Common::EVENT_RTL:
 			if (ConfMan.getBool("confirm_exit")) {
 				if (g_engine)
diff --git a/base/main.cpp b/base/main.cpp
index 81f9b91..9e4a500 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -286,11 +286,13 @@ static void setupKeymapper(OSystem &system) {
 	act = new Action(primaryGlobalKeymap, "SKLI", _("Skip line"));
 	act->addKeyEvent(KeyState(KEYCODE_PERIOD, '.', 0));
 
+#ifdef ENABLE_VKEYBD
 	act = new Action(primaryGlobalKeymap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType);
-	act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
+	act->addEvent(EVENT_VIRTUAL_KEYBOARD);
+#endif
 
 	act = new Action(primaryGlobalKeymap, "REMP", _("Remap keys"), kKeyRemapActionType);
-	act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0));
+	act->addEvent(EVENT_KEYMAPPER_REMAP);
 
 	act = new Action(primaryGlobalKeymap, "FULS", _("Toggle FullScreen"));
 	act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));
diff --git a/common/EventMapper.cpp b/common/EventMapper.cpp
index 6af27b8..2808a7b 100644
--- a/common/EventMapper.cpp
+++ b/common/EventMapper.cpp
@@ -27,13 +27,25 @@ namespace Common {
 List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
 	List<Event> events;
 	Event mappedEvent;
-	if (ev.type == EVENT_KEYDOWN && ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F5) {
-		mappedEvent.type = EVENT_MAINMENU;
+	if (ev.type == EVENT_KEYDOWN) {
+		if (ev.kbd.hasFlags(KBD_CTRL) && ev.kbd.keycode == KEYCODE_F5) {
+			mappedEvent.type = EVENT_MAINMENU;
+		}
+#ifdef ENABLE_VKEYBD
+		else if (ev.kbd.keycode == KEYCODE_F7 && ev.kbd.hasFlags(0)) {
+			mappedEvent.type = EVENT_VIRTUAL_KEYBOARD;
+		}
+#endif
+#ifdef ENABLE_KEYMAPPER
+		else if (ev.kbd.keycode == KEYCODE_F8 && ev.kbd.hasFlags(0)) {
+			mappedEvent.type = EVENT_KEYMAPPER_REMAP;
+		}
+#endif
 	}
-	else {
-		// just pass it through
+
+	// if it didn't get mapped, just pass it through
+	if (mappedEvent.type == EVENT_INVALID)
 		mappedEvent = ev;
-	}
 	events.push_back(mappedEvent);
 	return events;
 }
diff --git a/common/events.h b/common/events.h
index 5e539f0..69cca9b 100644
--- a/common/events.h
+++ b/common/events.h
@@ -78,7 +78,12 @@ enum EventType {
 	,
 	// IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use
 	// this, please talk to tsoliman and/or LordHoto.
-	EVENT_CUSTOM_BACKEND = 18
+	EVENT_CUSTOM_BACKEND = 18,
+	EVENT_KEYMAPPER_REMAP = 19
+#endif
+#ifdef ENABLE_VKEYBD
+	,
+	EVENT_VIRTUAL_KEYBOARD = 20
 #endif
 };
 
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 465af54..5f30738 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -118,11 +118,13 @@ void GuiManager::initKeymap() {
 	act = new Action(guiMap, "CLIK", _("Mouse click"), kLeftClickActionType);
 	act->addLeftClickEvent();
 
+#ifdef ENABLE_VKEYBD
 	act = new Action(guiMap, "VIRT", _("Display keyboard"), kVirtualKeyboardActionType);
-	act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0));
+	act->addEvent(EVENT_VIRTUAL_KEYBOARD);
+#endif
 
 	act = new Action(guiMap, "REMP", _("Remap keys"), kKeyRemapActionType);
-	act->addKeyEvent(KeyState(KEYCODE_F8, ASCII_F8, 0));
+	act->addEvent(EVENT_KEYMAPPER_REMAP);
 
 	act = new Action(guiMap, "FULS", _("Toggle FullScreen"));
 	act->addKeyEvent(KeyState(KEYCODE_RETURN, ASCII_RETURN, KBD_ALT));






More information about the Scummvm-git-logs mailing list