mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
ZVISION: Add keymapper support
This commit is contained in:
parent
bc0553951f
commit
496edf905f
@ -222,25 +222,25 @@ void ZVision::processEvents() {
|
||||
onMouseMove(_event.mouse);
|
||||
break;
|
||||
|
||||
case Common::EVENT_KEYDOWN: {
|
||||
switch (_event.kbd.keycode) {
|
||||
case Common::KEYCODE_LEFT:
|
||||
case Common::KEYCODE_RIGHT:
|
||||
case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
|
||||
switch ((ZVisionAction)_event.customType) {
|
||||
case kZVisionActionLeft:
|
||||
case kZVisionActionRight:
|
||||
if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
|
||||
_keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_LEFT ?
|
||||
_keyboardVelocity = (_event.customType == kZVisionActionLeft ?
|
||||
-_scriptManager->getStateValue(StateKey_KbdRotateSpeed) :
|
||||
_scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2;
|
||||
break;
|
||||
|
||||
case Common::KEYCODE_UP:
|
||||
case Common::KEYCODE_DOWN:
|
||||
case kZVisionActionUp:
|
||||
case kZVisionActionDown:
|
||||
if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT)
|
||||
_keyboardVelocity = (_event.kbd.keycode == Common::KEYCODE_UP ?
|
||||
_keyboardVelocity = (_event.customType == kZVisionActionUp ?
|
||||
-_scriptManager->getStateValue(StateKey_KbdRotateSpeed) :
|
||||
_scriptManager->getStateValue(StateKey_KbdRotateSpeed)) * 2;
|
||||
break;
|
||||
|
||||
case Common::KEYCODE_F10: {
|
||||
case kZVisionActionShowFPS: {
|
||||
Common::String fpsStr = Common::String::format("FPS: %d", getFPS());
|
||||
_renderManager->showDebugMsg(fpsStr);
|
||||
}
|
||||
@ -248,7 +248,26 @@ void ZVision::processEvents() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
|
||||
switch ((ZVisionAction)_event.customType) {
|
||||
case kZVisionActionLeft:
|
||||
case kZVisionActionRight:
|
||||
if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
|
||||
_keyboardVelocity = 0;
|
||||
break;
|
||||
case kZVisionActionUp:
|
||||
case kZVisionActionDown:
|
||||
if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT)
|
||||
_keyboardVelocity = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case Common::EVENT_KEYDOWN: {
|
||||
uint8 vkKey = getZvisionKey(_event.kbd.keycode);
|
||||
|
||||
_scriptManager->setStateValue(StateKey_KeyPress, vkKey);
|
||||
@ -260,20 +279,6 @@ void ZVision::processEvents() {
|
||||
break;
|
||||
case Common::EVENT_KEYUP:
|
||||
_scriptManager->addEvent(_event);
|
||||
switch (_event.kbd.keycode) {
|
||||
case Common::KEYCODE_LEFT:
|
||||
case Common::KEYCODE_RIGHT:
|
||||
if (_renderManager->getRenderTable()->getRenderState() == RenderTable::PANORAMA)
|
||||
_keyboardVelocity = 0;
|
||||
break;
|
||||
case Common::KEYCODE_UP:
|
||||
case Common::KEYCODE_DOWN:
|
||||
if (_renderManager->getRenderTable()->getRenderState() == RenderTable::TILT)
|
||||
_keyboardVelocity = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -30,6 +30,10 @@
|
||||
#include "zvision/file/save_manager.h"
|
||||
#include "zvision/scripting/script_manager.h"
|
||||
|
||||
#include "backends/keymapper/action.h"
|
||||
#include "backends/keymapper/keymapper.h"
|
||||
#include "backends/keymapper/standard-actions.h"
|
||||
|
||||
#include "common/translation.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/str-array.h"
|
||||
@ -76,6 +80,7 @@ public:
|
||||
}
|
||||
|
||||
bool hasFeature(MetaEngineFeature f) const override;
|
||||
Common::KeymapArray initKeymaps(const char *target) const override;
|
||||
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
|
||||
SaveStateList listSaves(const char *target) const override;
|
||||
int getMaximumSaveSlot() const override;
|
||||
@ -120,6 +125,131 @@ bool ZVision::ZVision::canSaveGameStateCurrently() {
|
||||
return !_videoIsPlaying && currentLocation.world != 'g' && !(currentLocation.room == 'j' || currentLocation.room == 'a');
|
||||
}
|
||||
|
||||
Common::KeymapArray ZVisionMetaEngine::initKeymaps(const char *target) const {
|
||||
using namespace Common;
|
||||
using namespace ZVision;
|
||||
|
||||
Keymap *mainKeymap = new Keymap(Keymap::kKeymapTypeGame, mainKeymapId, "Z-Vision");
|
||||
|
||||
Action *act;
|
||||
|
||||
act = new Action("LCLK", _("Left Click"));
|
||||
act->setLeftClickEvent();
|
||||
act->addDefaultInputMapping("MOUSE_LEFT");
|
||||
act->addDefaultInputMapping("JOY_A");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("RCLK", _("Right Click"));
|
||||
act->setRightClickEvent();
|
||||
act->addDefaultInputMapping("MOUSE_RIGHT");
|
||||
act->addDefaultInputMapping("JOY_B");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveUp, _("Look Up"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionUp);
|
||||
act->addDefaultInputMapping("UP");
|
||||
act->addDefaultInputMapping("JOY_UP");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveDown, _("Look Down"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionDown);
|
||||
act->addDefaultInputMapping("DOWN");
|
||||
act->addDefaultInputMapping("JOY_DOWN");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveLeft, _("Turn Left"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionLeft);
|
||||
act->addDefaultInputMapping("LEFT");
|
||||
act->addDefaultInputMapping("JOY_LEFT");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionMoveRight, _("Turn Right"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionRight);
|
||||
act->addDefaultInputMapping("RIGHT");
|
||||
act->addDefaultInputMapping("JOY_RIGHT");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("FPS", _("Show FPS"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionShowFPS);
|
||||
act->addDefaultInputMapping("F10");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("HELP", _("Help"));
|
||||
act->setKeyEvent(KEYCODE_F1);
|
||||
act->addDefaultInputMapping("F1");
|
||||
act->addDefaultInputMapping("JOY_LEFT_TRIGGER");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("INV", _("Inventory"));
|
||||
act->setKeyEvent(KEYCODE_F5);
|
||||
act->addDefaultInputMapping("F5");
|
||||
act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("SPELL", _("Spellbook"));
|
||||
act->setKeyEvent(KEYCODE_F6);
|
||||
act->addDefaultInputMapping("F6");
|
||||
act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("SCORE", _("Score"));
|
||||
act->setKeyEvent(KEYCODE_F7);
|
||||
act->addDefaultInputMapping("F7");
|
||||
act->addDefaultInputMapping("JOY_RIGHT_TRIGGER");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("AWAY", _("Put away object"));
|
||||
act->setKeyEvent(KEYCODE_F8);
|
||||
act->addDefaultInputMapping("F8");
|
||||
act->addDefaultInputMapping("JOY_X");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("COIN", _("Extract coin"));
|
||||
act->setKeyEvent(KEYCODE_F9);
|
||||
act->addDefaultInputMapping("F9");
|
||||
act->addDefaultInputMapping("JOY_Y");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionSave, _("Save"));
|
||||
act->setKeyEvent(KeyState(KEYCODE_s, 's', KBD_CTRL));
|
||||
act->addDefaultInputMapping("C+s");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionLoad, _("Restore"));
|
||||
act->setKeyEvent(KeyState(KEYCODE_r, 'r', KBD_CTRL));
|
||||
act->addDefaultInputMapping("C+r");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action("QUIT", _("Quit"));
|
||||
act->setKeyEvent(KeyState(KEYCODE_q, 'q', KBD_CTRL));
|
||||
act->addDefaultInputMapping("C+q");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
act = new Action(kStandardActionOpenSettings, _("Preferences"));
|
||||
act->setKeyEvent(KeyState(KEYCODE_p, 'p', KBD_CTRL));
|
||||
act->addDefaultInputMapping("C+p");
|
||||
mainKeymap->addAction(act);
|
||||
|
||||
Keymap *cutscenesKeymap = new Keymap(Keymap::kKeymapTypeGame, cutscenesKeymapId, "Z-Vision - Cutscenes");
|
||||
|
||||
act = new Action(kStandardActionSkip, _("Skip cutscene"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionSkipCutscene);
|
||||
act->addDefaultInputMapping("SPACE");
|
||||
act->addDefaultInputMapping("JOY_Y");
|
||||
cutscenesKeymap->addAction(act);
|
||||
|
||||
act = new Action("QUIT", _("Quit"));
|
||||
act->setCustomEngineActionEvent(kZVisionActionQuit);
|
||||
act->addDefaultInputMapping("C+q");
|
||||
cutscenesKeymap->addAction(act);
|
||||
|
||||
KeymapArray keymaps(2);
|
||||
keymaps[0] = mainKeymap;
|
||||
keymaps[1] = cutscenesKeymap;
|
||||
|
||||
return keymaps;
|
||||
}
|
||||
|
||||
bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
||||
const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;
|
||||
if (gd) {
|
||||
|
@ -992,6 +992,7 @@ bool RenderManager::askQuestion(const Common::String &str) {
|
||||
// Spanish: si/no
|
||||
// French Nemesis: F4/any other key
|
||||
// French ZGI: oui/non
|
||||
// TODO: Handle this using the keymapper
|
||||
switch (evnt.kbd.keycode) {
|
||||
case Common::KEYCODE_y:
|
||||
if (_engine->getLanguage() == Common::EN_ANY)
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "engines/util.h"
|
||||
#include "graphics/surface.h"
|
||||
|
||||
#include "backends/keymapper/keymap.h"
|
||||
|
||||
#include "zvision/zvision.h"
|
||||
#include "zvision/core/clock.h"
|
||||
#include "zvision/graphics/render_manager.h"
|
||||
@ -91,18 +93,20 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect,
|
||||
vid.start();
|
||||
_videoIsPlaying = true;
|
||||
|
||||
_cutscenesKeymap->setEnabled(true);
|
||||
_mainKeymap->setEnabled(false);
|
||||
|
||||
// Only continue while the video is still playing
|
||||
while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) {
|
||||
// Check for engine quit and video stop key presses
|
||||
while (_eventMan->pollEvent(_event)) {
|
||||
switch (_event.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
switch (_event.kbd.keycode) {
|
||||
case Common::KEYCODE_q:
|
||||
if (_event.kbd.hasFlags(Common::KBD_CTRL))
|
||||
quitGame();
|
||||
case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
|
||||
switch ((ZVisionAction)_event.customType) {
|
||||
case kZVisionActionQuit:
|
||||
quitGame();
|
||||
break;
|
||||
case Common::KEYCODE_SPACE:
|
||||
case kZVisionActionSkipCutscene:
|
||||
if (skippable) {
|
||||
vid.stop();
|
||||
}
|
||||
@ -137,6 +141,9 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect,
|
||||
_system->delayMillis(vid.getTimeToNextFrame() / 2);
|
||||
}
|
||||
|
||||
_cutscenesKeymap->setEnabled(false);
|
||||
_mainKeymap->setEnabled(true);
|
||||
|
||||
_videoIsPlaying = false;
|
||||
_clock.start();
|
||||
|
||||
|
@ -35,6 +35,9 @@
|
||||
#include "zvision/text/truetype_font.h"
|
||||
#include "zvision/sound/midi.h"
|
||||
|
||||
#include "backends/keymapper/keymap.h"
|
||||
#include "backends/keymapper/keymapper.h"
|
||||
|
||||
#include "common/config-manager.h"
|
||||
#include "common/str.h"
|
||||
#include "common/debug.h"
|
||||
@ -76,6 +79,9 @@ struct zvisionIniSettings {
|
||||
{"mpegmovies", StateKey_MPEGMovies, -1, true, true} // Zork: Grand Inquisitor DVD hi-res MPEG movies (0 = normal, 1 = hires, 2 = disable option)
|
||||
};
|
||||
|
||||
const char *mainKeymapId = "zvision";
|
||||
const char *cutscenesKeymapId = "zvision-cutscenes";
|
||||
|
||||
ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
|
||||
: Engine(syst),
|
||||
_gameDescription(gameDesc),
|
||||
@ -200,6 +206,12 @@ void ZVision::initialize() {
|
||||
|
||||
initScreen();
|
||||
|
||||
Common::Keymapper *keymapper = _system->getEventManager()->getKeymapper();
|
||||
_mainKeymap = keymapper->getKeymap(mainKeymapId);
|
||||
_mainKeymap->setEnabled(true);
|
||||
_cutscenesKeymap = keymapper->getKeymap(cutscenesKeymapId);
|
||||
_cutscenesKeymap->setEnabled(false);
|
||||
|
||||
// Register random source
|
||||
_rnd = new Common::RandomSource("zvision");
|
||||
|
||||
|
@ -36,6 +36,10 @@
|
||||
|
||||
#include "gui/debugger.h"
|
||||
|
||||
namespace Common {
|
||||
class Keymap;
|
||||
}
|
||||
|
||||
namespace Video {
|
||||
class VideoDecoder;
|
||||
}
|
||||
@ -96,6 +100,22 @@ enum ZVisionFeatures {
|
||||
GF_DVD = (1 << 0) // ZGI DVD version
|
||||
};
|
||||
|
||||
enum ZVisionAction {
|
||||
kZVisionActionNone,
|
||||
kZVisionActionUp,
|
||||
kZVisionActionDown,
|
||||
kZVisionActionLeft,
|
||||
kZVisionActionRight,
|
||||
kZVisionActionShowFPS,
|
||||
kZVisionActionSkipCutscene,
|
||||
kZVisionActionQuit,
|
||||
|
||||
kZVisionActionCount
|
||||
};
|
||||
|
||||
extern const char *mainKeymapId;
|
||||
extern const char *cutscenesKeymapId;
|
||||
|
||||
class ZVision : public Engine {
|
||||
public:
|
||||
ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);
|
||||
@ -139,6 +159,8 @@ private:
|
||||
// To prevent allocation every time we process events
|
||||
Common::Event _event;
|
||||
|
||||
Common::Keymap *_mainKeymap, *_cutscenesKeymap;
|
||||
|
||||
int _frameRenderDelay;
|
||||
int _renderedFrameCount;
|
||||
int _fps;
|
||||
|
Loading…
Reference in New Issue
Block a user