[Scummvm-git-logs] scummvm master -> fd5767a95db9337d668feedce60d4a463565fbb4
sev-
noreply at scummvm.org
Sun Aug 10 11:10:30 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
fd5767a95d PRINCE: Add keymapper support
Commit: fd5767a95db9337d668feedce60d4a463565fbb4
https://github.com/scummvm/scummvm/commit/fd5767a95db9337d668feedce60d4a463565fbb4
Author: aunnoman1 (aunnoman123 at outlook.com)
Date: 2025-08-10T13:10:27+02:00
Commit Message:
PRINCE: Add keymapper support
Changed paths:
engines/prince/inventory.cpp
engines/prince/metaengine.cpp
engines/prince/prince.cpp
engines/prince/prince.h
engines/prince/videoplayer.cpp
diff --git a/engines/prince/inventory.cpp b/engines/prince/inventory.cpp
index 05f73d8bb2e..84e81548288 100644
--- a/engines/prince/inventory.cpp
+++ b/engines/prince/inventory.cpp
@@ -678,7 +678,7 @@ void PrinceEngine::displayInventory() {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_KEYDOWN:
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
keyHandler(event);
break;
case Common::EVENT_LBUTTONDOWN:
diff --git a/engines/prince/metaengine.cpp b/engines/prince/metaengine.cpp
index b96e2c9bf02..eb096e33e3c 100644
--- a/engines/prince/metaengine.cpp
+++ b/engines/prince/metaengine.cpp
@@ -25,6 +25,10 @@
#include "prince/prince.h"
#include "prince/detection.h"
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/standard-actions.h"
+
namespace Prince {
#ifdef USE_TTS
@@ -108,6 +112,7 @@ public:
SaveStateList listSaves(const char *target) const override;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
bool removeSaveState(const char *target, int slot) const override;
+ Common::KeymapArray initKeymaps(const char *target) const override;
};
bool PrinceMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -215,6 +220,61 @@ Common::Error PrinceMetaEngine::createInstance(OSystem *syst, Engine **engine, c
return Common::kNoError;
}
+Common::KeymapArray PrinceMetaEngine::initKeymaps(const char *target) const {
+ using namespace Common;
+ using namespace Prince;
+
+ Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "prince-default", _("Default keymappings"));
+
+ Common::Action *act;
+
+ act = new Common::Action(kStandardActionLeftClick, _("Move / Interact"));
+ act->setLeftClickEvent();
+ act->addDefaultInputMapping("MOUSE_LEFT");
+ act->addDefaultInputMapping("JOY_A");
+ engineKeyMap->addAction(act);
+
+ act = new Common::Action(kStandardActionRightClick, _("Open interaction menu"));
+ act->setRightClickEvent();
+ act->addDefaultInputMapping("MOUSE_RIGHT");
+ act->addDefaultInputMapping("JOY_B");
+ engineKeyMap->addAction(act);
+
+ act = new Common::Action("SAVE", _("Save game"));
+ act->setCustomEngineActionEvent(kActionSave);
+ act->addDefaultInputMapping("F1");
+ act->addDefaultInputMapping("JOY_X");
+ engineKeyMap->addAction(act);
+
+ act = new Action("LOAD", _("Load game"));
+ act->setCustomEngineActionEvent(kActionLoad);
+ act->addDefaultInputMapping("F2");
+ act->addDefaultInputMapping("JOY_Y");
+ engineKeyMap->addAction(act);
+
+ // I18N: This refers to the Z key on a keyboard.
+ act = new Action("Z", _("Z key")); // TODO: Rename this action to better reflect its use in the prison cell minigame near the end of the game.
+ act->setCustomEngineActionEvent(kActionZ);
+ act->addDefaultInputMapping("z");
+ act->addDefaultInputMapping("JOY_LEFT");
+ engineKeyMap->addAction(act);
+
+ // I18N: This refers to the X key on a keyboard.
+ act = new Action("X", _("X key")); // TODO: Rename this action to better reflect its use in the prison cell minigame near the end of the game.
+ act->setCustomEngineActionEvent(kActionX);
+ act->addDefaultInputMapping("x");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ engineKeyMap->addAction(act);
+
+ act = new Action("SKIP", _("Skip"));
+ act->setCustomEngineActionEvent(kActionSkip);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_UP");
+ engineKeyMap->addAction(act);
+
+ return Keymap::arrayOf(engineKeyMap);
+}
+
#if PLUGIN_ENABLED_DYNAMIC(PRINCE)
REGISTER_PLUGIN_DYNAMIC(PRINCE, PLUGIN_TYPE_ENGINE, PrinceMetaEngine);
#else
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index b50357afb6a..48147f67e1a 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -522,8 +522,8 @@ void PrinceEngine::showLogo() {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ if (event.customType == kActionSkip) {
stopSample(0);
return;
}
@@ -640,27 +640,27 @@ void PrinceEngine::setMobTranslationTexts() {
}
void PrinceEngine::keyHandler(Common::Event event) {
- uint16 nChar = event.kbd.keycode;
+ uint16 nChar = event.customType;
switch (nChar) {
- case Common::KEYCODE_F1:
+ case kActionSave:
if (canLoadGameStateCurrently())
scummVMSaveLoadDialog(false);
break;
- case Common::KEYCODE_F2:
+ case kActionLoad:
if (canSaveGameStateCurrently())
scummVMSaveLoadDialog(true);
break;
- case Common::KEYCODE_z:
+ case kActionZ: // This refers to the "z" key on the keyboard. It is used to play a prison escape mini-game near the end of the game.
if (_flags->getFlagValue(Flags::POWERENABLED)) {
_flags->setFlagValue(Flags::MBFLAG, 1);
}
break;
- case Common::KEYCODE_x:
+ case kActionX: // This refers to the "x" key on the keyboard. It is used to play a prison escape mini-game near the end of the game.
if (_flags->getFlagValue(Flags::POWERENABLED)) {
_flags->setFlagValue(Flags::MBFLAG, 2);
}
break;
- case Common::KEYCODE_ESCAPE:
+ case kActionSkip:
if (_intro) {
stopTextToSpeech();
_intro = false;
@@ -829,7 +829,7 @@ void PrinceEngine::showTexts(Graphics::Surface *screen) {
text._time--;
if (!text._time) {
- if (ttsMan != nullptr && (ConfMan.getBool("tts_enabled_speech") ||
+ if (ttsMan != nullptr && (ConfMan.getBool("tts_enabled_speech") ||
ConfMan.getBool("tts_enabled_objects") || ConfMan.getBool("tts_enabled_missing_voice")) && ttsMan->isSpeaking()) {
text._time = 1;
continue;
@@ -843,9 +843,9 @@ void PrinceEngine::sayText(const Common::String &text, bool isSpeech, Common::Te
Common::TextToSpeechManager *ttsMan = g_system->getTextToSpeechManager();
// Only voice subtitles if either this is a version with no voices or the speech volume is muted (the English/Spanish
// translations still have dubs in different languages, so don't voice the subtitles unless the dub is muted)
- bool speak = (!isSpeech && ConfMan.getBool("tts_enabled_objects")) ||
- (isSpeech && ConfMan.getBool("tts_enabled_speech") &&
- (getFeatures() & GF_NOVOICES || ConfMan.getInt("speech_volume") == 0 || ConfMan.getBool("subtitles")));
+ bool speak = (!isSpeech && ConfMan.getBool("tts_enabled_objects")) ||
+ (isSpeech && ConfMan.getBool("tts_enabled_speech") &&
+ (getFeatures() & GF_NOVOICES || ConfMan.getInt("speech_volume") == 0 || ConfMan.getBool("subtitles")));
if (ttsMan != nullptr && speak) {
Common::String ttsText(text);
// Some emotive text has a < at the front, which causes the entire text to not be voiced by the TTS system
@@ -893,7 +893,7 @@ Common::U32String PrinceEngine::convertText(const Common::String &text) const {
int i = 0;
for (const byte *b = bytes; *b; ++b) {
bool inTable = checkConversionTable(b, i, convertedBytes, conversionTable);
-
+
if (_credits && !inTable) {
if (*b == 0x2a) { // * in credits
convertedBytes[i] = 0x20;
@@ -950,7 +950,7 @@ void PrinceEngine::setTTSVoice(uint8 textColor) const {
// there may be different characters with the same text colors in different locations, and rarely
// different characters with the same text colors in the same location. Using the location number and/or
// mob index differentiates characters in these cases
- if (characterVoiceData[i].textColor == textColor &&
+ if (characterVoiceData[i].textColor == textColor &&
(characterVoiceData[i].locationNumber == 0 || characterVoiceData[i].locationNumber == _locationNr) &&
(characterVoiceData[i].mobIndex == -1 || characterVoiceData[i].mobIndex == _dialogMob)) {
id = i;
@@ -1216,7 +1216,7 @@ void PrinceEngine::dialogRun() {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_KEYDOWN:
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
keyHandler(event);
break;
case Common::EVENT_LBUTTONDOWN:
@@ -1441,8 +1441,8 @@ void PrinceEngine::scrollCredits() {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
- if (event.type == Common::EVENT_KEYDOWN) {
- if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
+ if (event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
+ if (event.customType == kActionSkip) {
blackPalette();
return;
}
@@ -1489,7 +1489,7 @@ void PrinceEngine::mainLoop() {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
switch (event.type) {
- case Common::EVENT_KEYDOWN:
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
keyHandler(event);
break;
case Common::EVENT_LBUTTONDOWN:
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index 573ff2f9650..157646be7e9 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -52,6 +52,15 @@
namespace Prince {
+enum PRINCEActions {
+ kActionNone,
+ kActionSave,
+ kActionLoad,
+ kActionZ,
+ kActionX,
+ kActionSkip,
+};
+
struct SavegameHeader;
class PrinceEngine;
diff --git a/engines/prince/videoplayer.cpp b/engines/prince/videoplayer.cpp
index 50e77df029f..987fd87e52c 100644
--- a/engines/prince/videoplayer.cpp
+++ b/engines/prince/videoplayer.cpp
@@ -66,7 +66,7 @@ void PrinceEngine::playVideo(const Common::Path &videoFilename) {
Common::Event event;
while (_system->getEventManager()->pollEvent(event)) {
- if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) ||
+ if ((event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START && event.customType == kActionSkip) ||
event.type == Common::EVENT_LBUTTONUP)
skipVideo = true;
}
More information about the Scummvm-git-logs
mailing list