[Scummvm-git-logs] scummvm master -> 22a21e99cc864194c754f9a9fdc25cb53a106ac2

sev- noreply at scummvm.org
Sun May 14 20:43:04 UTC 2023


This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
74ddbe5eaa BACKENDS: Add double-click time feature to support OS-configurable double-click intervals, implement it for Windows.
126ccc5983 BACKENDS: Fix double click time pull from event recorder not working correctly.
6c8ceeae25 BACKENDS: Refactor some things to make getDoubleClickTime behavior with event recorder simpler.
ee758dee53 BACKENDS: Undo some formatting-only changes.
22a21e99cc TESTBED: Add tests for double-click time.


Commit: 74ddbe5eaa479ec134478d90fb6156bbe30ddb68
    https://github.com/scummvm/scummvm/commit/74ddbe5eaa479ec134478d90fb6156bbe30ddb68
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-14T22:42:59+02:00

Commit Message:
BACKENDS: Add double-click time feature to support OS-configurable double-click intervals, implement it for Windows.

Changed paths:
    backends/platform/sdl/sdl.cpp
    backends/platform/sdl/sdl.h
    common/system.h
    gui/EventRecorder.cpp
    gui/EventRecorder.h


diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 0e0821ceda3..2f8bb5035d5 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -89,7 +89,10 @@ OSystem_SDL::OSystem_SDL()
 	_logger(nullptr),
 	_eventSource(nullptr),
 	_eventSourceWrapper(nullptr),
