[Scummvm-git-logs] scummvm master -> f09dd12a7e0c6bd2c9354e5eeeb771881488f27c

bluegr noreply at scummvm.org
Sun Jul 28 19:02:50 UTC 2024


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:
f09dd12a7e LURE: Add keymapper support


Commit: f09dd12a7e0c6bd2c9354e5eeeb771881488f27c
    https://github.com/scummvm/scummvm/commit/f09dd12a7e0c6bd2c9354e5eeeb771881488f27c
Author: NabeelShabbir (i210443 at nu.edu.pk)
Date: 2024-07-28T22:02:47+03:00

Commit Message:
LURE: Add keymapper support

Changed paths:
    engines/lure/animseq.cpp
    engines/lure/events.cpp
    engines/lure/events.h
    engines/lure/fights.cpp
    engines/lure/game.cpp
    engines/lure/intro.cpp
    engines/lure/lure.h
    engines/lure/menu.cpp
    engines/lure/metaengine.cpp
    engines/lure/sound.cpp
    engines/lure/surface.cpp


diff --git a/engines/lure/animseq.cpp b/engines/lure/animseq.cpp
index 0b83a0f2183..cc1c4e47db0 100644
--- a/engines/lure/animseq.cpp
+++ b/engines/lure/animseq.cpp
@@ -39,8 +39,8 @@ AnimAbortType AnimationSequence::delay(uint32 milliseconds) {
 
 	while (g_system->getMillis() < delayCtr) {
 		while (events.pollEvent()) {
-			if ((events.type() == Common::EVENT_KEYDOWN) && (events.event().kbd.ascii != 0)) {
-				if (events.event().kbd.keycode == Common::KEYCODE_ESCAPE)
+			if ((events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START) && (events.event().customType != kActionNone)) {
+				if (events.event().customType == kActionEscape)
 					return ABORT_END_INTRO;
 				else
 					return ABORT_NEXT_SCENE;
diff --git a/engines/lure/events.cpp b/engines/lure/events.cpp
index 7bc893becbd..ccffda32023 100644
--- a/engines/lure/events.cpp
+++ b/engines/lure/events.cpp
@@ -185,7 +185,8 @@ void Events::waitForPress() {
 	while (!keyButton) {
 		while (pollEvent()) {
 			if ((_event.type == Common::EVENT_QUIT) || (_event.type == Common::EVENT_RETURN_TO_LAUNCHER)) return;
-			else if ((_event.type == Common::EVENT_KEYDOWN) && (_event.kbd.ascii != 0))
+			else if (((_event.type == Common::EVENT_KEYDOWN) && (_event.kbd.ascii != 0)) ||
+					 ((_event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START) && (_event.customType != kActionNone)))
 				keyButton = true;
 			else if ((_event.type == Common::EVENT_LBUTTONDOWN) ||
 				(_event.type == Common::EVENT_MBUTTONDOWN) ||
@@ -212,6 +213,7 @@ bool Events::interruptableDelay(uint32 milliseconds) {
 
 		if (events.pollEvent()) {
 			if (((events.type() == Common::EVENT_KEYDOWN) && (events.event().kbd.ascii != 0)) ||
+				((events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START) && (events.customType() != kActionNone)) ||
 				(events.type() == Common::EVENT_LBUTTONDOWN))
 				return true;
 		}
diff --git a/engines/lure/events.h b/engines/lure/events.h
index d5d4f79f834..666527d3dd0 100644
--- a/engines/lure/events.h
+++ b/engines/lure/events.h
@@ -71,6 +71,7 @@ public:
 
 	Common::Event event() { return _event; }
 	Common::EventType type() { return _event.type; }
+	Common::CustomEventType customType() { return _event.customType; };
 };
 
 } // End of namespace Lure
diff --git a/engines/lure/fights.cpp b/engines/lure/fights.cpp
index d9c19c21dd2..6024b4b7372 100644
--- a/engines/lure/fights.cpp
+++ b/engines/lure/fights.cpp
@@ -170,16 +170,16 @@ void FightsManager::reset() {
 const CursorType moveList[] = {CURSOR_LEFT_ARROW, CURSOR_FIGHT_UPPER,
 	CURSOR_FIGHT_MIDDLE, CURSOR_FIGHT_LOWER, CURSOR_RIGHT_ARROW};
 
-struct KeyMapping {
-	Common::KeyCode keycode;
+struct ActionMapping {
+	Common::CustomEventType customAction;
 	uint8 moveNumber;
 };
 
-const KeyMapping keyList[] = {
-	{Common::KEYCODE_LEFT, 10}, {Common::KEYCODE_RIGHT, 14},
-	{Common::KEYCODE_KP7, 11}, {Common::KEYCODE_KP4, 12}, {Common::KEYCODE_KP1, 13},
-	{Common::KEYCODE_KP9, 6},  {Common::KEYCODE_KP6, 7},  {Common::KEYCODE_KP3, 8},
-	{Common::KEYCODE_INVALID, 0}};
+const ActionMapping actionList[] = {
+	{kActionFightMoveLeft, 10}, {kActionFightMoveRight, 14},
+	{kActionFightCursorLeftTop, 11}, {kActionFightCursorLeftMiddle, 12}, {kActionFightCursorLeftBottom, 13},
+	{kActionFightCursorRightTop, 6},  {kActionFightCursorRightMiddle, 7},  {kActionFightCursorRightBottom, 8},
+	{kActionNone, 0}};
 
 void FightsManager::checkEvents() {
 	LureEngine &engine = LureEngine::getReference();
@@ -190,26 +190,25 @@ void FightsManager::checkEvents() {
 	int moveNumber = 0;
 
 	while ((moveNumber == 0) && events.pollEvent()) {
-
-		if (events.type() == Common::EVENT_KEYDOWN) {
-			switch (events.event().kbd.keycode) {
-			case Common::KEYCODE_ESCAPE:
+		if (events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
+			switch (events.event().customType) {
+			case kActionEscape:
 				engine.quitGame();
 				return;
-
 			default:
 				// Scan through the mapping list for a move for the keypress
-				const KeyMapping *keyPtr = &keyList[0];
-				while ((keyPtr->keycode != Common::KEYCODE_INVALID) &&
-					(keyPtr->keycode != events.event().kbd.keycode))
-					++keyPtr;
-				if (keyPtr->keycode != Common::KEYCODE_INVALID) {
-					moveNumber = keyPtr->moveNumber;
+				const ActionMapping *actionPtr = &actionList[0];
+				while ((actionPtr->customAction != kActionNone) &&
+					   (actionPtr->customAction != events.event().customType))
+					++actionPtr;
+				if (actionPtr->customAction != kActionNone) {
+					moveNumber = actionPtr->moveNumber;
 					_keyDown = KS_KEYDOWN_1;
 				}
+
 			}
 
-		} else if (events.type() == Common::EVENT_KEYUP) {
+		} else if (events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_END) {
 			_keyDown = KS_UP;
 
 		} else if (events.type() == Common::EVENT_MOUSEMOVE) {
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index 253be974a5b..cb85286eaec 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -29,6 +29,8 @@
 #include "lure/sound.h"
 #include "lure/strings.h"
 
+#include "backends/keymapper/keymapper.h"
+
 #include "common/config-manager.h"
 #include "common/system.h"
 
@@ -50,7 +52,6 @@ Game::Game() {
 	_fastTextFlag = false;
 	_preloadFlag = false;
 	_debugFlag = gDebugLevel >= ERROR_BASIC;
-
 	_soundFlag = true;
 }
 
@@ -185,25 +186,40 @@ void Game::execute() {
 			}
 
 			while (events.pollEvent()) {
-				if (events.type() == Common::EVENT_KEYDOWN) {
-					uint16 roomNum = room.roomNumber();
-
-					// Handle special keys
+				// Handle special keys
+				if (events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
 					bool handled = true;
-					switch (events.event().kbd.keycode) {
-					case Common::KEYCODE_F5:
+					switch (events.customType()) {
+					case kActionSaveGame:
 						if (isMenuAvailable())
 							SaveRestoreDialog::show(true);
 						break;
 
-					case Common::KEYCODE_F7:
+					case kActionRestoreGame:
 						SaveRestoreDialog::show(false);
 						break;
 
-					case Common::KEYCODE_F9:
+					case kActionRestartGame:
 						doRestart();
 						break;
 
+					case kActionEscape:
+						doQuit();
+						break;
+
+					default:
+						handled = false;
+					}
+					if (handled)
+						continue;
+				}
+
+				if (events.type() == Common::EVENT_KEYDOWN) {
+					uint16 roomNum = room.roomNumber();
+
+					// Handle special keys
+					bool handled = true;
+					switch (events.event().kbd.keycode) {
 					case Common::KEYCODE_KP_PLUS:
 						if (_debugFlag) {
 							while (++roomNum <= 51)
@@ -234,10 +250,6 @@ void Game::execute() {
 							room.setShowInfo(!room.showInfo());
 						break;
 
-					case Common::KEYCODE_ESCAPE:
-						doQuit();
-						break;
-
 					default:
 						handled = false;
 					}
@@ -1028,13 +1040,6 @@ bool Game::getYN() {
 	Resources &res = Resources::getReference();
 	LureEngine &engine = LureEngine::getReference();
 
-	Common::Language l = LureEngine::getReference().getLanguage();
-	Common::KeyCode y = Common::KEYCODE_y;
-	if (l == Common::FR_FRA) y = Common::KEYCODE_o;
-	else if ((l == Common::DE_DEU) || (l == Common::NL_NLD)) y = Common::KEYCODE_j;
-	else if ((l == Common::ES_ESP) || (l == Common::IT_ITA)) y = Common::KEYCODE_s;
-	else if (l == Common::RU_RUS) y = Common::KEYCODE_l;
-
 	bool vKbdFlag = g_system->hasFeature(OSystem::kFeatureVirtualKeyboard);
 	if (!vKbdFlag)
 		mouse.cursorOff();
@@ -1048,19 +1053,17 @@ bool Game::getYN() {
 	bool breakFlag = false;
 	bool result = false;
 
+	Common::Keymapper *keymapper = LureEngine::getReference().getEventManager()->getKeymapper();
+	keymapper->getKeymap("yesno-shortcut")->setEnabled(true);
+
 	do {
 		while (events.pollEvent()) {
-			if (events.event().type == Common::EVENT_KEYDOWN) {
-				Common::KeyCode key = events.event().kbd.keycode;
-				if (l == Common::RU_RUS) {
-					if ((key == y) || (key == Common::KEYCODE_y) || (key == Common::KEYCODE_ESCAPE)) {
-						breakFlag = true;
-						result = key == y;
-					}
-				} else if ((key == y) || (key == Common::KEYCODE_n) ||
-					(key == Common::KEYCODE_ESCAPE)) {
+			if (events.event().type == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
+				Common::CustomEventType key = events.event().customType;
+				if ((key == kActionYes) || (key == kActionNo) ||
+					(key == kActionEscape)) {
 					breakFlag = true;
-					result = key == y;
+					result = key == kActionYes;
 				}
 			}
 			if (events.event().type == Common::EVENT_LBUTTONUP) {
@@ -1076,6 +1079,8 @@ bool Game::getYN() {
 		g_system->delayMillis(10);
 	} while (!engine.shouldQuit() && !breakFlag);
 
+	keymapper->getKeymap("yesno-shortcut")->setEnabled(false);
+
 	screen.update();
 	if (!vKbdFlag)
 		mouse.cursorOn();
diff --git a/engines/lure/intro.cpp b/engines/lure/intro.cpp
index 96a1f0d44ff..a955ed5ddad 100644
--- a/engines/lure/intro.cpp
+++ b/engines/lure/intro.cpp
@@ -95,8 +95,8 @@ bool Introduction::interruptableDelay(uint32 milliseconds) {
 	Events &events = Events::getReference();
 
 	if (events.interruptableDelay(milliseconds)) {
-		if (events.type() == Common::EVENT_KEYDOWN)
-			return events.event().kbd.keycode == 27;
+		if (events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START) 
+			return events.event().customType == kActionEscape;
 		else if (LureEngine::getReference().shouldQuit())
 			return true;
 		else if (events.type() == Common::EVENT_LBUTTONDOWN)
diff --git a/engines/lure/lure.h b/engines/lure/lure.h
index 32c08214526..27c47926483 100644
--- a/engines/lure/lure.h
+++ b/engines/lure/lure.h
@@ -64,6 +64,28 @@ enum LureLanguage {
 	LANG_UNKNOWN = -1
 };
 
+enum LUREActions {
+	kActionNone,
+	kActionSaveGame,
+	kActionRestoreGame,
+	kActionRestartGame,
+	kActionQuitGame,
+	kActionEscape,
+	kActionFightMoveLeft,
+	kActionFightMoveRight,
+	kActionFightCursorLeftTop,
+	kActionFightCursorLeftMiddle,
+	kActionFightCursorLeftBottom,
+	kActionFightCursorRightTop,
+	kActionFightCursorRightMiddle,
+	kActionFightCursorRightBottom,
+	kActionIndexNext,
+	kActionIndexPrevious,
+	kActionIndexSelect,
+	kActionYes,
+	kActionNo
+};
+
 struct LureGameDescription;
 
 class LureEngine : public Engine {
diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp
index 7ebd69e00f7..1fbcec31ad3 100644
--- a/engines/lure/menu.cpp
+++ b/engines/lure/menu.cpp
@@ -575,20 +575,20 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) {
 					++selectedIndex;
 					refreshFlag = true;
 				}
-			} else if (e.type() == Common::EVENT_KEYDOWN) {
-				uint16 keycode = e.event().kbd.keycode;
+			} else if (e.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
+				uint16 keycode = e.event().customType;
 
-				if (((keycode == Common::KEYCODE_KP8) || (keycode == Common::KEYCODE_UP)) && (selectedIndex > 0)) {
+				if ((keycode == kActionIndexPrevious) && (selectedIndex > 0)) {
 					--selectedIndex;
 					refreshFlag = true;
-				} else if (((keycode == Common::KEYCODE_KP2) || (keycode == Common::KEYCODE_DOWN)) &&
+				} else if ((keycode == kActionIndexNext) &&
 						(selectedIndex < numEntries-1)) {
 					++selectedIndex;
 					refreshFlag = true;
-				} else if ((keycode == Common::KEYCODE_RETURN) || (keycode == Common::KEYCODE_KP_ENTER)) {
+				} else if (keycode == kActionIndexSelect) {
 					bailOut = true;
 					break;
-				} else if (keycode == Common::KEYCODE_ESCAPE) {
+				} else if (keycode == kActionEscape) {
 					selectedIndex = 0xffff;
 					bailOut = true;
 					break;
diff --git a/engines/lure/metaengine.cpp b/engines/lure/metaengine.cpp
index 878c6c84b9d..d95c1c664d6 100644
--- a/engines/lure/metaengine.cpp
+++ b/engines/lure/metaengine.cpp
@@ -23,6 +23,10 @@
 #include "common/system.h"
 #include "common/translation.h"
 
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/standard-actions.h"
+
 #include "engines/advancedDetector.h"
 
 #include "lure/lure.h"
@@ -96,6 +100,8 @@ public:
 	SaveStateList listSaves(const char *target) const override;
 	int getMaximumSaveSlot() const override;
 	void removeSaveState(const char *target, int slot) const override;
+
+	Common::KeymapArray initKeymaps(const char *target) const override;
 };
 
 bool LureMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -155,6 +161,174 @@ void LureMetaEngine::removeSaveState(const char *target, int slot) const {
 	g_system->getSavefileManager()->removeSavefile(filename);
 }
 
+Common::KeymapArray LureMetaEngine::initKeymaps(const char *target) const {
+	using namespace Common;
+	using namespace Lure;
+
+	Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "lure-default", _("Default keymappings"));
+	Keymap *gameKeyMap = new Keymap(Keymap::kKeymapTypeGame, "game-shortcuts", _("Game keymappings"));
+	Keymap *fightKeyMap = new Keymap(Keymap::kKeymapTypeGame, "fight-shortcut", _("Fight sequence keymappings"));
+	Keymap *indexKeyMap = new Keymap(Keymap::kKeymapTypeGame, "index-shortcut", _("Index keymappings"));
+	Keymap *yesNoKeyMap = new Keymap(Keymap::kKeymapTypeGame, "yesno-shortcut", _("Yes/No keymappings"));
+
+	Common::Action *act;
+
+	{
+		act = new Common::Action(kStandardActionLeftClick, _("Left click"));
+		act->setLeftClickEvent();
+		act->addDefaultInputMapping("MOUSE_LEFT");
+		act->addDefaultInputMapping("JOY_A");
+		engineKeyMap->addAction(act);
+
+		act = new Common::Action(kStandardActionRightClick, _("Right click"));
+		act->setRightClickEvent();
+		act->addDefaultInputMapping("MOUSE_RIGHT");
+		act->addDefaultInputMapping("JOY_B");
+		engineKeyMap->addAction(act);
+	}
+
+	{
+		act = new Common::Action("SAVEGAME", _("Save game"));
+		act->setCustomEngineActionEvent(kActionSaveGame);
+		act->addDefaultInputMapping("F5");
+		act->addDefaultInputMapping("JOY_Y");
+		gameKeyMap->addAction(act);
+
+		act = new Common::Action("RESTOREGAME", _("Restore game"));
+		act->setCustomEngineActionEvent(kActionRestoreGame);
+		act->addDefaultInputMapping("F7");
+		act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
+		gameKeyMap->addAction(act);
+
+		act = new Common::Action("RESTARTGAME", _("Restart game"));
+		act->setCustomEngineActionEvent(kActionRestartGame);
+		act->addDefaultInputMapping("F9");
+		act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
+		gameKeyMap->addAction(act);
+
+		act = new Common::Action("ESC", _("Escape"));
+		act->setCustomEngineActionEvent(kActionEscape);
+		act->addDefaultInputMapping("ESCAPE");
+		act->addDefaultInputMapping("JOY_X");
+		gameKeyMap->addAction(act);
+	}
+
+	{
+		// I18N: Move actor left during fight
+		act = new Common::Action("MOVELEFT", _("Move left"));
+		act->setCustomEngineActionEvent(kActionFightMoveLeft);
+		act->addDefaultInputMapping("LEFT");
+		act->addDefaultInputMapping("JOY_LEFT");
+		fightKeyMap->addAction(act);
+
+		
+		// I18N: Move actor right during fight
+		act = new Common::Action("MOVERIGHT", _("Move right"));
+		act->setCustomEngineActionEvent(kActionFightMoveRight);
+		act->addDefaultInputMapping("RIGHT");
+		act->addDefaultInputMapping("JOY_RIGHT");
+		fightKeyMap->addAction(act);
+
+		// I18N: Shift Cursor during fight to top left
+		act = new Common::Action("CURSORLEFTTOP", _("Shift Cursor - Top left"));
+		act->setCustomEngineActionEvent(kActionFightCursorLeftTop);
+		act->addDefaultInputMapping("KP7");
+		fightKeyMap->addAction(act);
+
+		// I18N: Shift Cursor during fight to middle left
+		act = new Common::Action("CURSORLEFTMIDDLE", _("Shift Cursor -  Middle left"));
+		act->setCustomEngineActionEvent(kActionFightCursorLeftTop);
+		act->addDefaultInputMapping("KP4");
+		fightKeyMap->addAction(act);
+
+		// I18N: Shift Cursor during fight to bottom left
+		act = new Common::Action("CURSORLEFTBOTTOM", _("Shift Cursor - Bottom left"));
+		act->setCustomEngineActionEvent(kActionFightCursorLeftTop);
+		act->addDefaultInputMapping("KP1");
+		fightKeyMap->addAction(act);
+
+		// I18N: Shift Cursor during fight to top right
+		act = new Common::Action("CURSORRIGHTTOP", _("Shift Cursor - Top right"));
+		act->setCustomEngineActionEvent(kActionFightCursorLeftTop);
+		act->addDefaultInputMapping("KP9");
+		fightKeyMap->addAction(act);
+
+		// I18N: Shift Cursor during fight to middle right
+		act = new Common::Action("CURSORRIGHTMIDDLE", _("Shift Cursor - Middle right"));
+		act->setCustomEngineActionEvent(kActionFightCursorLeftTop);
+		act->addDefaultInputMapping("KP6");
+		fightKeyMap->addAction(act);
+
+		// I18N: Shift Cursor during fight to bottom right
+		act = new Common::Action("CURSORRIGHTBOTTOM", _("Shift Cursor - Bottom right"));
+		act->setCustomEngineActionEvent(kActionFightCursorLeftTop);
+		act->addDefaultInputMapping("KP3");
+		fightKeyMap->addAction(act);
+	}
+
+	{
+		act = new Common::Action("INDEXPREVIOUS", _("Go to next index"));
+		act->setCustomEngineActionEvent(kActionIndexNext);
+		act->addDefaultInputMapping("KP2");
+		act->addDefaultInputMapping("DOWN");
+		act->addDefaultInputMapping("JOY_DOWN");
+		indexKeyMap->addAction(act);
+
+		act = new Common::Action("INDEXNEXT", _("Go to previous index"));
+		act->setCustomEngineActionEvent(kActionIndexPrevious);
+		act->addDefaultInputMapping("KP8");
+		act->addDefaultInputMapping("UP");
+		act->addDefaultInputMapping("JOY_UP");
+		indexKeyMap->addAction(act);
+
+		act = new Common::Action("INDEXSELECT", _("Select index"));
+		act->setCustomEngineActionEvent(kActionIndexSelect);
+		act->addDefaultInputMapping("KP3");
+		act->addDefaultInputMapping("JOY_CENTER");
+		indexKeyMap->addAction(act);
+	}
+
+	{
+		String s = ConfMan.get("language", target);
+		Language l = Common::parseLanguage(s);
+
+		act = new Common::Action("YES", _("Press \"Yes\" key"));
+		act->setCustomEngineActionEvent(kActionYes);
+		act->addDefaultInputMapping("JOY_LEFT_STICK");
+		if (l == Common::FR_FRA)
+			act->addDefaultInputMapping("o");
+		else if ((l == Common::DE_DEU) || (l == Common::NL_NLD))
+			act->addDefaultInputMapping("j");
+		else if ((l == Common::ES_ESP) || (l == Common::IT_ITA))
+			act->addDefaultInputMapping("s");
+		else if (l == Common::RU_RUS)
+			act->addDefaultInputMapping("l");
+		else
+			act->addDefaultInputMapping("y");
+		yesNoKeyMap->addAction(act);
+
+		act = new Common::Action("NO", _("Press \"No\" key"));
+		act->setCustomEngineActionEvent(kActionNo);
+		act->addDefaultInputMapping("JOY_RIGHT_STICK");
+		if (l == Common::RU_RUS)
+			act->addDefaultInputMapping("y");
+		else
+			act->addDefaultInputMapping("n");
+		yesNoKeyMap->addAction(act);
+	}
+
+	KeymapArray keymaps(5);
+	keymaps[0] = engineKeyMap;
+	keymaps[1] = gameKeyMap;
+	keymaps[2] = fightKeyMap;
+	keymaps[3] = indexKeyMap;
+	keymaps[4] = yesNoKeyMap;
+
+	yesNoKeyMap->setEnabled(false);
+
+	return keymaps;
+}
+
 #if PLUGIN_ENABLED_DYNAMIC(LURE)
 	REGISTER_PLUGIN_DYNAMIC(LURE, PLUGIN_TYPE_ENGINE, LureMetaEngine);
 #else
diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp
index 08677a90acf..18631cb4f67 100644
--- a/engines/lure/sound.cpp
+++ b/engines/lure/sound.cpp
@@ -211,7 +211,8 @@ bool SoundManager::initCustomTimbres(bool canAbort) {
 
 		if (events.interruptableDelay(10)) {
 			if (LureEngine::getReference().shouldQuit() ||
-					(canAbort && events.type() == Common::EVENT_KEYDOWN && events.event().kbd.keycode == 27)) {
+					(canAbort && events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START &&
+						events.event().customType == kActionEscape)) {
 				// User has quit the game or pressed Escape.
 				_mt32Driver->clearSysExQueue();
 				result = true;
@@ -439,8 +440,8 @@ bool SoundManager::fadeOut() {
 	_driver->startFade(3000, 0);
 	while (_driver->isFading()) {
 		if (events.interruptableDelay(100)) {
-			result = ((events.type() == Common::EVENT_KEYDOWN && events.event().kbd.keycode == 27) ||
-				LureEngine::getReference().shouldQuit());
+			result = ((events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START && events.event().customType == kActionEscape)
+						|| LureEngine::getReference().shouldQuit());
 			_driver->abortFade();
 			break;
 		}
diff --git a/engines/lure/surface.cpp b/engines/lure/surface.cpp
index 91da5f66ac6..8b664cbd5c9 100644
--- a/engines/lure/surface.cpp
+++ b/engines/lure/surface.cpp
@@ -1018,8 +1018,8 @@ bool SaveRestoreDialog::show(bool saveDialog) {
 			if (abortFlag) break;
 
 			while (events.pollEvent()) {
-				if ((events.type() == Common::EVENT_KEYDOWN) &&
-					(events.event().kbd.keycode == Common::KEYCODE_ESCAPE)) {
+				if (events.type() == Common::EVENT_CUSTOM_ENGINE_ACTION_START &&
+						events.event().customType == kActionEscape) {
 					abortFlag = true;
 					break;
 				}




More information about the Scummvm-git-logs mailing list