[Scummvm-cvs-logs] scummvm master -> 7f8b7e0916bf6cbbdc15d57f71eceba648034c50

clone2727 clone2727 at gmail.com
Thu Nov 22 05:19:46 CET 2012


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

Summary:
7f8b7e0916 PEGASUS: Add a keymap


Commit: 7f8b7e0916bf6cbbdc15d57f71eceba648034c50
    https://github.com/scummvm/scummvm/commit/7f8b7e0916bf6cbbdc15d57f71eceba648034c50
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-11-21T20:18:08-08:00

Commit Message:
PEGASUS: Add a keymap

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index d32e9dd..b958def 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -33,6 +33,7 @@
 #include "common/textconsole.h"
 #include "common/translation.h"
 #include "common/random.h"
+#include "backends/keymapper/keymapper.h"
 #include "base/plugins.h"
 #include "base/version.h"
 #include "gui/saveload.h"
@@ -151,6 +152,7 @@ Common::Error PegasusEngine::run() {
 	}
 
 	// Set up input
+	initKeymap();
 	InputHandler::setInputHandler(this);
 	allowInput(true);
 
@@ -2349,4 +2351,41 @@ uint PegasusEngine::getNeighborhoodCD(const NeighborhoodID neighborhood) const {
 	return 1;
 }
 
+void PegasusEngine::initKeymap() {
+#ifdef ENABLE_KEYMAPPER
+	static const char *const kKeymapName = "pegasus";
+	Common::Keymapper *const mapper = _eventMan->getKeymapper();
+
+	// Do not try to recreate same keymap over again
+	if (mapper->getKeymap(kKeymapName) != 0)
+		return;
+
+	Common::Keymap *const engineKeyMap = new Common::Keymap(kKeymapName);
+
+	// Since the game has multiple built-in keys for each of these anyway,
+	// this just attempts to remap one of them.
+	const Common::KeyActionEntry keyActionEntries[] = {
+		{ Common::KEYCODE_UP, "UP", _("Up/Forward") },
+		{ Common::KEYCODE_DOWN, "DWN", _("Down/Backward") },
+		{ Common::KEYCODE_LEFT, "TL", _("Turn Left") },
+		{ Common::KEYCODE_RIGHT, "TR", _("Turn Right") },
+		{ Common::KEYCODE_BACKQUOTE, "TIV", _("Toggle Inventory Tray") },
+		{ Common::KEYCODE_BACKSPACE, "TBI", _("Toggle Biochip Tray") },
+		{ Common::KEYCODE_RETURN, "ENT", _("Enter/Select") },
+		{ Common::KEYCODE_t, "TMA", _("Toggle Middle Area") },
+		{ Common::KEYCODE_i, "TIN", _("Toggle Info") },
+		{ Common::KEYCODE_ESCAPE, "PM", _("Activate Pause Menu") },
+		{ Common::KEYCODE_e, "WTF", _("???") } // easter egg key (without being completely upfront about it)
+	};
+
+	for (uint i = 0; i < ARRAYSIZE(keyActionEntries); i++) {
+		Common::Action *const act = new Common::Action(engineKeyMap, keyActionEntries[i].id, keyActionEntries[i].description);
+		act->addKeyEvent(keyActionEntries[i].ks);
+	}
+
+	mapper->addGameKeymap(engineKeyMap);
+	mapper->pushKeymap(kKeymapName, true);
+#endif
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 2a8ba22..a8f2e1f 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -265,6 +265,7 @@ private:
 	void doSubChase();
 	uint getNeighborhoodCD(const NeighborhoodID neighborhood) const;
 	uint _currentCD;
+	void initKeymap();
 
 	// Menu
 	GameMenu *_gameMenu;






More information about the Scummvm-git-logs mailing list