[Scummvm-git-logs] scummvm master -> 70465214ece9dcd2fc71fa3859e4bc36ed147af6

bluegr noreply at scummvm.org
Fri Jul 12 15:43:19 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:
70465214ec GROOVIE: Add keymapper support


Commit: 70465214ece9dcd2fc71fa3859e4bc36ed147af6
    https://github.com/scummvm/scummvm/commit/70465214ece9dcd2fc71fa3859e4bc36ed147af6
Author: NabeelShabbir (i210443 at nu.edu.pk)
Date: 2024-07-12T18:43:16+03:00

Commit Message:
GROOVIE: Add keymapper support

Changed paths:
    engines/groovie/groovie.cpp
    engines/groovie/groovie.h
    engines/groovie/metaengine.cpp
    engines/groovie/script.cpp
    engines/groovie/script.h


diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp
index cec1907acbd..959e188d4e1 100644
--- a/engines/groovie/groovie.cpp
+++ b/engines/groovie/groovie.cpp
@@ -266,6 +266,9 @@ Common::Error GroovieEngine::run() {
 		Common::Event ev;
 		while (_eventMan->pollEvent(ev)) {
 			switch (ev.type) {
+			case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+				_script->setAction(ev.customType);
+				break;
 			case Common::EVENT_KEYDOWN:
 				// Send the event to the scripts
 				_script->setKbdChar(ev.kbd.ascii);
diff --git a/engines/groovie/groovie.h b/engines/groovie/groovie.h
index 7e4aa980da6..f9dd88d3ce5 100644
--- a/engines/groovie/groovie.h
+++ b/engines/groovie/groovie.h
@@ -85,6 +85,11 @@ enum GameSpeed {
 	kGroovieSpeedFast
 };
 
+enum GROOVIEAction {
+	kActionNone,
+	kActionSkip
+};
+
 #define MAX_SAVES 25
 
 struct GroovieGameDescription;
diff --git a/engines/groovie/metaengine.cpp b/engines/groovie/metaengine.cpp
index 94e1545755d..b866b08673d 100644
--- a/engines/groovie/metaengine.cpp
+++ b/engines/groovie/metaengine.cpp
@@ -25,6 +25,10 @@
 #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 "engines/advancedDetector.h"
 #include "groovie/detection.h"
 
@@ -136,6 +140,8 @@ public:
 	void removeSaveState(const char *target, int slot) const override;
 	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
 	int getAutosaveSlot() const override;
+
+	Common::KeymapArray initKeymaps(const char *target) const override;
 };
 
 Common::Error GroovieMetaEngine::createInstance(OSystem *syst, Engine **engine, const GroovieGameDescription *gd) const {
@@ -188,6 +194,36 @@ int GroovieMetaEngine::getAutosaveSlot() const {
 	return GroovieEngine::AUTOSAVE_SLOT;
 }
 
+Common::KeymapArray GroovieMetaEngine::initKeymaps(const char *target) const {
+	using namespace Common;
+	using namespace Groovie;
+
+	Keymap *engineKeyMap = new Keymap(Keymap::kKeymapTypeGame, "groovie-engine", _("Groovie engine"));
+
+	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("SKIPORFAST", _("Skip or fast forward scene"));
+	act->setCustomEngineActionEvent(kActionSkip);
+	act->addDefaultInputMapping("ESCAPE");
+	act->addDefaultInputMapping("SPACE");
+	act->addDefaultInputMapping("JOY_X");
+	engineKeyMap->addAction(act);
+
+	return Keymap::arrayOf(engineKeyMap);
+}
+
 } // End of namespace Groovie
 
 #if PLUGIN_ENABLED_DYNAMIC(GROOVIE)
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index c6dd0a144b5..70ed858980b 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -118,6 +118,7 @@ Script::Script(GroovieEngine *vm, EngineVersion version) :
 	_videoSkipAddress = 0;
 	resetFastForward();
 	_eventKbdChar = 0;
+	_eventAction = kActionNone;
 	_eventMouseClicked = 0;
 	_wantAutosave = false;
 }
@@ -397,6 +398,10 @@ void Script::setKbdChar(uint8 c) {
 	_eventKbdChar = c;
 }
 
+void Script::setAction(uint8 a) {
+	_eventAction = a;
+}
+
 Common::String &Script::getContext() {
 	return _debugString;
 }
@@ -983,11 +988,12 @@ bool Script::playvideofromref(uint32 fileref, bool loopUntilAudioDone) {
 	}
 
 	// Check if the user wants to skip the video
-	if (_eventMouseClicked == 2 || _eventKbdChar == Common::KEYCODE_ESCAPE || _eventKbdChar == Common::KEYCODE_SPACE) {
+	if (_eventMouseClicked == 2 || _eventAction == kActionSkip) {
 		// we don't want to clear a left click here, that would eat the input
 		if (_eventMouseClicked == 2)
 			_eventMouseClicked = 0;
 		_eventKbdChar = 0;
+		_eventAction = kActionNone;
 		if (_videoSkipAddress != 0) {
 			// Jump to the given address
 			_currentInstruction = _videoSkipAddress;
@@ -1038,6 +1044,7 @@ bool Script::playvideofromref(uint32 fileref, bool loopUntilAudioDone) {
 			// Clear the input events while playing the video
 			_eventMouseClicked = 0;
 			_eventKbdChar = 0;
+			_eventAction = kActionNone;
 
 			// Newline
 			debugCN(1, kDebugScript, "\n");
@@ -1103,6 +1110,7 @@ void Script::o_inputloopstart() {	//0x0B
 	// Save the current pressed character for the whole loop
 	_kbdChar = _eventKbdChar;
 	_eventKbdChar = 0;
+	_eventAction = kActionNone;
 }
 
 void Script::o_keyboardaction() {
@@ -1329,7 +1337,7 @@ void Script::o_sleep() {
 	while (_vm->_system->getMillis() < endTime && !_fastForwarding) {
 		_vm->_system->getEventManager()->pollEvent(ev);
 		if (ev.type == Common::EVENT_RBUTTONDOWN
-			|| (ev.type == Common::EVENT_KEYDOWN && (ev.kbd.ascii == Common::KEYCODE_SPACE || ev.kbd.ascii == Common::KEYCODE_ESCAPE))
+			|| (ev.type == Common::EVENT_CUSTOM_ENGINE_ACTION_START && (ev.customType == kActionSkip))
 		) {
 			_fastForwarding = true;
 			break;
diff --git a/engines/groovie/script.h b/engines/groovie/script.h
index ff1b378e4dd..cf7f841123e 100644
--- a/engines/groovie/script.h
+++ b/engines/groovie/script.h
@@ -72,6 +72,7 @@ public:
 
 	void setMouseClick(uint8 button);
 	void setKbdChar(uint8 c);
+	void setAction(uint8 a);
 
 	void setBitFlag(int bitnum, bool value);
 	bool getBitFlag(int bitnum);
@@ -118,6 +119,7 @@ private:
 	uint8 _eventMouseClicked;
 	uint8 _kbdChar;
 	uint8 _eventKbdChar;
+	uint8 _eventAction;
 	uint16 _inputLoopAddress;
 	uint8 _newCursorStyle;
 	uint16 _hotspotTopAction;




More information about the Scummvm-git-logs mailing list