-	_window(nullptr) {
+	_window(nullptr),
+	_haveDoubleClickTime(false),
+	_doubleClickTime(0)
+{
 }
 
 OSystem_SDL::~OSystem_SDL() {
@@ -188,6 +191,15 @@ bool OSystem_SDL::hasFeature(Feature f) {
 	if (f == kFeatureOpenGLForGame) return true;
 	if (f == kFeatureShadersForGame) return _supportsShaders;
 #endif
+
+	if (f == kFeatureDoubleClickTime) {
+		bool haveDoubleClickTime = _haveDoubleClickTime;
+#ifdef ENABLE_EVENTRECORDER
+		g_eventRec.processHaveDoubleClickTime(haveDoubleClickTime);
+#endif
+		return haveDoubleClickTime;
+	}
+
 	return ModularGraphicsBackend::hasFeature(f);
 }
 
@@ -762,6 +774,14 @@ Common::SaveFileManager *OSystem_SDL::getSavefileManager() {
 #endif
 }
 
+uint32 OSystem_SDL::getDoubleClickTime() const {
+	uint32 doubleClickTime = _doubleClickTime;
+#ifdef ENABLE_EVENTRECORDER
+	g_eventRec.processDoubleClickTime(doubleClickTime);
+#endif
+	return _doubleClickTime;
+}
+
 //Not specified in base class
 Common::String OSystem_SDL::getDefaultIconsPath() {
 	Common::String path = ConfMan.get("iconspath");
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index 28ba76a09ed..e743a94298a 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -89,6 +89,7 @@ public:
 	MixerManager *getMixerManager() override;
 	Common::TimerManager *getTimerManager() override;
 	Common::SaveFileManager *getSavefileManager() override;
+	uint32 getDoubleClickTime() const override;
 
 	// Default paths
 	virtual Common::String getDefaultIconsPath();
@@ -187,6 +188,9 @@ protected:
 	bool setGraphicsMode(int mode, uint flags) override;
 	int getGraphicsMode() const override;
 #endif
+
+	bool _haveDoubleClickTime;
+	uint32 _doubleClickTime;
 };
 
 #endif
diff --git a/common/system.h b/common/system.h
index 3941bf835c4..cb25429a7a2 100644
--- a/common/system.h
+++ b/common/system.h
@@ -548,7 +548,12 @@ public:
 		/**
 		* For platforms that should not have a Quit button.
 		*/
-		kFeatureNoQuit
+		kFeatureNoQuit,
+
+		/**
+		* Supports getDoubleClickTime call.
+		*/
+		kFeatureDoubleClickTime,
 	};
 
 	/**
@@ -1389,6 +1394,16 @@ public:
 	 */
 	virtual void setCursorPalette(const byte *colors, uint start, uint num) {}
 
+	
+
+	/** Get the system-configured double-click time interval.
+	 *
+	 * Backends which implement this should have the kFeatureDoubleClickTime flag set.
+	 *
+	 * @see kFeatureDoubleClickTime
+	 */
+	virtual uint32 getDoubleClickTime() const { return 0; }
+
 	/** @} */
 
 
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index 1e3b73d0657..816f561c68b 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -512,6 +512,9 @@ void EventRecorder::getConfigFromDomain(const Common::ConfigManager::Domain *dom
 }
 
 void EventRecorder::getConfig() {
+	if (g_system->hasFeature(OSystem::kFeatureDoubleClickTime))
+		_recordFile->getHeader().settingsRecords["double_click_time"] = Common::String::format("%u", static_cast<unsigned int>(g_system->getDoubleClickTime()));
+
 	getConfigFromDomain(ConfMan.getDomain(ConfMan.kApplicationDomain));
 	getConfigFromDomain(ConfMan.getActiveDomain());
 	_recordFile->getHeader().settingsRecords["save_slot"] = ConfMan.get("save_slot");
@@ -687,6 +690,27 @@ Common::SeekableReadStream *EventRecorder::processSaveStream(const Common::Strin
 	}
 }
 
+void EventRecorder::processHaveDoubleClickTime(bool &haveDoubleClickTime) {
+	if (_initialized && (_recordMode == kRecorderPlayback || _recordMode == kRecorderUpdate))
+		haveDoubleClickTime = _playbackFile->getHeader().settingsRecords.contains("double_click_time");
+}
+
+void EventRecorder::processDoubleClickTime(uint32 &doubleClickTime) {
+	if (_initialized && (_recordMode == kRecorderPlayback || _recordMode == kRecorderUpdate)) {
+		const Common::StringMap &settings = _playbackFile->getHeader().settingsRecords;
+		Common::StringMap::const_iterator it = settings.find("double_click_time");
+		if (it == settings.end())
+			doubleClickTime = 0;
+		else {
+			unsigned int temp = 0;
+			if (sscanf(it->_value.c_str(), "%u", &temp))
+				doubleClickTime = temp;
+			else
+				doubleClickTime = 0;
+		}
+	}
+}
+
 Common::SaveFileManager *EventRecorder::getSaveManager(Common::SaveFileManager *realSaveManager) {
 	_realSaveManager = realSaveManager;
 	if (_recordMode != kPassthrough) {
diff --git a/gui/EventRecorder.h b/gui/EventRecorder.h
index 9beaea8e9d7..acbf5992f7c 100644
--- a/gui/EventRecorder.h
+++ b/gui/EventRecorder.h
@@ -87,6 +87,8 @@ public:
 	void processGameDescription(const ADGameDescription *desc);
 	bool processAutosave();
 	Common::SeekableReadStream *processSaveStream(const Common::String & fileName);
+	void processHaveDoubleClickTime(bool &haveDoubleClickTime);
+	void processDoubleClickTime(uint32 &doubleClickTime);
 
 	/** Hooks for intercepting into GUI processing, so required events could be shoot
 	 *  or filtered out */


Commit: 126ccc5983586b3f30b0784d767c6db24af93d13
    https://github.com/scummvm/scummvm/commit/126ccc5983586b3f30b0784d767c6db24af93d13
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-14T22:42:59+02:00

Commit Message:
BACKENDS: Fix double click time pull from event recorder not working correctly.

Changed paths:
    backends/platform/sdl/sdl.cpp


diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 2f8bb5035d5..58c9e98f341 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -779,7 +779,7 @@ uint32 OSystem_SDL::getDoubleClickTime() const {
 #ifdef ENABLE_EVENTRECORDER
 	g_eventRec.processDoubleClickTime(doubleClickTime);
 #endif
-	return _doubleClickTime;
+	return doubleClickTime;
 }
 
 //Not specified in base class


Commit: 6c8ceeae25c894286e4acc5dc0387aae19d97702
    https://github.com/scummvm/scummvm/commit/6c8ceeae25c894286e4acc5dc0387aae19d97702
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-14T22:42:59+02:00

Commit Message:
BACKENDS: Refactor some things to make getDoubleClickTime behavior with event recorder simpler.

Changed paths:
    backends/platform/sdl/sdl.cpp
    backends/platform/sdl/sdl.h
    backends/platform/sdl/win32/win32.cpp
    backends/platform/sdl/win32/win32.h
    common/system.h
    gui/EventRecorder.cpp
    gui/EventRecorder.h


diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 58c9e98f341..7ce019e0f4a 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -89,9 +89,7 @@ OSystem_SDL::OSystem_SDL()
 	_logger(nullptr),
 	_eventSource(nullptr),
 	_eventSourceWrapper(nullptr),
-	_window(nullptr),
-	_haveDoubleClickTime(false),
-	_doubleClickTime(0)
+	_window(nullptr)
 {
 }
 
@@ -192,14 +190,6 @@ bool OSystem_SDL::hasFeature(Feature f) {
 	if (f == kFeatureShadersForGame) return _supportsShaders;
 #endif
 
-	if (f == kFeatureDoubleClickTime) {
-		bool haveDoubleClickTime = _haveDoubleClickTime;
-#ifdef ENABLE_EVENTRECORDER
-		g_eventRec.processHaveDoubleClickTime(haveDoubleClickTime);
-#endif
-		return haveDoubleClickTime;
-	}
-
 	return ModularGraphicsBackend::hasFeature(f);
 }
 
@@ -775,11 +765,10 @@ Common::SaveFileManager *OSystem_SDL::getSavefileManager() {
 }
 
 uint32 OSystem_SDL::getDoubleClickTime() const {
-	uint32 doubleClickTime = _doubleClickTime;
-#ifdef ENABLE_EVENTRECORDER
-	g_eventRec.processDoubleClickTime(doubleClickTime);
-#endif
-	return doubleClickTime;
+	if (ConfMan.hasKey("double_click_time"))
+		return ConfMan.getInt("double_click_time");
+
+	return getOSDoubleClickTime();
 }
 
 //Not specified in base class
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index e743a94298a..450a6f28d98 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -189,8 +189,7 @@ protected:
 	int getGraphicsMode() const override;
 #endif
 
-	bool _haveDoubleClickTime;
-	uint32 _doubleClickTime;
+	virtual uint32 getOSDoubleClickTime() const { return 0; }
 };
 
 #endif
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index 4f1084ec09a..d1bdbcd5772 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -83,7 +83,6 @@ void OSystem_Win32::init() {
 #if defined(USE_JPEG)
 	initializeJpegLibraryForWin95();
 #endif
-
 	// Invoke parent implementation of this method
 	OSystem_SDL::init();
 }
@@ -505,6 +504,10 @@ AudioCDManager *OSystem_Win32::createAudioCDManager() {
 	return createWin32AudioCDManager();
 }
 
+uint32 OSystem_Win32::getOSDoubleClickTime() const {
+	return GetDoubleClickTime();
+}
+
 // libjpeg-turbo uses SSE instructions that error on at least some Win95 machines.
 // These can be disabled with an environment variable. Fixes bug #13643
 #if defined(USE_JPEG)
diff --git a/backends/platform/sdl/win32/win32.h b/backends/platform/sdl/win32/win32.h
index 4ac05e60464..dd8a4cc0689 100644
--- a/backends/platform/sdl/win32/win32.h
+++ b/backends/platform/sdl/win32/win32.h
@@ -62,6 +62,8 @@ protected:
 
 	HWND getHwnd() { return ((SdlWindow_Win32*)_window)->getHwnd(); }
 
+	uint32 getOSDoubleClickTime() const override;
+
 private:
 	bool _isPortable;
 	bool detectPortableConfigFile();
diff --git a/common/system.h b/common/system.h
index cb25429a7a2..d61177fa9a5 100644
--- a/common/system.h
+++ b/common/system.h
@@ -549,11 +549,6 @@ public:
 		* For platforms that should not have a Quit button.
 		*/
 		kFeatureNoQuit,
-
-		/**
-		* Supports getDoubleClickTime call.
-		*/
-		kFeatureDoubleClickTime,
 	};
 
 	/**
@@ -1396,11 +1391,9 @@ public:
 
 	
 
-	/** Get the system-configured double-click time interval.
-	 *
-	 * Backends which implement this should have the kFeatureDoubleClickTime flag set.
-	 *
-	 * @see kFeatureDoubleClickTime
+	/**
+	 * Get the system-configured double-click time interval.
+	 * If the system doesn't support configuring double-click time, returns 0.
 	 */
 	virtual uint32 getDoubleClickTime() const { return 0; }
 
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index 816f561c68b..31637af9971 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -512,8 +512,7 @@ void EventRecorder::getConfigFromDomain(const Common::ConfigManager::Domain *dom
 }
 
 void EventRecorder::getConfig() {
-	if (g_system->hasFeature(OSystem::kFeatureDoubleClickTime))
-		_recordFile->getHeader().settingsRecords["double_click_time"] = Common::String::format("%u", static_cast<unsigned int>(g_system->getDoubleClickTime()));
+	_recordFile->getHeader().settingsRecords["double_click_time"] = Common::String::format("%u", static_cast<unsigned int>(g_system->getDoubleClickTime()));
 
 	getConfigFromDomain(ConfMan.getDomain(ConfMan.kApplicationDomain));
 	getConfigFromDomain(ConfMan.getActiveDomain());
@@ -690,27 +689,6 @@ Common::SeekableReadStream *EventRecorder::processSaveStream(const Common::Strin
 	}
 }
 
-void EventRecorder::processHaveDoubleClickTime(bool &haveDoubleClickTime) {
-	if (_initialized && (_recordMode == kRecorderPlayback || _recordMode == kRecorderUpdate))
-		haveDoubleClickTime = _playbackFile->getHeader().settingsRecords.contains("double_click_time");
-}
-
-void EventRecorder::processDoubleClickTime(uint32 &doubleClickTime) {
-	if (_initialized && (_recordMode == kRecorderPlayback || _recordMode == kRecorderUpdate)) {
-		const Common::StringMap &settings = _playbackFile->getHeader().settingsRecords;
-		Common::StringMap::const_iterator it = settings.find("double_click_time");
-		if (it == settings.end())
-			doubleClickTime = 0;
-		else {
-			unsigned int temp = 0;
-			if (sscanf(it->_value.c_str(), "%u", &temp))
-				doubleClickTime = temp;
-			else
-				doubleClickTime = 0;
-		}
-	}
-}
-
 Common::SaveFileManager *EventRecorder::getSaveManager(Common::SaveFileManager *realSaveManager) {
 	_realSaveManager = realSaveManager;
 	if (_recordMode != kPassthrough) {
diff --git a/gui/EventRecorder.h b/gui/EventRecorder.h
index acbf5992f7c..9beaea8e9d7 100644
--- a/gui/EventRecorder.h
+++ b/gui/EventRecorder.h
@@ -87,8 +87,6 @@ public:
 	void processGameDescription(const ADGameDescription *desc);
 	bool processAutosave();
 	Common::SeekableReadStream *processSaveStream(const Common::String & fileName);
-	void processHaveDoubleClickTime(bool &haveDoubleClickTime);
-	void processDoubleClickTime(uint32 &doubleClickTime);
 
 	/** Hooks for intercepting into GUI processing, so required events could be shoot
 	 *  or filtered out */


Commit: ee758dee53bbc7b4c42e9800aeafab8446fc074b
    https://github.com/scummvm/scummvm/commit/ee758dee53bbc7b4c42e9800aeafab8446fc074b
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-14T22:42:59+02:00

Commit Message:
BACKENDS: Undo some formatting-only changes.

Changed paths:
    backends/platform/sdl/sdl.cpp
    common/system.h


diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 7ce019e0f4a..776a98ce7a0 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -89,8 +89,7 @@ OSystem_SDL::OSystem_SDL()
 	_logger(nullptr),
 	_eventSource(nullptr),
 	_eventSourceWrapper(nullptr),
-	_window(nullptr)
-{
+	_window(nullptr) {
 }
 
 OSystem_SDL::~OSystem_SDL() {
@@ -189,7 +188,6 @@ bool OSystem_SDL::hasFeature(Feature f) {
 	if (f == kFeatureOpenGLForGame) return true;
 	if (f == kFeatureShadersForGame) return _supportsShaders;
 #endif
-
 	return ModularGraphicsBackend::hasFeature(f);
 }
 
diff --git a/common/system.h b/common/system.h
index d61177fa9a5..bec293b637a 100644
--- a/common/system.h
+++ b/common/system.h
@@ -548,7 +548,7 @@ public:
 		/**
 		* For platforms that should not have a Quit button.
 		*/
-		kFeatureNoQuit,
+		kFeatureNoQuit
 	};
 
 	/**


Commit: 22a21e99cc864194c754f9a9fdc25cb53a106ac2
    https://github.com/scummvm/scummvm/commit/22a21e99cc864194c754f9a9fdc25cb53a106ac2
Author: elasota (ejlasota at gmail.com)
Date: 2023-05-14T22:42:59+02:00

Commit Message:
TESTBED: Add tests for double-click time.

Changed paths:
    engines/testbed/events.cpp
    engines/testbed/events.h


diff --git a/engines/testbed/events.cpp b/engines/testbed/events.cpp
index db193d30fcf..df9bba4848c 100644
--- a/engines/testbed/events.cpp
+++ b/engines/testbed/events.cpp
@@ -264,6 +264,48 @@ TestExitStatus EventTests::mouseEvents() {
 	return passed;
 }
 
+TestExitStatus EventTests::doubleClickTime() {
+	Testsuite::clearScreen();
+
+	uint32 dclickTime = g_system->getDoubleClickTime();
+
+	if (dclickTime == 0) {
+		if (Testsuite::handleInteractiveInput("Double-click time returned 0, meaning it isn't configurable on this operating system.\nIs that correct ?", "Yes", "No", kOptionLeft)) {
+			Testsuite::logDetailedPrintf("Unsupported double-click time check failed");
+			return kTestFailed;
+		}
+	}
+
+	Common::String info = "Testing double click time detection.\n "
+						  "This should report the correct double-click time for the system";
+
+	if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
+		Testsuite::logPrintf("Info! Skipping test : double click time\n");
+		return kTestSkipped;
+	}
+
+	info = Common::String::format("Double-click time was reported as: %u msec\nDoes this seem correct?", static_cast<unsigned int>(dclickTime));
+
+	if (Testsuite::handleInteractiveInput(info, "Yes", "No", kOptionRight)) {
+		Testsuite::logDetailedPrintf("Double-click time failed");
+		return kTestFailed;
+	}
+
+	if (Testsuite::handleInteractiveInput("Do you want to test for detecting configuration changes?\nIf so, change the OS double-click time now, then click 'Yes'", "Yes", "No", kOptionLeft)) {
+		dclickTime = g_system->getDoubleClickTime();
+
+		info = Common::String::format("Double-click time was reported as: %u msec\nDoes this seem correct?", static_cast<unsigned int>(dclickTime));
+
+		if (Testsuite::handleInteractiveInput(info, "Yes", "No", kOptionRight)) {
+			Testsuite::logDetailedPrintf("Double-click time reconfiguration failed");
+			return kTestFailed;
+		}
+	}
+
+
+	return kTestPassed;
+}
+
 TestExitStatus EventTests::kbdEvents() {
 
 	Testsuite::clearScreen();
@@ -330,6 +372,7 @@ TestExitStatus EventTests::showMainMenu() {
 
 EventTestSuite::EventTestSuite() {
 	addTest("MouseEvents", &EventTests::mouseEvents);
+	addTest("DoubleClickTime", &EventTests::doubleClickTime);
 	addTest("KeyboardEvents", &EventTests::kbdEvents);
 	addTest("MainmenuEvent", &EventTests::showMainMenu);
 }
diff --git a/engines/testbed/events.h b/engines/testbed/events.h
index 03629f1902a..50fc0698b2c 100644
--- a/engines/testbed/events.h
+++ b/engines/testbed/events.h
@@ -33,6 +33,7 @@ char keystrokeToChar();
 Common::Rect drawFinishZone();
 // will contain function declarations for Event tests
 TestExitStatus mouseEvents();
+TestExitStatus doubleClickTime();
 TestExitStatus kbdEvents();
 TestExitStatus showMainMenu();
 // add more here




More information about the Scummvm-git-logs mailing list