mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-11 19:54:03 +00:00
TUCKER: Add keymapper support
This commit is contained in:
parent
73412b42e9
commit
783dfa8bdf
@ -22,6 +22,12 @@
|
||||
#include "common/savefile.h"
|
||||
#include "common/system.h"
|
||||
#include "common/fs.h"
|
||||
#include "common/translation.h"
|
||||
|
||||
#include "backends/keymapper/action.h"
|
||||
#include "backends/keymapper/keymapper.h"
|
||||
#include "backends/keymapper/standard-actions.h"
|
||||
|
||||
#include "engines/advancedDetector.h"
|
||||
#include "base/plugins.h"
|
||||
#include "graphics/thumbnail.h"
|
||||
@ -150,8 +156,82 @@ public:
|
||||
target = getName();
|
||||
return Tucker::generateGameStateFileName(target, saveGameIdx, saveGameIdx == kSavegameFilePattern);
|
||||
}
|
||||
|
||||
Common::KeymapArray initKeymaps(const char *target) const override;
|
||||
};
|
||||
|
||||
Common::KeymapArray TuckerMetaEngine::initKeymaps(const char *target) const {
|
||||
using namespace Common;
|
||||
using namespace Tucker;
|
||||
|
||||
Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "tucker-default", _("Default keymappings"));
|
||||
Keymap *gameKeyMap = new Keymap(Keymap::kKeymapTypeGame, "game-shortcuts", _("Game keymappings"));
|
||||
|
||||
Common::Action *act;
|
||||
|
||||
act = new Common::Action(kStandardActionLeftClick, _("Left click"));
|
||||
act->setLeftClickEvent();
|
||||
act->addDefaultInputMapping("MOUSE_LEFT");
|
||||
act->addDefaultInputMapping("JOY_A");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action(kStandardActionRightClick, _("Right click"));
|
||||
act->setRightClickEvent();
|
||||
act->addDefaultInputMapping("MOUSE_RIGHT");
|
||||
act->addDefaultInputMapping("JOY_B");
|
||||
engineKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("PAUSE", _("Pause"));
|
||||
act->setCustomEngineActionEvent(kActionPause);
|
||||
act->addDefaultInputMapping("p");
|
||||
act->addDefaultInputMapping("JOY_X");
|
||||
gameKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("SKIP_SPEECH", _("Skip speech"));
|
||||
act->setCustomEngineActionEvent(kActionSkipSpeech);
|
||||
act->addDefaultInputMapping("PERIOD");
|
||||
act->addDefaultInputMapping("JOY_LEFT_TRIGGER");
|
||||
gameKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("FAST_MODE", _("Fast mode"));
|
||||
act->setCustomEngineActionEvent(kActionFastMode);
|
||||
act->addDefaultInputMapping("C+f");
|
||||
act->addDefaultInputMapping("JOY_RIGHT_TRIGGER");
|
||||
gameKeyMap->addAction(act);
|
||||
|
||||
// I18N: Panel contains all actor actions and the artstyle is toggled
|
||||
act = new Common::Action("TOGGLE_PANEL_STYLE", _("Toggle panel style"));
|
||||
act->setCustomEngineActionEvent(kActionTogglePanelStyle);
|
||||
act->addDefaultInputMapping("F1");
|
||||
act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
|
||||
gameKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("TOGGLE_TEXT_SPEECH", _("Toggle text speech"));
|
||||
act->setCustomEngineActionEvent(kActionToggleTextSpeech);
|
||||
act->addDefaultInputMapping("F2");
|
||||
act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
|
||||
gameKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("HELP", _("Help"));
|
||||
act->setCustomEngineActionEvent(kActionHelp);
|
||||
act->addDefaultInputMapping("F3");
|
||||
act->addDefaultInputMapping("JOY_Y");
|
||||
gameKeyMap->addAction(act);
|
||||
|
||||
act = new Common::Action("ESCAPE", _("Escape"));
|
||||
act->setCustomEngineActionEvent(kActionEscape);
|
||||
act->addDefaultInputMapping("ESCAPE");
|
||||
act->addDefaultInputMapping("JOY_BACK");
|
||||
gameKeyMap->addAction(act);
|
||||
|
||||
KeymapArray keymaps(2);
|
||||
keymaps[0] = engineKeyMap;
|
||||
keymaps[1] = gameKeyMap;
|
||||
|
||||
return keymaps;
|
||||
}
|
||||
|
||||
|
||||
#if PLUGIN_ENABLED_DYNAMIC(TUCKER)
|
||||
REGISTER_PLUGIN_DYNAMIC(TUCKER, PLUGIN_TYPE_ENGINE, TuckerMetaEngine);
|
||||
#else
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "common/savefile.h"
|
||||
#include "common/textconsole.h"
|
||||
|
||||
#include "backends/keymapper/keymapper.h"
|
||||
|
||||
#include "engines/util.h"
|
||||
|
||||
#include "graphics/cursorman.h"
|
||||
@ -641,40 +643,34 @@ void TuckerEngine::parseEvents() {
|
||||
Common::Event ev;
|
||||
while (_eventMan->pollEvent(ev)) {
|
||||
switch (ev.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
switch (ev.kbd.ascii) {
|
||||
// do not use KEYCODE_PERIOD here so that it works with most keyboard layouts
|
||||
case '.':
|
||||
case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
|
||||
switch (ev.customType) {
|
||||
case kActionEscape:
|
||||
_inputKeys[kInputKeyEscape] = true;
|
||||
// fall through
|
||||
case kActionSkipSpeech:
|
||||
_inputKeys[kInputKeySkipSpeech] = true;
|
||||
break;
|
||||
default:
|
||||
case kActionFastMode:
|
||||
_fastMode = !_fastMode;
|
||||
break;
|
||||
}
|
||||
switch (ev.kbd.keycode) {
|
||||
case Common::KEYCODE_f:
|
||||
if (ev.kbd.hasFlags(Common::KBD_CTRL)) {
|
||||
_fastMode = !_fastMode;
|
||||
}
|
||||
break;
|
||||
case Common::KEYCODE_p:
|
||||
case kActionPause:
|
||||
_inputKeys[kInputKeyPause] = true;
|
||||
break;
|
||||
case Common::KEYCODE_F1:
|
||||
case kActionTogglePanelStyle:
|
||||
_inputKeys[kInputKeyTogglePanelStyle] = true;
|
||||
break;
|
||||
case Common::KEYCODE_F2:
|
||||
case kActionToggleTextSpeech:
|
||||
_inputKeys[kInputKeyToggleTextSpeech] = true;
|
||||
break;
|
||||
case Common::KEYCODE_F3:
|
||||
case kActionHelp:
|
||||
_inputKeys[kInputKeyHelp] = true;
|
||||
break;
|
||||
case Common::KEYCODE_ESCAPE:
|
||||
_inputKeys[kInputKeyEscape] = true;
|
||||
_inputKeys[kInputKeySkipSpeech] = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Common::EVENT_KEYDOWN:
|
||||
_lastKeyPressed = ev.kbd.keycode;
|
||||
break;
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
@ -1638,6 +1634,13 @@ void TuckerEngine::drawData3() {
|
||||
}
|
||||
|
||||
void TuckerEngine::execData3PreUpdate() {
|
||||
Common::Keymapper *keymapper = _eventMan->getKeymapper();
|
||||
if (_location == kLocationComputerScreen) {
|
||||
keymapper->getKeymap("game-shortcuts")->setEnabled(false);
|
||||
} else {
|
||||
keymapper->getKeymap("game-shortcuts")->setEnabled(true);
|
||||
}
|
||||
|
||||
switch (_location) {
|
||||
case 1:
|
||||
execData3PreUpdate_locationNum1();
|
||||
|
@ -53,6 +53,17 @@ class RewindableAudioStream;
|
||||
*/
|
||||
namespace Tucker {
|
||||
|
||||
enum TUCKERAction {
|
||||
kActionNone,
|
||||
kActionSkipSpeech,
|
||||
kActionFastMode,
|
||||
kActionPause,
|
||||
kActionTogglePanelStyle,
|
||||
kActionToggleTextSpeech,
|
||||
kActionHelp,
|
||||
kActionEscape
|
||||
};
|
||||
|
||||
enum CursorStyle {
|
||||
kCursorNormal = 0,
|
||||
kCursorTalk = 1,
|
||||
|
Loading…
Reference in New Issue
Block a user