[Scummvm-git-logs] scummvm master -> 7d14ef7cc0b6d62e5895027cda28cf0f83dd5c31

bluegr noreply at scummvm.org
Wed Jul 3 06:58:40 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:
7d14ef7cc0 SAGA: Add keymapper support


Commit: 7d14ef7cc0b6d62e5895027cda28cf0f83dd5c31
    https://github.com/scummvm/scummvm/commit/7d14ef7cc0b6d62e5895027cda28cf0f83dd5c31
Author: NabeelShabbir (i210443 at nu.edu.pk)
Date: 2024-07-03T09:58:37+03:00

Commit Message:
SAGA: Add keymapper support

Changed paths:
    engines/saga/displayinfo.h
    engines/saga/input.cpp
    engines/saga/interface.cpp
    engines/saga/interface.h
    engines/saga/metaengine.cpp
    engines/saga/saga.cpp
    engines/saga/saga.h


diff --git a/engines/saga/displayinfo.h b/engines/saga/displayinfo.h
index 8bdfe819104..4ef0cbbd027 100644
--- a/engines/saga/displayinfo.h
+++ b/engines/saga/displayinfo.h
@@ -33,7 +33,7 @@ struct PanelButton {
 	int width;
 	int height;
 	int id;
-	uint16 ascii;
+	uint16 customType;
 	int state;
 	int upSpriteNumber;
 	int downSpriteNumber;
@@ -134,14 +134,14 @@ struct GameDisplayInfo {
 
 // ITE section
 static PanelButton ITE_MainPanelButtons[] = {
-	{kPanelButtonVerb,		52,4,	57,10,	kVerbITEWalkTo,'w',0,	0,1,0},
-	{kPanelButtonVerb,		52,15,	57,10,	kVerbITELookAt,'l',0,	2,3,0},
-	{kPanelButtonVerb,		52,26,	57,10,	kVerbITEPickUp,'p',0,	4,5,0},
-	{kPanelButtonVerb,		52,37,	57,10,	kVerbITETalkTo,'t',0,	0,1,0},
-	{kPanelButtonVerb,		110,4,	56,10,	kVerbITEOpen,'o',0,	6,7,0},
-	{kPanelButtonVerb,		110,15,	56,10,	kVerbITEClose,'c',0,	8,9,0},
-	{kPanelButtonVerb,		110,26,	56,10,	kVerbITEUse,'u',0,		10,11,0},
-	{kPanelButtonVerb,		110,37,	56,10,	kVerbITEGive,'g',0,	12,13,0},
+	{kPanelButtonVerb,		52,  4,	57,10,	kVerbITEWalkTo,	kActionWalkTo,	0,	 0,	 1,	0},
+	{kPanelButtonVerb,		52, 15,	57,10,	kVerbITELookAt,	kActionLookAt,	0,	 2,	 3,	0},
+	{kPanelButtonVerb,		52, 26,	57,10,	kVerbITEPickUp,	kActionPickUp,	0,	 4,	 5,	0},
+	{kPanelButtonVerb,		52, 37,	57,10,	kVerbITETalkTo,	kActionTalkTo,	0,	 0,	 1,	0},
+	{kPanelButtonVerb,		110, 4,	56,10,	kVerbITEOpen,	kActionOpen,	0,	 6,	 7,	0},
+	{kPanelButtonVerb,		110,15,	56,10,	kVerbITEClose,	kActionClose,	0,	 8,	 9,	0},
+	{kPanelButtonVerb,		110,26,	56,10,	kVerbITEUse,	kActionUse,		0,	10,	11,	0},
+	{kPanelButtonVerb,		110,37,	56,10,	kVerbITEGive,	kActionGive,	0,	12,	13,	0},
 	{kPanelButtonArrow,		306,6,	8,5,	-1,'U',0,			0,4,2},
 	{kPanelButtonArrow,		306,41,	8,5,	1,'D',0,			1,5,3},
 
@@ -157,14 +157,14 @@ static PanelButton ITE_MainPanelButtons[] = {
 };
 
 static PanelButton ITE_MainPanelButtons_ZH[] = {
-	{kPanelButtonVerb,		53,0,	34,16,	kVerbITEWalkTo,'w',0,	0,1,0},
-	{kPanelButtonVerb,		53,17,	34,16,	kVerbITELookAt,'l',0,	2,3,0},
-	{kPanelButtonVerb,		53,34,	34,16,	kVerbITEPickUp,'p',0,	4,5,0},
-	{kPanelButtonVerb,		92,0,	34,16,	kVerbITETalkTo,'t',0,	0,1,0},
-	{kPanelButtonVerb,		92,17,	34,16,	kVerbITEOpen,'o',0,	6,7,0},
-	{kPanelButtonVerb,		92,34,	34,16,	kVerbITEClose,'c',0,	8,9,0},
-	{kPanelButtonVerb,		132,0,	34,16,	kVerbITEUse,'u',0,		10,11,0},
-	{kPanelButtonVerb,		132,17,	34,16,	kVerbITEGive,'g',0,	12,13,0},
+	{kPanelButtonVerb,		 53, 0,	34,16,	kVerbITEWalkTo,	kActionWalkTo,	0,	0,1,0},
+	{kPanelButtonVerb,		 53,17,	34,16,	kVerbITELookAt,	kActionLookAt,	0,	2,3,0},
+	{kPanelButtonVerb,		 53,34,	34,16,	kVerbITEPickUp,	kActionPickUp,	0,	4,5,0},
+	{kPanelButtonVerb,		 92, 0,	34,16,	kVerbITETalkTo,	kActionTalkTo,	0,	0,1,0},
+	{kPanelButtonVerb,		 92,17,	34,16,	kVerbITEOpen,	kActionOpen,	0,	6,7,0},
+	{kPanelButtonVerb,		 92,34,	34,16,	kVerbITEClose,	kActionClose,	0,	8,9,0},
+	{kPanelButtonVerb,		132, 0,	34,16,	kVerbITEUse,	kActionUse,		0,	10,11,0},
+	{kPanelButtonVerb,		132,17,	34,16,	kVerbITEGive,	kActionGive,	0,	12,13,0},
 	{kPanelButtonArrow,		306,6,	8,5,	-1,'U',0,			0,4,2},
 	{kPanelButtonArrow,		306,41,	8,5,	1,'D',0,			1,5,3},
 
@@ -190,13 +190,13 @@ static PanelButton ITE_ConversePanelButtons[] = {
 
 static PanelButton ITE_OptionPanelButtons[] = {
 	{kPanelButtonOptionSlider,	284,19, 13,75,	0,'-',0,	0,0,0}, //slider-scroller
-	{kPanelButtonOption,	113,18, 45,17,	kTextReadingSpeed,'r',0,	0,0,0}, //read speed
-	{kPanelButtonOption,	113,37, 45,17,	kTextMusic,'m',0,	0,0,0}, //music
-	{kPanelButtonOption,	113,56, 45,17,	kTextSound,'n',0,	0,0,0}, //sound-noise
-	{kPanelButtonOption,	13,79, 135,17,	kTextQuitGame,'q',0,	0,0,0}, //quit
-	{kPanelButtonOption,	13,98, 135,17,	kTextContinuePlaying,'c',0,	0,0,0}, //continue
-	{kPanelButtonOption,	164,98, 57,17,	kTextLoad,'l',0,	0,0,0}, //load
-	{kPanelButtonOption,	241,98, 57,17,	kTextSave,'s',0,	0,0,0},	//save
+	{kPanelButtonOption,	113,18, 45,17,	kTextReadingSpeed,		kActionOptionReadingSpeed,	0,	0,0,0}, //read speed
+	{kPanelButtonOption,	113,37, 45,17,	kTextMusic,				kActionOptionMusic,			0,	0,0,0}, //music
+	{kPanelButtonOption,	113,56, 45,17,	kTextSound,				kActionOptionSound,			0,	0,0,0}, //sound-noise
+	{kPanelButtonOption,	13,79, 135,17,	kTextQuitGame,			kActionOptionQuitGame,		0,	0,0,0}, //quit
+	{kPanelButtonOption,	13,98, 135,17,	kTextContinuePlaying,	kActionOptionContinue,		0,	0,0,0}, //continue
+	{kPanelButtonOption,	164,98, 57,17,	kTextLoad,				kActionOptionLoad,			0,	0,0,0}, //load
+	{kPanelButtonOption,	241,98, 57,17,	kTextSave,				kActionOptionSaveGame,		0,	0,0,0},	//save
 	{kPanelButtonOptionSaveFiles,	166,20, 112,74,	0,'-',0,	0,0,0},	//savefiles
 
 	{kPanelButtonOptionText,-1,4, 0,0,	kTextGameOptions,'-',0,	0,0,0},	// text: game options
@@ -208,13 +208,13 @@ static PanelButton ITE_OptionPanelButtons[] = {
 
 static PanelButton ITE_OptionPanelButtons_ZH[] = {
 	{kPanelButtonOptionSlider,	284,19, 13,75,	0,'-',0,	0,0,0}, //slider-scroller
-	{kPanelButtonOption,	113,18, 45,17,	kTextReadingSpeed,'r',0,	0,0,0}, //read speed
-	{kPanelButtonOption,	113,37, 45,17,	kTextMusic,'m',0,	0,0,0}, //music
-	{kPanelButtonOption,	113,56, 45,17,	kTextSound,'n',0,	0,0,0}, //sound-noise
-	{kPanelButtonOption,	13,79, 135,17,	kTextQuitGame,'q',0,	0,0,0}, //quit
-	{kPanelButtonOption,	13,98, 135,17,	kTextContinuePlaying,'c',0,	0,0,0}, //continue
-	{kPanelButtonOption,	164,98, 57,17,	kTextLoad,'l',0,	0,0,0}, //load
-	{kPanelButtonOption,	241,98, 57,17,	kTextSave,'s',0,	0,0,0},	//save
+	{kPanelButtonOption,	113,18, 45,17,	kTextReadingSpeed,		kActionOptionReadingSpeed,	0,	0,0,0}, //read speed
+	{kPanelButtonOption,	113,37, 45,17,	kTextMusic,				kActionOptionMusic,			0,	0,0,0}, //music
+	{kPanelButtonOption,	113,56, 45,17,	kTextSound,				kActionOptionSound,			0,	0,0,0}, //sound-noise
+	{kPanelButtonOption,	13,79, 135,17,	kTextQuitGame,			kActionOptionQuitGame,		0,	0,0,0}, //quit
+	{kPanelButtonOption,	13,98, 135,17,	kTextContinuePlaying,	kActionOptionContinue,		0,	0,0,0}, //continue
+	{kPanelButtonOption,	164,98, 57,17,	kTextLoad,				kActionOptionLoad,			0,	0,0,0}, //load
+	{kPanelButtonOption,	241,98, 57,17,	kTextSave,				kActionOptionSaveGame,		0,	0,0,0},	//save
 	{kPanelButtonOptionSaveFiles,	166,20, 112,74,	0,'-',0,	0,0,0},	//savefiles
 
 	{kPanelButtonOptionText,9,0, 165,17,	kTextGameOptions,'-',0,	0,0,0},	// text: game options
@@ -225,19 +225,19 @@ static PanelButton ITE_OptionPanelButtons_ZH[] = {
 };
 
 static PanelButton ITE_QuitPanelButtons[] = {
-	{kPanelButtonQuit, 11,17, 60,16, kTextQuit,'q',0, 0,0,0},
-	{kPanelButtonQuit, 121,17, 60,16, kTextCancel,'c',0, 0,0,0},
+	{kPanelButtonQuit, 11,17, 60,16, kTextQuit,kActionOptionQuit,0, 0,0,0},
+	{kPanelButtonQuit, 121,17, 60,16, kTextCancel,kActionOptionCancel,0, 0,0,0},
 	{kPanelButtonQuitText, -1,5, 0,0, kTextQuitTheGameQuestion,'-',0, 0,0,0},
 };
 
 static PanelButton ITE_LoadPanelButtons[] = {
-	{kPanelButtonLoad, 101,19, 60,16, kTextOK,'o',0, 0,0,0},
+	{kPanelButtonLoad, 101,19, 60,16, kTextOK,kActionOptionOkay,0, 0,0,0},
 	{kPanelButtonLoadText, -1,5, 0,0, kTextLoadSuccessful,'-',0, 0,0,0},
 };
 
 static PanelButton ITE_SavePanelButtons[] = {
-	{kPanelButtonSave, 11,37, 60,16, kTextSave,'s',0, 0,0,0},
-	{kPanelButtonSave, 101,37, 60,16, kTextCancel,'c',0, 0,0,0},
+	{kPanelButtonSave, 11,37, 60,16, kTextSave,kActionOptionSave,0, 0,0,0},
+	{kPanelButtonSave, 101,37, 60,16, kTextCancel,kActionOptionCancel,0, 0,0,0},
 	{kPanelButtonSaveEdit, 26,17, 119,17, 0,'-',0, 0,0,0},
 	{kPanelButtonSaveText, -1,5, 0,0, kTextEnterSaveGameName,'-',0, 0,0,0},
 };
@@ -390,14 +390,14 @@ static const GameDisplayInfo ITE_DisplayInfo_ZH = {
 #define IHNM_CONVERSE_TEXT_LINES        11
 
 static PanelButton IHNM_MainPanelButtons[] = {
-	{kPanelButtonVerb,		106,12,		114,30,	kVerbIHNMWalk,'w',0,	0,1,0},
-	{kPanelButtonVerb,		106,44,		114,30,	kVerbIHNMLookAt,'l',0,	2,3,0},
-	{kPanelButtonVerb,		106,76,		114,30, kVerbIHNMTake,'k',0,	4,5,0},
-	{kPanelButtonVerb,		106,108,	114,30, kVerbIHNMUse,'u',0,		6,7,0},
-	{kPanelButtonVerb,		223,12,		114,30, kVerbIHNMTalkTo,'t',0,	8,9,0},
-	{kPanelButtonVerb,		223,44,		114,30, kVerbIHNMSwallow,'s',0,	10,11,0},
-	{kPanelButtonVerb,		223,76,		114,30, kVerbIHNMGive,'g',0,	12,13,0},
-	{kPanelButtonVerb,		223,108,	114,30, kVerbIHNMPush,'p',0,	14,15,0},
+	{kPanelButtonVerb,		106,12,		114,30,	kVerbIHNMWalk,		kActionWalkTo,	0,	 0, 1,0},
+	{kPanelButtonVerb,		106,44,		114,30,	kVerbIHNMLookAt,	kActionLookAt,	0,	 2, 3,0},
+	{kPanelButtonVerb,		106,76,		114,30, kVerbIHNMTake,		kActionTake,	0,	 4, 5,0},
+	{kPanelButtonVerb,		106,108,	114,30, kVerbIHNMUse,		kActionUse,		0,	 6, 7,0},
+	{kPanelButtonVerb,		223,12,		114,30, kVerbIHNMTalkTo,	kActionTalkTo,	0,	 8, 9,0},
+	{kPanelButtonVerb,		223,44,		114,30, kVerbIHNMSwallow,	kActionSwallow,	0,	10,11,0},
+	{kPanelButtonVerb,		223,76,		114,30, kVerbIHNMGive,		kActionGive,	0,	12,13,0},
+	{kPanelButtonVerb,		223,108,	114,30, kVerbIHNMPush,		kActionPush,	0,	14,15,0},
 	{kPanelButtonArrow,		606,22,		20,25,	-1,'[',0,			2,3,4},	// TODO: IHNM needs more states hre
 	{kPanelButtonArrow,		606,108,	20,25,	1,']',0,			6,7,8},
 
@@ -434,32 +434,32 @@ static PanelButton IHNM_OptionPanelButtons[] = {
 	{kPanelButtonOptionText,11,55,	139,21,	kTextMusic,'-',0, 0,0,0},			// text: music
 	{kPanelButtonOptionText,11,80,	139,21,	kTextSound,'-',0, 0,0,0},			// text: noise
 	{kPanelButtonOptionText,11,105,	139,21,	kTextVoices,'-',0, 0,0,0},			// text: voices
-	{kPanelButtonOption,	154,30, 79,23,	kTextReadingSpeed,'r',0,	0,0,0},	//read speed
-	{kPanelButtonOption,	154,55, 79,23,	kTextMusic,'m',0,	0,0,0},			//music
-	{kPanelButtonOption,	154,80, 79,23,	kTextSound,'n',0,	0,0,0},			//sound-noise
-	{kPanelButtonOption,	154,105,79,23,	kTextVoices,'v',0,	0,0,0},			//voices
-	{kPanelButtonOption,	20,150,	200,25,	kTextQuitGame,'q',0,	0,0,0},		//quit
-	{kPanelButtonOption,	20,178,	200,25,	kTextContinuePlaying,'c',0,	0,0,0}, //continue
+	{kPanelButtonOption,	154,30, 79,23,	kTextReadingSpeed,kActionOptionReadingSpeed,0,	0,0,0},	//read speed
+	{kPanelButtonOption,	154,55, 79,23,	kTextMusic,kActionOptionMusic,0,	0,0,0},			//music
+	{kPanelButtonOption,	154,80, 79,23,	kTextSound,kActionOptionSound,0,	0,0,0},			//sound-noise
+	{kPanelButtonOption,	154,105,79,23,	kTextVoices,kActionOptionVoices,0,	0,0,0},			//voices
+	{kPanelButtonOption,	20,150,	200,25,	kTextQuitGame,kActionOptionQuitGame,0,	0,0,0},		//quit
+	{kPanelButtonOption,	20,178,	200,25,	kTextContinuePlaying,kActionOptionContinue,0,	0,0,0}, //continue
 	{kPanelButtonOptionSaveFiles,	244,18, 170,138,	0,'-',0,	0,0,0},		//savefiles
-	{kPanelButtonOption,	243,163, 79,23,	kTextLoad,'l',0,	0,0,0},			//load
-	{kPanelButtonOption,	334,163, 79,23,	kTextSave,'s',0,	0,0,0},			//save
+	{kPanelButtonOption,	243,163, 79,23,	kTextLoad,kActionOptionLoad,0,	0,0,0},			//load
+	{kPanelButtonOption,	334,163, 79,23,	kTextSave,kActionOptionSaveGame,0,	0,0,0},			//save
 };
 
 static PanelButton IHNM_QuitPanelButtons[] = {
-	{kPanelButtonQuit,		26,80,	80,25,	kTextQuit,'q',0, 0,0,0},
-	{kPanelButtonQuit,		156,80,	80,25,	kTextCancel,'c',0, 0,0,0},
+	{kPanelButtonQuit,		26,80,	80,25,	kTextQuit,kActionOptionQuit,0, 0,0,0},
+	{kPanelButtonQuit,		156,80,	80,25,	kTextCancel,kActionOptionCancel,0, 0,0,0},
 	{kPanelButtonQuitText,	-1,30,	0,0,	kTextQuitTheGameQuestion,'-',0, 0,0,0},
 };
 
 static PanelButton IHNM_LoadPanelButtons[] = {
-	{kPanelButtonLoad,		26,80,	80,25,	kTextOK,'o',0, 0,0,0},
-	{kPanelButtonLoad,		156,80,	80,25,	kTextCancel,'c',0, 0,0,0},
+	{kPanelButtonLoad,		26,80,	80,25,	kTextOK,kActionOptionOkay,0, 0,0,0},
+	{kPanelButtonLoad,		156,80,	80,25,	kTextCancel,kActionOptionCancel,0, 0,0,0},
 	{kPanelButtonLoadText,	-1,30,	0,0,	kTextLoadSavedGame,'-',0, 0,0,0},
 };
 
 static PanelButton IHNM_SavePanelButtons[] = {
-	{kPanelButtonSave, 25,79, 80,25, kTextSave,'s',0, 0,0,0},
-	{kPanelButtonSave, 155,79, 80,25, kTextCancel,'c',0, 0,0,0},
+	{kPanelButtonSave, 25,79, 80,25, kTextSave,kActionOptionSave,0, 0,0,0},
+	{kPanelButtonSave, 155,79, 80,25, kTextCancel,kActionOptionCancel,0, 0,0,0},
 	{kPanelButtonSaveEdit, 22,56, 216,17, 0,'-',0, 0,0,0},
 	{kPanelButtonSaveText, -1,30, 0,0, kTextEnterSaveGameName,'-',0, 0,0,0},
 };
diff --git a/engines/saga/input.cpp b/engines/saga/input.cpp
index 3717173a557..c9b7e410842 100644
--- a/engines/saga/input.cpp
+++ b/engines/saga/input.cpp
@@ -46,17 +46,37 @@ int SagaEngine::processInput() {
 		}
 
 		switch (event.type) {
+		case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+			switch (event.customType) {
+			case kActionPause:
+				_render->toggleFlag(RF_RENDERPAUSE);
+				break;
+			case kActionAbortSpeech:
+				_actor->abortSpeech();
+				break;
+			case kActionBossKey:
+				_interface->keyBoss();
+				break;
+			case kActionShowDialogue:
+				_interface->draw();
+				break;
+			case kActionOptions:
+				if (_interface->getSaveReminderState() > 0)
+					_interface->setMode(kPanelOption);
+				break;
+			default:
+				_interface->processAscii(event.kbd, event.customType);
+				break;
+			};
+
+			break;
 		case Common::EVENT_KEYDOWN:
 			if (_interface->_textInput || _interface->_statusTextInput) {
-				_interface->processAscii(event.kbd);
+				_interface->processAscii(event.kbd, event.customType);
 				return SUCCESS;
 			}
 
 			switch (event.kbd.keycode) {
-			case Common::KEYCODE_r:
-				_interface->draw();
-				break;
-
 #if 0
 			case Common::KEYCODE_KP_MINUS:
 			case Common::KEYCODE_KP_PLUS:
@@ -86,13 +106,6 @@ int SagaEngine::processInput() {
 			case Common::KEYCODE_F4:
 				_render->toggleFlag(RF_OBJECTMAP_TEST);
 				break;
-#endif
-			case Common::KEYCODE_F5:
-				if (_interface->getSaveReminderState() > 0)
-					_interface->setMode(kPanelOption);
-				break;
-
-#ifdef SAGA_DEBUG
 			case Common::KEYCODE_F6:
 				_render->toggleFlag(RF_ACTOR_PATH_TEST);
 				break;
@@ -102,21 +115,8 @@ int SagaEngine::processInput() {
 			case Common::KEYCODE_F8:
 				break;
 #endif
-
-			case Common::KEYCODE_F9:
-				_interface->keyBoss();
-				break;
-
-			// Actual game keys
-			case Common::KEYCODE_SPACE:
-				_actor->abortSpeech();
-				break;
-			case Common::KEYCODE_PAUSE:
-			case Common::KEYCODE_z:
-				_render->toggleFlag(RF_RENDERPAUSE);
-				break;
 			default:
-				_interface->processAscii(event.kbd);
+				_interface->processAscii(event.kbd, event.customType);
 				break;
 			}
 			break;
@@ -145,6 +145,17 @@ int SagaEngine::processInput() {
 		default:
 			break;
 		}
+
+		Common::Keymapper *keymapper = SagaEngine::getEventManager()->getKeymapper();
+		if (_interface->_textInput || _interface->_statusTextInput) {
+			keymapper->getKeymap("game-shortcuts")->setEnabled(false);
+			keymapper->getKeymap("save-panel")->setEnabled(false);
+		} else {
+			keymapper->getKeymap("game-shortcuts")->setEnabled(true);
+			keymapper->getKeymap("save-panel")->setEnabled(true);
+		}
+
+		enableKeyMap(_interface->getMode());
 	}
 
 	return SUCCESS;
diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp
index 18699817c49..e593a058e99 100644
--- a/engines/saga/interface.cpp
+++ b/engines/saga/interface.cpp
@@ -486,7 +486,7 @@ void Interface::setMode(int mode) {
 	_vm->_render->setFullRefresh(true);
 }
 
-bool Interface::processAscii(Common::KeyState keystate) {
+bool Interface::processAscii(Common::KeyState keystate, Common::CustomEventType customType) {
 	// TODO: Checking for Esc and Enter below is a bit hackish, and
 	// probably only works with the English version. Maybe we should
 	// add a flag to the button so it can indicate if it's the default
@@ -501,7 +501,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 
 	switch (_panelMode) {
 	case kPanelNull:
-		if (keystate.keycode == Common::KEYCODE_ESCAPE) {
+		if (customType == kActionEscape) {
 			if (_vm->_scene->isInIntro()) {
 				_vm->_scene->skipScene();
 			} else {
@@ -517,7 +517,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 #endif
 		break;
 	case kPanelCutaway:
-		if (keystate.keycode == Common::KEYCODE_ESCAPE) {
+		if (customType == kActionEscape) {
 			if (!_disableAbortSpeeches)
 				_vm->_actor->abortAllSpeeches();
 			_vm->_scene->cutawaySkip();
@@ -530,7 +530,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 #endif
 		break;
 	case kPanelVideo:
-		if (keystate.keycode == Common::KEYCODE_ESCAPE) {
+		if (customType == kActionEscape) {
 			if (_vm->_scene->isInIntro()) {
 				_vm->_scene->skipScene();
 			} else {
@@ -548,14 +548,14 @@ bool Interface::processAscii(Common::KeyState keystate) {
 		break;
 	case kPanelOption:
 		// TODO: check input dialog keys
-		if (keystate.keycode == Common::KEYCODE_ESCAPE || keystate.keycode == Common::KEYCODE_RETURN) { // Esc or Enter
+		if (customType == kActionEscape || keystate.keycode == Common::KEYCODE_RETURN) { // Esc or Enter
 			ascii = 'c'; //continue
 		}
 
 		for (i = 0; i < _optionPanel.buttonsCount; i++) {
 			panelButton = &_optionPanel.buttons[i];
 			if (panelButton->type == kPanelButtonOption) {
-				if (panelButton->ascii == ascii) {
+				if (panelButton->customType == customType) {
 					setOption(panelButton);
 					return true;
 				}
@@ -567,7 +567,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 			return true;
 		}
 
-		if (keystate.keycode == Common::KEYCODE_ESCAPE) {
+		if (customType == kActionEscape) {
 			ascii = 'c'; // cancel
 		} else if (keystate.keycode == Common::KEYCODE_RETURN) { // Enter
 			ascii = 's'; // save
@@ -576,7 +576,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 		for (i = 0; i < _savePanel.buttonsCount; i++) {
 			panelButton = &_savePanel.buttons[i];
 			if (panelButton->type == kPanelButtonSave) {
-				if (panelButton->ascii == ascii) {
+				if (panelButton->customType == customType) {
 					setSave(panelButton);
 					return true;
 				}
@@ -584,7 +584,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 		}
 		break;
 	case kPanelQuit:
-		if (keystate.keycode == Common::KEYCODE_ESCAPE) {
+		if (customType == kActionEscape) {
 			ascii = 'c'; // cancel
 		} else if (keystate.keycode == Common::KEYCODE_RETURN) { // Enter
 			ascii = 'q'; // quit
@@ -593,7 +593,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 		for (i = 0; i < _quitPanel.buttonsCount; i++) {
 			panelButton = &_quitPanel.buttons[i];
 			if (panelButton->type == kPanelButtonQuit) {
-				if (panelButton->ascii == ascii) {
+				if (panelButton->customType == customType) {
 					setQuit(panelButton);
 					return true;
 				}
@@ -604,7 +604,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 		for (i = 0; i < _loadPanel.buttonsCount; i++) {
 			panelButton = &_loadPanel.buttons[i];
 			if (panelButton->type == kPanelButtonLoad) {
-				if (panelButton->ascii == ascii) {
+				if (panelButton->customType == customType) {
 					setLoad(panelButton);
 					return true;
 				}
@@ -614,7 +614,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 	case kPanelMain:
 		for (i = 0; i < _mainPanel.buttonsCount; i++) {
 			panelButton = &_mainPanel.buttons[i];
-			if (panelButton->ascii == ascii) {
+			if (panelButton->customType == customType) {
 				if (panelButton->type == kPanelButtonVerb) {
 					_vm->_script->setVerb(panelButton->id);
 				}
@@ -624,29 +624,24 @@ bool Interface::processAscii(Common::KeyState keystate) {
 				return true;
 			}
 		}
-		if (keystate.keycode == Common::KEYCODE_o && keystate.hasFlags(Common::KBD_CTRL)) { // ctrl-o
-			if (_saveReminderState > 0) {
-				setMode(kPanelOption);
-				return true;
-			}
-		}
 		break;
 	case kPanelConverse:
-		switch (ascii) {
-		case 'x':
+		switch (customType) {
+		case kActionConverseExit:
 			setMode(kPanelMain);
 			if (_vm->_scene->isITEPuzzleScene())
 				_vm->_puzzle->exitPuzzle();
 			break;
-
-		case 'u':
+		case kActionConversePosDown:
+			converseChangePos(1);
+			break;
+		case kActionConversePosUp:
 			converseChangePos(-1);
 			break;
-
-		case 'd':
-			converseChangePos(1);
+		default:
 			break;
-
+		}
+		switch (ascii) {
 		case '1':
 		case '2':
 		case '3':
@@ -686,7 +681,7 @@ bool Interface::processAscii(Common::KeyState keystate) {
 				return true;
 			}
 
-			if (keystate.keycode == Common::KEYCODE_ESCAPE || keystate.keycode == Common::KEYCODE_RETURN) {
+			if (customType == kActionEscape || keystate.keycode == Common::KEYCODE_RETURN) {
 				_vm->_script->wakeUpThreads(kWaitTypeRequest);
 				_vm->_interface->setMode(kPanelMain);
 
@@ -2749,7 +2744,7 @@ void Interface::handleConverseClick(const Point& mousePoint) {
 	}
 
 	if (_conversePanel.currentButton->type == kPanelButtonConverseText) {
-		converseSetPos(_conversePanel.currentButton->ascii);
+		converseSetPos(_conversePanel.currentButton->customType);
 	}
 
 	if (_conversePanel.currentButton->type == kPanelButtonArrow) {
diff --git a/engines/saga/interface.h b/engines/saga/interface.h
index 0c6887b063e..8872a44dc84 100644
--- a/engines/saga/interface.h
+++ b/engines/saga/interface.h
@@ -226,7 +226,7 @@ public:
 	void drawStatusBar();
 	void setVerbState(int verb, int state);
 
-	bool processAscii(Common::KeyState keystate);
+	bool processAscii(Common::KeyState keystate, Common::CustomEventType customType);
 
 	void keyBoss();
 	void keyBossExit();
diff --git a/engines/saga/metaengine.cpp b/engines/saga/metaengine.cpp
index d57e7a689fc..4abd39dd68c 100644
--- a/engines/saga/metaengine.cpp
+++ b/engines/saga/metaengine.cpp
@@ -31,6 +31,10 @@
 #include "common/translation.h"
 #include "graphics/thumbnail.h"
 
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/standard-actions.h"
+
 #include "saga/animation.h"
 #include "saga/displayinfo.h"
 #include "saga/events.h"
@@ -103,6 +107,8 @@ public:
 	int getMaximumSaveSlot() const override;
 	void removeSaveState(const char *target, int slot) const override;
 	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
+
+	Common::KeymapArray initKeymaps(const char *target) const override;
 };
 
 bool SagaMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -253,6 +259,238 @@ SaveStateDescriptor SagaMetaEngine::querySaveMetaInfos(const char *target, int s
 	return SaveStateDescriptor();
 }
 
+Common::KeymapArray SagaMetaEngine::initKeymaps(const char *target) const {
+	using namespace Common;
+	using namespace Saga;
+
+	Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, engineKeyMapId, _("Default game keymap"));
+	Keymap *gameKeyMap = new Keymap(Keymap::kKeymapTypeGame, gameKeyMapId, _("Game keymapping"));
+	Keymap *optionKeyMap = new Keymap(Keymap::kKeymapTypeGame, optionKeyMapId, _("Option panel keymapping"));
+	Keymap *saveKeyMap = new Keymap(Keymap::kKeymapTypeGame, saveKeyMapId, _("Save panel keymapping"));
+	Keymap *loadKeyMap = new Keymap(Keymap::kKeymapTypeGame, loadKeyMapId, _("Load panel keymapping"));
+	Keymap *quitKeyMap = new Keymap(Keymap::kKeymapTypeGame, quitKeyMapId, _("Quit panel keymapping"));
+	Keymap *converseKeyMap = new Keymap(Keymap::kKeymapTypeGame, converseKeyMapId, _("Converse panel keymapping"));
+
+	Action *act;
+
+	{
+		act = new Action(kStandardActionLeftClick, _("Left Click"));
+		act->setLeftClickEvent();
+		act->addDefaultInputMapping("MOUSE_LEFT");
+		act->addDefaultInputMapping("JOY_A");
+		engineKeyMap->addAction(act);
+
+		act = new Action(kStandardActionMiddleClick, _("Middle Click"));
+		act->addDefaultInputMapping("MOUSE_MIDDLE");
+		act->setMiddleClickEvent();
+		engineKeyMap->addAction(act);
+
+		act = new Action(kStandardActionRightClick, _("Right Click"));
+		act->setRightClickEvent();
+		act->addDefaultInputMapping("MOUSE_RIGHT");
+		act->addDefaultInputMapping("JOY_B");
+		engineKeyMap->addAction(act);
+
+		act = new Action("BOSSKEY", _("Boss Key"));
+		act->setCustomEngineActionEvent(kActionBossKey);
+		act->addDefaultInputMapping("F9");
+		engineKeyMap->addAction(act);
+
+		act = new Action("SHOWOPTION", _("Show Options"));
+		act->setCustomEngineActionEvent(kActionOptions);
+		act->addDefaultInputMapping("F5");
+		act->addDefaultInputMapping("C+o");
+		engineKeyMap->addAction(act);
+	}
+
+	{
+		act = new Action("EXITCONVO", _("Exit Conversation"));
+		act->setCustomEngineActionEvent(kActionConverseExit);
+		act->addDefaultInputMapping("x");
+		converseKeyMap->addAction(act);
+
+		act = new Action("UPCONVO", _("Conversation position - Up"));
+		act->setCustomEngineActionEvent(kActionConversePosUp);
+		act->addDefaultInputMapping("u");
+		converseKeyMap->addAction(act);
+
+		act = new Action("DOWNCONVO", _("Conversation position - Down"));
+		act->setCustomEngineActionEvent(kActionConversePosDown);
+		act->addDefaultInputMapping("d");
+		converseKeyMap->addAction(act);
+	}
+
+	{
+		act = new Action("ESCAPE", _("Escape"));
+		act->setCustomEngineActionEvent(kActionEscape);
+		act->addDefaultInputMapping("ESCAPE");
+		gameKeyMap->addAction(act);
+
+		act = new Action("PAUSE", _("Pause Game"));
+		act->setCustomEngineActionEvent(kActionPause);
+		act->addDefaultInputMapping("z");
+		act->addDefaultInputMapping("PAUSE");
+		gameKeyMap->addAction(act);
+
+		act = new Action("ABRTSPEECH", _("Abort Speech"));
+		act->setCustomEngineActionEvent(kActionAbortSpeech);
+		act->addDefaultInputMapping("SPACE");
+		gameKeyMap->addAction(act);
+
+		act = new Action("SHOWDILOG", _("Show Dialogue"));
+		act->setCustomEngineActionEvent(kActionShowDialogue);
+		act->addDefaultInputMapping("r");
+		gameKeyMap->addAction(act);
+
+		act = new Action("WALK", _("Walk"));
+		act->setCustomEngineActionEvent(kActionWalkTo);
+		act->addDefaultInputMapping("w");
+		gameKeyMap->addAction(act);
+
+		act = new Action("LOOK", _("Look at"));
+		act->setCustomEngineActionEvent(kActionLookAt);
+		act->addDefaultInputMapping("l");
+		gameKeyMap->addAction(act);
+
+		act = new Action("PICKUP", _("Pickup"));
+		act->setCustomEngineActionEvent(kActionPickUp);
+		act->addDefaultInputMapping("p");
+		gameKeyMap->addAction(act);
+
+		act = new Action("TALK", _("Talk to"));
+		act->setCustomEngineActionEvent(kActionTalkTo);
+		act->addDefaultInputMapping("t");
+		gameKeyMap->addAction(act);
+
+		act = new Action("OPEN", _("Open"));
+		act->setCustomEngineActionEvent(kActionOpen);
+		act->addDefaultInputMapping("o");
+		gameKeyMap->addAction(act);
+
+		act = new Action("CLOSE", _("Close"));
+		act->setCustomEngineActionEvent(kActionClose);
+		act->addDefaultInputMapping("c");
+		gameKeyMap->addAction(act);
+
+		act = new Action("USE", _("Use"));
+		act->setCustomEngineActionEvent(kActionUse);
+		act->addDefaultInputMapping("u");
+		gameKeyMap->addAction(act);
+
+		act = new Action("GIVE", _("Give"));
+		act->setCustomEngineActionEvent(kActionGive);
+		act->addDefaultInputMapping("g");
+		gameKeyMap->addAction(act);
+
+		act = new Action("PUSH", _("Push"));
+		act->setCustomEngineActionEvent(kActionPush);
+		act->addDefaultInputMapping("p");
+		gameKeyMap->addAction(act);
+
+		act = new Action("TAKE", _("Take"));
+		act->setCustomEngineActionEvent(kActionTake);
+		act->addDefaultInputMapping("k");
+		gameKeyMap->addAction(act);
+
+		act = new Action("SWALLOW", _("Swallow"));
+		act->setCustomEngineActionEvent(kActionSwallow);
+		act->addDefaultInputMapping("s");
+		gameKeyMap->addAction(act);
+	}
+
+	{
+		act = new Action("READSPEED", _("Reading Speed"));
+		act->setCustomEngineActionEvent(kActionOptionReadingSpeed);
+		act->addDefaultInputMapping("r");
+		optionKeyMap->addAction(act);
+
+		act = new Action("MUSIC", _("Change Music"));
+		act->setCustomEngineActionEvent(kActionOptionMusic);
+		act->addDefaultInputMapping("m");
+		optionKeyMap->addAction(act);
+
+		act = new Action("SOUND", _("Change Sound"));
+		act->setCustomEngineActionEvent(kActionOptionSound);
+		act->addDefaultInputMapping("n");
+		optionKeyMap->addAction(act);
+
+		act = new Action("VOICES", _("Change Voices"));
+		act->setCustomEngineActionEvent(kActionOptionVoices);
+		act->addDefaultInputMapping("v");
+		optionKeyMap->addAction(act);
+
+		act = new Action("CONTGAME", _("Continue Game"));
+		act->setCustomEngineActionEvent(kActionOptionContinue);
+		act->addDefaultInputMapping("c");
+		optionKeyMap->addAction(act);
+
+		act = new Action("LOAD", _("Load Game"));
+		act->setCustomEngineActionEvent(kActionOptionLoad);
+		act->addDefaultInputMapping("l");
+		optionKeyMap->addAction(act);
+
+		act = new Action("QUITGAME", _("Quit Game"));
+		act->setCustomEngineActionEvent(kActionOptionQuitGame);
+		act->addDefaultInputMapping("q");
+		optionKeyMap->addAction(act);
+
+		act = new Action("SAVEGAME", _("Save Game"));
+		act->setCustomEngineActionEvent(kActionOptionSaveGame);
+		act->addDefaultInputMapping("s");
+		optionKeyMap->addAction(act);
+	}
+
+	{
+		act = new Action("QUIT", _("Quit"));
+		act->setCustomEngineActionEvent(kActionOptionQuit);
+		act->addDefaultInputMapping("q");
+		quitKeyMap->addAction(act);
+
+		act = new Action("CNCLQUIT", _("Cancel Quit"));
+		act->setCustomEngineActionEvent(kActionOptionCancel);
+		act->addDefaultInputMapping("c");
+		quitKeyMap->addAction(act);
+
+		act = new Action("OKAY", _("okay"));
+		act->setCustomEngineActionEvent(kActionOptionOkay);
+		act->addDefaultInputMapping("o");
+		loadKeyMap->addAction(act);
+
+		act = new Action("CNCLLOAD", _("Cancel Load"));
+		act->setCustomEngineActionEvent(kActionOptionCancel);
+		act->addDefaultInputMapping("c");
+		loadKeyMap->addAction(act);
+
+		act = new Action("SAVE", _("Save"));
+		act->setCustomEngineActionEvent(kActionOptionSave);
+		act->addDefaultInputMapping("s");
+		saveKeyMap->addAction(act);
+
+		act = new Action("CNCLSAVE", _("Cancel Save"));
+		act->setCustomEngineActionEvent(kActionOptionCancel);
+		act->addDefaultInputMapping("c");
+		saveKeyMap->addAction(act);
+	}
+
+	KeymapArray keymaps(7);
+	keymaps[0] = engineKeyMap;
+	keymaps[1] = gameKeyMap;
+	keymaps[2] = optionKeyMap;
+	keymaps[3] = saveKeyMap;
+	keymaps[4] = loadKeyMap;
+	keymaps[5] = quitKeyMap;
+	keymaps[6] = converseKeyMap;
+
+	gameKeyMap->setEnabled(false);
+	optionKeyMap->setEnabled(false);
+	saveKeyMap->setEnabled(false);
+	loadKeyMap->setEnabled(false);
+	quitKeyMap->setEnabled(false);
+	converseKeyMap->setEnabled(false);
+
+	return keymaps;
+}
+
 #if PLUGIN_ENABLED_DYNAMIC(SAGA)
 	REGISTER_PLUGIN_DYNAMIC(SAGA, PLUGIN_TYPE_ENGINE, SagaMetaEngine);
 #else
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index d050d946eb3..eab4e04290b 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -54,6 +54,15 @@
 
 namespace Saga {
 
+const char *engineKeyMapId = "engine-default";
+const char *gameKeyMapId = "game-shortcuts";
+const char *optionKeyMapId = "option-panel";
+const char *saveKeyMapId = "save-panel";
+const char *loadKeyMapId = "load-panel";
+const char *quitKeyMapId = "quit-panel";
+const char *converseKeyMapId = "converse-panel";
+
+
 static const GameResourceDescription ITE_Resources_GermanAGACD = {
 	1810,	// Scene lookup table RN
 	216,	// Script lookup table RN
@@ -711,6 +720,48 @@ void SagaEngine::getExcuseInfo(int verb, const char *&textString, int &soundReso
 	}
 }
 
+void SagaEngine::enableKeyMap(int mode) {
+	PanelModes newPanelMode = (PanelModes)mode;
+	if (_currentPanelMode == newPanelMode) {
+		return;
+	}
+
+	Common::String id;
+	switch (newPanelMode) {
+	case kPanelMain:
+		id = gameKeyMapId;
+		break;
+	case kPanelOption:
+		id = optionKeyMapId;
+		break;
+	case kPanelSave:
+		id = saveKeyMapId;
+		break;
+	case kPanelLoad:
+		id = loadKeyMapId;
+		break;
+	case kPanelQuit:
+		id = quitKeyMapId;
+		break;
+	case kPanelConverse:
+		id = converseKeyMapId;
+		break;
+	default:
+		id = ""; // disable all keymaps if it is not any of above Panels
+		break;
+	}
+
+	Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+	const Common::KeymapArray &keymaps = keymapper->getKeymaps();
+	for (Common::Keymap *keymap : keymaps) {
+		const Common::String &keymapId = keymap->getId();
+		if (keymap->getType() == Common::Keymap::kKeymapTypeGame && keymapId != engineKeyMapId) {
+			keymap->setEnabled(keymapId == id);
+		}
+	}
+	_currentPanelMode = newPanelMode;
+}
+
 ColorId SagaEngine::KnownColor2ColorId(KnownColor knownColor) {
 	ColorId colorId = kITEDOSColorTransBlack;
 
diff --git a/engines/saga/saga.h b/engines/saga/saga.h
index 9aa19769f57..be44495c41e 100644
--- a/engines/saga/saga.h
+++ b/engines/saga/saga.h
@@ -29,6 +29,9 @@
 #include "common/memstream.h"
 #include "common/textconsole.h"
 
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+
 #include "saga/gfx.h"
 #include "saga/detection.h"
 
@@ -95,6 +98,50 @@ enum ERRORCODE {
 	SUCCESS = 0
 };
 
+enum SAGAAction {
+	kActionNone,
+	kActionLookAt,
+	kActionWalkTo,
+	kActionPickUp,
+	kActionTalkTo,
+	kActionOpen,
+	kActionClose,
+	kActionUse,
+	kActionGive,
+	kActionTake,
+	kActionSwallow,
+	kActionPush,
+	kActionPause,
+	kActionAbortSpeech,
+	kActionBossKey,
+	kActionEscape,
+	kActionShowDialogue,
+	kActionOptions,
+	kActionOptionQuit,
+	kActionOptionCancel,
+	kActionOptionSave,
+	kActionOptionOkay,
+	kActionOptionReadingSpeed,
+	kActionOptionMusic,
+	kActionOptionSound,
+	kActionOptionVoices,
+	kActionOptionContinue,
+	kActionOptionLoad,
+	kActionOptionQuitGame,
+	kActionOptionSaveGame,
+	kActionConverseExit,
+	kActionConversePosUp,
+	kActionConversePosDown
+};
+
+extern const char *engineKeyMapId;
+extern const char *gameKeyMapId;
+extern const char *optionKeyMapId;
+extern const char *saveKeyMapId;
+extern const char *loadKeyMapId;
+extern const char *quitKeyMapId;
+extern const char *converseKeyMapId;
+
 enum VerbTypeIds {
 	kVerbITENone = 0,
 	kVerbITEPickUp = 1,
@@ -631,8 +678,12 @@ public:
 	const char *getTextString(int textStringId);
 	void getExcuseInfo(int verb, const char *&textString, int &soundResourceId);
 
+	void enableKeyMap(int mode);
+
 private:
 
+	int _currentPanelMode;
+
 public:
 	ColorId KnownColor2ColorId(KnownColor knownColor);
 	void setTalkspeed(int talkspeed);




More information about the Scummvm-git-logs mailing list