ADL: Add keymapper support

This commit is contained in:
Cameron Cawley 2021-07-23 17:27:11 +01:00 committed by Filippos Karapetis
parent c51d5cf6f7
commit 2992675704
4 changed files with 34 additions and 7 deletions

View File

@ -1 +1,2 @@
engines/adl/detection.cpp
engines/adl/metaengine.cpp

View File

@ -108,17 +108,15 @@ AdlEngine::AdlEngine(OSystem *syst, const AdlGameDescription *gd) :
bool AdlEngine::pollEvent(Common::Event &event) const {
if (g_system->getEventManager()->pollEvent(event)) {
if (event.type != Common::EVENT_KEYDOWN)
return false;
if (event.kbd.flags & Common::KBD_CTRL) {
if (event.kbd.keycode == Common::KEYCODE_q) {
if (event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START) {
if (event.customType == kADLActionQuit) {
quitGame();
return false;
}
return false;
}
return true;
if (event.type == Common::EVENT_KEYDOWN)
return true;
}
return false;

View File

@ -69,6 +69,13 @@ enum kDebugChannels {
kDebugChannelScript = 1 << 0
};
enum ADLAction {
kADLActionNone,
kADLActionQuit,
kADLActionCount
};
// Save and restore opcodes
#define IDO_ACT_SAVE 0x0f
#define IDO_ACT_LOAD 0x10

View File

@ -25,9 +25,14 @@
#include "common/system.h"
#include "common/savefile.h"
#include "common/file.h"
#include "common/translation.h"
#include "graphics/thumbnail.h"
#include "backends/keymapper/action.h"
#include "backends/keymapper/keymapper.h"
#include "adl/adl.h"
#include "adl/detection.h"
#include "adl/disk_image_helpers.h"
@ -85,6 +90,7 @@ public:
void removeSaveState(const char *target, int slot) const override;
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const override;
Common::KeymapArray initKeymaps(const char *target) const override;
};
bool AdlMetaEngine::hasFeature(MetaEngineFeature f) const {
@ -246,6 +252,21 @@ Common::Error AdlMetaEngine::createInstance(OSystem *syst, Engine **engine, cons
return Common::kNoError;
}
Common::KeymapArray AdlMetaEngine::initKeymaps(const char *target) const {
using namespace Common;
Keymap *engineKeymap = new Keymap(Keymap::kKeymapTypeGame, "adl", "ADL");
Action *act;
act = new Action("QUIT", _("Quit"));
act->setCustomEngineActionEvent(kADLActionQuit);
act->addDefaultInputMapping("C+q");
engineKeymap->addAction(act);
return Keymap::arrayOf(engineKeymap);
}
} // End of namespace Adl
#if PLUGIN_ENABLED_DYNAMIC(ADL)