[Scummvm-git-logs] scummvm master -> 3408120503d3e9058d4feab4d428940e3eff3d18
bluegr
noreply at scummvm.org
Fri Jul 19 05:13:47 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:
3408120503 CINE: Add keymapper support
Commit: 3408120503d3e9058d4feab4d428940e3eff3d18
https://github.com/scummvm/scummvm/commit/3408120503d3e9058d4feab4d428940e3eff3d18
Author: NabeelShabbir (i210443 at nu.edu.pk)
Date: 2024-07-19T08:13:44+03:00
Commit Message:
CINE: Add keymapper support
Changed paths:
engines/cine/cine.cpp
engines/cine/cine.h
engines/cine/main_loop.cpp
engines/cine/metaengine.cpp
engines/cine/various.cpp
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index 3689ef14fa5..ab481e7e953 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -23,6 +23,8 @@
#include "common/debug-channels.h"
#include "common/events.h"
+#include "backends/keymapper/keymapper.h"
+
#include "engines/util.h"
#include "graphics/cursorman.h"
@@ -310,15 +312,19 @@ void CineEngine::showSplashScreen() {
uint32 now = g_system->getMillis();
while (!done && g_system->getMillis() - now < 2000) {
+ Common::Keymapper *keymapper = _eventMan->getKeymapper();
+ keymapper->getKeymap("intro-shortcuts")->setEnabled(true);
+
Common::Event event;
while (eventMan->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 == kActionExitSonyScreen) {
done = true;
break;
}
if (shouldQuit())
done = true;
}
+ keymapper->getKeymap("intro-shortcuts")->setEnabled(false);
}
}
diff --git a/engines/cine/cine.h b/engines/cine/cine.h
index c7760ecda90..4ce207b7b45 100644
--- a/engines/cine/cine.h
+++ b/engines/cine/cine.h
@@ -30,6 +30,7 @@
#include "common/hashmap.h"
#include "common/hash-str.h"
#include "common/random.h"
+#include "common/events.h"
#include "engines/engine.h"
@@ -92,6 +93,35 @@ struct VolumeResource {
typedef Common::HashMap<Common::String, Common::Array<VolumeResource> > StringToVolumeResourceArrayHashMap;
+enum CINEAction {
+ kActionNone,
+ kActionMoveUp,
+ kActionMoveDown,
+ kActionMoveLeft,
+ kActionMoveRight,
+ kActionMoveUpLeft,
+ kActionMoveUpRight,
+ kActionMoveDownLeft,
+ kActionMoveDownRight,
+ kActionGameSpeedDefault,
+ kActionGameSpeedSlower,
+ kActionGameSpeedFaster,
+ kActionExamine,
+ kActionTake,
+ kActionInventory,
+ kActionUse,
+ kActionActivate,
+ kActionSpeak,
+ kActionActionMenu,
+ kActionSystemMenu,
+ kActionCollisionPage,
+ kActionMouseLeft,
+ kActionMouseRight,
+ kActionExitSonyScreen,
+ kActionMenuOptionUp,
+ kActionMenuOptionDown
+};
+
class CineConsole;
class CineEngine : public Engine {
@@ -192,6 +222,7 @@ public:
Common::String _commandBuffer;
Common::Array<Common::KeyState> _keyInputList;
+ Common::Array<Common::CustomEventType> _actionList;
};
extern CineEngine *g_cine;
diff --git a/engines/cine/main_loop.cpp b/engines/cine/main_loop.cpp
index 446bd9141bf..2c77d3378c5 100644
--- a/engines/cine/main_loop.cpp
+++ b/engines/cine/main_loop.cpp
@@ -70,154 +70,142 @@ static void processEvent(Common::Event &event) {
case Common::EVENT_MOUSEMOVE:
break;
case Common::EVENT_WHEELUP:
- g_cine->_keyInputList.push_back(Common::KeyState(Common::KEYCODE_UP));
+ g_cine->_actionList.push_back(Common::CustomEventType(kActionMenuOptionUp));
break;
case Common::EVENT_WHEELDOWN:
- g_cine->_keyInputList.push_back(Common::KeyState(Common::KEYCODE_DOWN));
+ g_cine->_actionList.push_back(Common::CustomEventType(kActionMenuOptionDown));
break;
- case Common::EVENT_KEYDOWN:
- switch (event.kbd.keycode) {
- case Common::KEYCODE_RETURN:
- case Common::KEYCODE_KP_ENTER:
- case Common::KEYCODE_KP5:
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ g_cine->_actionList.push_back(event.customType);
+ switch (event.customType) {
+ case kActionMouseLeft:
if (allowPlayerInput) {
mouseLeft = 1;
}
break;
- case Common::KEYCODE_ESCAPE:
+ case kActionMouseRight:
if (allowPlayerInput) {
mouseRight = 1;
}
break;
- case Common::KEYCODE_F1:
+ case kActionExamine:
if (allowPlayerInput) {
playerCommand = 0; // EXAMINE
makeCommandLine();
}
break;
- case Common::KEYCODE_F2:
+ case kActionTake:
if (allowPlayerInput) {
playerCommand = 1; // TAKE
makeCommandLine();
}
break;
- case Common::KEYCODE_F3:
+ case kActionInventory:
if (allowPlayerInput && !inMenu) {
playerCommand = 2; // INVENTORY
makeCommandLine();
}
break;
- case Common::KEYCODE_F4:
+ case kActionUse:
if (allowPlayerInput && !inMenu) {
playerCommand = 3; // USE
makeCommandLine();
}
break;
- case Common::KEYCODE_F5:
+ case kActionActivate:
if (allowPlayerInput) {
playerCommand = 4; // ACTIVATE
makeCommandLine();
}
break;
- case Common::KEYCODE_F6:
+ case kActionSpeak:
if (allowPlayerInput) {
playerCommand = 5; // SPEAK
makeCommandLine();
}
break;
- case Common::KEYCODE_F9:
+ case kActionActionMenu:
if (allowPlayerInput && !inMenu) {
makeActionMenu();
makeCommandLine();
}
break;
- case Common::KEYCODE_F10:
+ case kActionSystemMenu:
if (!inMenu) {
g_cine->makeSystemMenu();
}
break;
- case Common::KEYCODE_F11:
+ case kActionCollisionPage:
renderer->showCollisionPage(true);
break;
- case Common::KEYCODE_KP0:
+ case kActionGameSpeedDefault:
g_cine->setDefaultGameSpeed();
break;
- case Common::KEYCODE_MINUS:
- case Common::KEYCODE_KP_MINUS:
+ case kActionGameSpeedSlower:
g_cine->modifyGameSpeed(-1); // Slower
break;
- case Common::KEYCODE_PLUS:
- case Common::KEYCODE_KP_PLUS:
+ case kActionGameSpeedFaster:
g_cine->modifyGameSpeed(+1); // Faster
break;
- case Common::KEYCODE_KP4:
+ case kActionMoveLeft:
moveUsingKeyboard(-1, 0); // Left
break;
- case Common::KEYCODE_KP6:
+ case kActionMoveRight:
moveUsingKeyboard(+1, 0); // Right
break;
- case Common::KEYCODE_KP8:
+ case kActionMoveUp:
moveUsingKeyboard(0, +1); // Up
break;
- case Common::KEYCODE_KP2:
+ case kActionMoveDown:
moveUsingKeyboard(0, -1); // Down
break;
- case Common::KEYCODE_KP9:
+ case kActionMoveUpRight:
moveUsingKeyboard(+1, +1); // Up & Right
break;
- case Common::KEYCODE_KP7:
+ case kActionMoveUpLeft:
moveUsingKeyboard(-1, +1); // Up & Left
break;
- case Common::KEYCODE_KP1:
+ case kActionMoveDownLeft:
moveUsingKeyboard(-1, -1); // Down & Left
break;
- case Common::KEYCODE_KP3:
+ case kActionMoveDownRight:
moveUsingKeyboard(+1, -1); // Down & Right
break;
- case Common::KEYCODE_LEFT:
- // fall through
- case Common::KEYCODE_RIGHT:
- // fall through
- case Common::KEYCODE_UP:
- // fall through
- case Common::KEYCODE_DOWN:
- // fall through
default:
- g_cine->_keyInputList.push_back(event.kbd);
break;
- }
+ };
break;
- case Common::EVENT_KEYUP:
- switch (event.kbd.keycode) {
- case Common::KEYCODE_RETURN:
- case Common::KEYCODE_KP_ENTER:
- case Common::KEYCODE_KP5:
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+ switch (event.customType) {
+ case kActionMouseLeft:
if (allowPlayerInput) {
mouseLeft = 0;
- }
- break;
- case Common::KEYCODE_ESCAPE:
+ } break;
+ case kActionMouseRight:
if (allowPlayerInput) {
mouseRight = 0;
}
- break;
- case Common::KEYCODE_F11:
- renderer->showCollisionPage(false);
- break;
- case Common::KEYCODE_KP4: // Left
- case Common::KEYCODE_KP6: // Right
- case Common::KEYCODE_KP8: // Up
- case Common::KEYCODE_KP2: // Down
- case Common::KEYCODE_KP9: // Up & Right
- case Common::KEYCODE_KP7: // Up & Left
- case Common::KEYCODE_KP1: // Down & Left
- case Common::KEYCODE_KP3: // Down & Right
+ case kActionMoveUp:
+ case kActionMoveDown:
+ case kActionMoveLeft:
+ case kActionMoveRight:
+ case kActionMoveUpLeft:
+ case kActionMoveUpRight:
+ case kActionMoveDownLeft:
+ case kActionMoveDownRight:
// Stop ego movement made with keyboard when releasing a known key
moveUsingKeyboard(0, 0);
break;
+ case kActionCollisionPage:
+ renderer->showCollisionPage(false);
+ break;
default:
break;
}
+ break;
+ case Common::EVENT_KEYDOWN:
+ g_cine->_keyInputList.push_back(event.kbd);
+ break;
default:
break;
}
@@ -269,9 +257,9 @@ void manageEvents(CallSource callSource, EventTarget eventTarget, bool useMaxMou
break;
case UNTIL_MOUSE_BUTTON_DOWN_OR_KEY_UP_OR_DOWN_OR_IN_RECTS:
foundTarget = mouseButtonDown;
- if (!g_cine->_keyInputList.empty()) {
- Common::KeyState key = g_cine->_keyInputList.back();
- if (key.keycode == Common::KEYCODE_UP || key.keycode == Common::KEYCODE_DOWN) {
+ if (!g_cine->_actionList.empty()) {
+ Common::CustomEventType customType = g_cine->_actionList.back();
+ if (customType == kActionMenuOptionUp || customType == kActionMenuOptionDown) {
foundTarget = true;
}
}
diff --git a/engines/cine/metaengine.cpp b/engines/cine/metaengine.cpp
index ad7158af1f0..f45841bd18f 100644
--- a/engines/cine/metaengine.cpp
+++ b/engines/cine/metaengine.cpp
@@ -28,6 +28,10 @@
#include "common/translation.h"
#include "common/util.h"
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/standard-actions.h"
+
#include "cine/cine.h"
#include "cine/various.h"
@@ -92,6 +96,8 @@ public:
void removeSaveState(const char *target, int slot) const override;
Common::String getSavegameFile(int saveGameIdx, const char *target = nullptr) const override;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
+
+ Common::KeymapArray initKeymaps(const char *target) const override;
};
bool CineMetaEngine::hasFeature(MetaEngineFeature f) const {
@@ -245,6 +251,190 @@ SaveStateDescriptor CineMetaEngine::querySaveMetaInfos(const char *target, int s
return SaveStateDescriptor();
}
+Common::KeymapArray CineMetaEngine::initKeymaps(const char *target) const {
+ using namespace Common;
+ using namespace Cine;
+
+ Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "cine-default", _("Default keymappings"));
+ Keymap *gameKeyMap = new Keymap(Keymap::kKeymapTypeGame, "game-shortcuts", _("Game keymappings"));
+ Keymap *mouseKeyMap = new Keymap(Keymap::kKeymapTypeGame, "mouse-shortcuts", _("Key to mouse keymappings"));
+ Keymap *introKeyMap = new Keymap(Keymap::kKeymapTypeGame, "intro-shortcuts", _("Exit screen keymappings"));
+
+ Action *act;
+
+ act = new Action(kStandardActionLeftClick, _("Left click"));
+ act->setLeftClickEvent();
+ act->addDefaultInputMapping("MOUSE_LEFT");
+ act->addDefaultInputMapping("JOY_A");
+ 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("SKIPSONY", _("Exit Sony intro screen"));
+ act->setCustomEngineActionEvent(kActionExitSonyScreen);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_A");
+ introKeyMap->addAction(act);
+
+ act = new Action("MOUSELEFT", _("Select option / Click in game"));
+ act->setCustomEngineActionEvent(kActionMouseLeft);
+ act->addDefaultInputMapping("RETURN");
+ act->addDefaultInputMapping("KP_ENTER");
+ act->addDefaultInputMapping("KP5");
+ mouseKeyMap->addAction(act);
+
+ act = new Action("MOUSERIGHT", _("Open action menu / Close menu"));
+ act->setCustomEngineActionEvent(kActionMouseRight);
+ act->addDefaultInputMapping("ESCAPE");
+ mouseKeyMap->addAction(act);
+
+ act = new Action("DEFAULTSPEED", _("Default game speed"));
+ act->setCustomEngineActionEvent(kActionGameSpeedDefault);
+ act->addDefaultInputMapping("KP0");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SLOWERSPEED", _("Slower game speed"));
+ act->setCustomEngineActionEvent(kActionGameSpeedSlower);
+ act->addDefaultInputMapping("MINUS");
+ act->addDefaultInputMapping("KP_MINUS");
+ act->allowKbdRepeats();
+ gameKeyMap->addAction(act);
+
+ act = new Action("FASTERSPEED", _("Faster game speed"));
+ act->setCustomEngineActionEvent(kActionGameSpeedFaster);
+ act->addDefaultInputMapping("PLUS");
+ act->addDefaultInputMapping("KP_PLUS");
+ act->addDefaultInputMapping("S+EQUALS");
+ act->allowKbdRepeats();
+ gameKeyMap->addAction(act);
+
+ act = new Action("EXAMINE", _("Examine"));
+ act->setCustomEngineActionEvent(kActionExamine);
+ act->addDefaultInputMapping("F1");
+ gameKeyMap->addAction(act);
+
+ act = new Action("TAKE", _("Take"));
+ act->setCustomEngineActionEvent(kActionTake);
+ act->addDefaultInputMapping("F2");
+ gameKeyMap->addAction(act);
+
+ act = new Action("INVENTORY", _("Inventory"));
+ act->setCustomEngineActionEvent(kActionInventory);
+ act->addDefaultInputMapping("F3");
+ gameKeyMap->addAction(act);
+
+ act = new Action("USE", _("Use"));
+ act->setCustomEngineActionEvent(kActionUse);
+ act->addDefaultInputMapping("F4");
+ gameKeyMap->addAction(act);
+
+ act = new Action("ACTIVATE", _("Activate"));
+ act->setCustomEngineActionEvent(kActionActivate);
+ act->addDefaultInputMapping("F5");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SPEAK", _("Speak"));
+ act->setCustomEngineActionEvent(kActionSpeak);
+ act->addDefaultInputMapping("F6");
+ gameKeyMap->addAction(act);
+
+ act = new Action("ACTMENU", _("Action menu"));
+ act->setCustomEngineActionEvent(kActionActionMenu);
+ act->addDefaultInputMapping("F9");
+ act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
+ gameKeyMap->addAction(act);
+
+ act = new Action("SYSMENU", _("System menu"));
+ act->setCustomEngineActionEvent(kActionSystemMenu);
+ act->addDefaultInputMapping("F10");
+ act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
+ gameKeyMap->addAction(act);
+
+ // I18N: Opens collision map of where the actor can freely move
+ act = new Action("COLLISIONPAGE", _("Show collisions"));
+ act->setCustomEngineActionEvent(kActionCollisionPage);
+ act->addDefaultInputMapping("F11");
+ act->addDefaultInputMapping("JOY_Y");
+ gameKeyMap->addAction(act);
+
+ // I18N: Move Actor to upwards direction
+ act = new Action("MOVEUP", _("Move up"));
+ act->setCustomEngineActionEvent(kActionMoveUp);
+ act->addDefaultInputMapping("KP8");
+ act->addDefaultInputMapping("JOY_UP");
+ gameKeyMap->addAction(act);
+
+ // I18N: Move Actor to downwards direction
+ act = new Action("MOVEDOWN", _("Move down"));
+ act->setCustomEngineActionEvent(kActionMoveDown);
+ act->addDefaultInputMapping("KP2");
+ act->addDefaultInputMapping("JOY_DOWN");
+ gameKeyMap->addAction(act);
+
+ // I18N: Move Actor to left direction
+ act = new Action("MOVELEFT", _("Move left"));
+ act->setCustomEngineActionEvent(kActionMoveLeft);
+ act->addDefaultInputMapping("KP4");
+ act->addDefaultInputMapping("JOY_LEFT");
+ gameKeyMap->addAction(act);
+
+ // I18N: Move Actor to right direction
+ act = new Action("MOVERIGHT", _("Move right"));
+ act->setCustomEngineActionEvent(kActionMoveRight);
+ act->addDefaultInputMapping("KP6");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ gameKeyMap->addAction(act);
+
+ // I18N: Move Actor to top-left direction
+ act = new Action("MOVEUPLEFT", _("Move up-left"));
+ act->setCustomEngineActionEvent(kActionMoveUpLeft);
+ act->addDefaultInputMapping("KP7");
+ gameKeyMap->addAction(act);
+
+ // I18N: Move Actor to top-right direction
+ act = new Action("MOVEUPRIGHT", _("Move up-right"));
+ act->setCustomEngineActionEvent(kActionMoveUpRight);
+ act->addDefaultInputMapping("KP9");
+ gameKeyMap->addAction(act);
+
+ // I18N: Move Actor to bottom-left direction
+ act = new Action("MOVEDOWNLEFT", _("Move down-left"));
+ act->setCustomEngineActionEvent(kActionMoveDownLeft);
+ act->addDefaultInputMapping("KP1");
+ gameKeyMap->addAction(act);
+
+ // I18N: Move Actor to bottom-right direction
+ act = new Action("MOVEDOWNRIGHT", _("Move down-right"));
+ act->setCustomEngineActionEvent(kActionMoveDownRight);
+ act->addDefaultInputMapping("KP3");
+ gameKeyMap->addAction(act);
+
+ act = new Action("MENUUP", _("Menu option up"));
+ act->setCustomEngineActionEvent(kActionMenuOptionUp);
+ act->addDefaultInputMapping("UP");
+ gameKeyMap->addAction(act);
+
+ act = new Action("MENUDOWN", _("Menu option down"));
+ act->setCustomEngineActionEvent(kActionMenuOptionDown);
+ act->addDefaultInputMapping("DOWN");
+ gameKeyMap->addAction(act);
+
+
+ KeymapArray keymaps(4);
+ keymaps[0] = engineKeyMap;
+ keymaps[1] = mouseKeyMap;
+ keymaps[2] = gameKeyMap;
+ keymaps[3] = introKeyMap;
+
+ introKeyMap->setEnabled(false);
+
+ return keymaps;
+}
+
void CineMetaEngine::removeSaveState(const char *target, int slot) const {
if (slot < 0 || slot >= MAX_SAVEGAMES) {
return;
diff --git a/engines/cine/various.cpp b/engines/cine/various.cpp
index 375e6379793..aea3c07daed 100644
--- a/engines/cine/various.cpp
+++ b/engines/cine/various.cpp
@@ -905,18 +905,18 @@ int16 makeMenuChoice(const CommandeType commandList[], uint16 height, uint16 X,
}
} else {
int selectionValueDiff = 0;
- while (!g_cine->_keyInputList.empty()) {
- switch (g_cine->_keyInputList.back().keycode) {
- case Common::KEYCODE_UP:
+ while (!g_cine->_actionList.empty()) {
+ switch (g_cine->_actionList.back()) {
+ case kActionMenuOptionUp:
selectionValueDiff--;
break;
- case Common::KEYCODE_DOWN:
+ case kActionMenuOptionDown:
selectionValueDiff++;
break;
default:
break;
}
- g_cine->_keyInputList.pop_back();
+ g_cine->_actionList.pop_back();
}
if (selectionValueDiff != 0) {
More information about the Scummvm-git-logs
mailing list