mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-01 00:12:59 +00:00
DRAGONS: Add keymapper input support
This commit is contained in:
parent
74f7a17dcf
commit
f080bd9f52
@ -1,2 +1,3 @@
|
||||
engines/dragons/detection.cpp
|
||||
engines/dragons/dragons.cpp
|
||||
engines/dragons/detection.cpp
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include "common/savefile.h"
|
||||
#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 "base/plugins.h"
|
||||
#include "graphics/thumbnail.h"
|
||||
|
||||
@ -134,6 +137,7 @@ public:
|
||||
virtual SaveStateList listSaves(const char *target) const;
|
||||
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
|
||||
virtual void removeSaveState(const char *target, int slot) const;
|
||||
Common::KeymapArray initKeymaps(const char *target) const override;
|
||||
};
|
||||
|
||||
bool DragonsMetaEngine::hasFeature(MetaEngineFeature f) const {
|
||||
@ -222,6 +226,109 @@ bool DragonsMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADG
|
||||
return desc != 0;
|
||||
}
|
||||
|
||||
Common::KeymapArray DragonsMetaEngine::initKeymaps(const char *target) const {
|
||||
using namespace Common;
|
||||
|
||||
Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "dragons", "Blazing Dragons");
|
||||
|
||||
Action *act;
|
||||
|
||||
act = new Action("LCLK", _("Action"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionSelect);
|
||||
act->addDefaultInputMapping("MOUSE_LEFT");
|
||||
act->addDefaultInputMapping("JOY_A");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("CHANGECOMMAND", _("Change Command"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionChangeCommand);
|
||||
act->addDefaultInputMapping("MOUSE_RIGHT");
|
||||
act->addDefaultInputMapping("JOY_B");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("INVENTORY", _("Inventory"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionInventory);
|
||||
act->addDefaultInputMapping("i");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("ENTER", _("Enter"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionEnter);
|
||||
act->addDefaultInputMapping("RETURN");
|
||||
act->addDefaultInputMapping("KP_ENTER");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveUp, _("Up"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionUp);
|
||||
act->addDefaultInputMapping("UP");
|
||||
act->addDefaultInputMapping("JOY_UP");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveDown, _("Down"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionDown);
|
||||
act->addDefaultInputMapping("DOWN");
|
||||
act->addDefaultInputMapping("JOY_DOWN");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveLeft, _("Left"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionLeft);
|
||||
act->addDefaultInputMapping("LEFT");
|
||||
act->addDefaultInputMapping("JOY_LEFT");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveRight, _("Right"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionRight);
|
||||
act->addDefaultInputMapping("RIGHT");
|
||||
act->addDefaultInputMapping("JOY_RIGHT");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("SQUARE", _("Square"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionSquare);
|
||||
act->addDefaultInputMapping("a");
|
||||
act->addDefaultInputMapping("JOY_X");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("TRIANGLE", _("Triangle"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionTriangle);
|
||||
act->addDefaultInputMapping("w");
|
||||
act->addDefaultInputMapping("JOY_Y");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("CIRCLE", _("Circle"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionCircle);
|
||||
act->addDefaultInputMapping("d");
|
||||
act->addDefaultInputMapping("JOY_B");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("s", _("Cross"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionCross);
|
||||
act->addDefaultInputMapping("s");
|
||||
act->addDefaultInputMapping("JOY_A");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("L1", _("Left Shoulder"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionL1);
|
||||
act->addDefaultInputMapping("o");
|
||||
act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("R1", _("Right Shoulder"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionR1);
|
||||
act->addDefaultInputMapping("p");
|
||||
act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("DEBUGGFX", _("Debug Graphics"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionDebugGfx);
|
||||
act->addDefaultInputMapping("TAB");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Action("QUIT", _("Quit Game"));
|
||||
act->setCustomEngineActionEvent(Dragons::kDragonsActionQuit);
|
||||
act->addDefaultInputMapping("C+q");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
return Keymap::arrayOf(engineKeyMap);
|
||||
}
|
||||
|
||||
#if PLUGIN_ENABLED_DYNAMIC(DRAGONS)
|
||||
REGISTER_PLUGIN_DYNAMIC(DRAGONS, PLUGIN_TYPE_ENGINE, DragonsMetaEngine);
|
||||
#else
|
||||
|
@ -148,77 +148,75 @@ void DragonsEngine::updateEvents() {
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
_cursor->updatePosition(event.mouse.x, event.mouse.y);
|
||||
break;
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
_leftMouseButtonUp = true;
|
||||
_leftMouseButtonDown = false;
|
||||
break;
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
_leftMouseButtonDown = true;
|
||||
break;
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
_rightMouseButtonUp = true;
|
||||
break;
|
||||
case Common::EVENT_WHEELDOWN:
|
||||
_mouseWheel = MOUSE_WHEEL_DOWN;
|
||||
break;
|
||||
case Common::EVENT_WHEELUP:
|
||||
_mouseWheel = MOUSE_WHEEL_UP;
|
||||
break;
|
||||
case Common::EVENT_KEYUP:
|
||||
if (event.kbd.keycode == Common::KEYCODE_i) {
|
||||
_iKeyUp = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_DOWN) {
|
||||
_downKeyUp = true;
|
||||
_downKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_UP) {
|
||||
_upKeyUp = true;
|
||||
_upKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_RETURN ||
|
||||
event.kbd.keycode == Common::KEYCODE_KP_ENTER) {
|
||||
_enterKeyUp = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_LEFT) {
|
||||
_leftKeyUp = true;
|
||||
_leftKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_RIGHT) {
|
||||
_rightKeyUp = true;
|
||||
_rightKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_w) {
|
||||
_wKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_a) {
|
||||
_aKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_s) {
|
||||
_sKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_d) {
|
||||
_dKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_o) {
|
||||
_oKeyDown = false;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_p) {
|
||||
_pKeyDown = false;
|
||||
case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
|
||||
if (event.customType == Dragons::kDragonsActionLeft) {
|
||||
_leftKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionRight) {
|
||||
_rightKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionUp) {
|
||||
_upKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionDown) {
|
||||
_downKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionSquare) {
|
||||
_aKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionTriangle) {
|
||||
_wKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionCircle) {
|
||||
_dKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionCross) {
|
||||
_sKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionL1) {
|
||||
_oKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionR1) {
|
||||
_pKeyDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionSelect) {
|
||||
_leftMouseButtonDown = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionDebugGfx) {
|
||||
_debugMode = !_debugMode;
|
||||
}
|
||||
break;
|
||||
case Common::EVENT_KEYDOWN:
|
||||
if (event.kbd.keycode == Common::KEYCODE_LEFT) {
|
||||
_leftKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_RIGHT) {
|
||||
_rightKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_UP) {
|
||||
_upKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_DOWN) {
|
||||
_downKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_w) {
|
||||
_wKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_a) {
|
||||
_aKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_s) {
|
||||
_sKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_d) {
|
||||
_dKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_o) {
|
||||
_oKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_p) {
|
||||
_pKeyDown = true;
|
||||
} else if (event.kbd.keycode == Common::KEYCODE_TAB) {
|
||||
_debugMode = !_debugMode;
|
||||
case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
|
||||
if (event.customType == Dragons::kDragonsActionLeft) {
|
||||
_leftKeyUp = true;
|
||||
_leftKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionRight) {
|
||||
_rightKeyUp = true;
|
||||
_rightKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionUp) {
|
||||
_upKeyUp = true;
|
||||
_upKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionDown) {
|
||||
_downKeyUp = true;
|
||||
_downKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionSquare) {
|
||||
_aKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionTriangle) {
|
||||
_wKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionCircle) {
|
||||
_dKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionCross) {
|
||||
_sKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionL1) {
|
||||
_oKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionR1) {
|
||||
_pKeyDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionSelect) {
|
||||
_leftMouseButtonUp = true;
|
||||
_leftMouseButtonDown = false;
|
||||
} else if (event.customType == Dragons::kDragonsActionChangeCommand) {
|
||||
_rightMouseButtonUp = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionInventory) {
|
||||
_iKeyUp = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionEnter) {
|
||||
_enterKeyUp = true;
|
||||
} else if (event.customType == Dragons::kDragonsActionQuit) {
|
||||
quitGame();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -109,6 +109,29 @@ struct PaletteCyclingInstruction {
|
||||
int16 updateCounter;
|
||||
};
|
||||
|
||||
enum DragonsAction {
|
||||
kDragonsActionNone,
|
||||
kDragonsActionUp,
|
||||
kDragonsActionDown,
|
||||
kDragonsActionLeft,
|
||||
kDragonsActionRight,
|
||||
kDragonsActionSquare,
|
||||
kDragonsActionTriangle,
|
||||
kDragonsActionCircle,
|
||||
kDragonsActionCross,
|
||||
kDragonsActionL1,
|
||||
kDragonsActionR1,
|
||||
kDragonsActionSelect,
|
||||
kDragonsActionChangeCommand,
|
||||
kDragonsActionInventory,
|
||||
kDragonsActionEnter,
|
||||
kDragonsActionMenu,
|
||||
kDragonsActionPause,
|
||||
kDragonsActionDebug,
|
||||
kDragonsActionDebugGfx,
|
||||
kDragonsActionQuit
|
||||
};
|
||||
|
||||
class BigfileArchive;
|
||||
class BackgroundResourceLoader;
|
||||
class Cursor;
|
||||
|
@ -50,7 +50,8 @@ void StrPlayer::playVideo(const Common::String &filename) {
|
||||
|
||||
Common::Event event;
|
||||
while (_vm->_system->getEventManager()->pollEvent(event)) {
|
||||
if ((event.type == Common::EVENT_KEYDOWN && event.kbd.keycode == Common::KEYCODE_ESCAPE) || event.type == Common::EVENT_LBUTTONUP) {
|
||||
if (event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_END
|
||||
&& (event.customType == Dragons::kDragonsActionSelect || event.customType == Dragons::kDragonsActionEnter)) {
|
||||
skipped = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user