[Scummvm-git-logs] scummvm master -> 0f6773217c670368de73348e201495cc4456023f

spleen1981 noreply at scummvm.org
Thu Sep 28 19:25:56 UTC 2023


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

Summary:
76ff21ba4e LIBRETRO: add backslash case for HOME expansion
1c8092f592 LIBRETRO: force slashes in LibRetroFilesystemNode constructor
74dd0af052 LIBRETRO: change path tests to LibRetroFilesystemNode
0f6773217c LIBRETRO: add automatic setup of default soundfont file


Commit: 76ff21ba4ef6b3a518e8833d39f88f60b72cf243
    https://github.com/scummvm/scummvm/commit/76ff21ba4ef6b3a518e8833d39f88f60b72cf243
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-09-28T21:24:48+02:00

Commit Message:
LIBRETRO: add backslash case for HOME expansion

Changed paths:
    backends/platform/libretro/src/libretro-fs.cpp


diff --git a/backends/platform/libretro/src/libretro-fs.cpp b/backends/platform/libretro/src/libretro-fs.cpp
index 3be686ee5e2..8fc048e0a5f 100644
--- a/backends/platform/libretro/src/libretro-fs.cpp
+++ b/backends/platform/libretro/src/libretro-fs.cpp
@@ -49,11 +49,8 @@ void LibRetroFilesystemNode::setFlags() {
 LibRetroFilesystemNode::LibRetroFilesystemNode(const Common::String &p) {
 	assert(p.size() > 0);
 
-	char expanded_path[MAXPATHLEN];
-	fill_pathname_expand_special(expanded_path, p.c_str(), MAXPATHLEN);
-
 	// Expand "~/" to the value of the HOME env variable
-	if (p.hasPrefix("~/")) {
+	if (p.hasPrefix("~/") || p.hasPrefix("~\\")) {
 		Common::String homeDir = getHomeDir();
 		if (homeDir.empty())
 			homeDir = ".";
@@ -62,7 +59,8 @@ LibRetroFilesystemNode::LibRetroFilesystemNode(const Common::String &p) {
 		// two chars, so this is safe:
 		_path = homeDir + (p.c_str() + 1);
 
-	}
+	} else
+		_path = p;
 
 	// Normalize the path (that is, remove unneeded slashes etc.)
 	_path = Common::normalizePath(expanded_path, '/');


Commit: 1c8092f5926be8b76ddfa0161998ecac72903551
    https://github.com/scummvm/scummvm/commit/1c8092f5926be8b76ddfa0161998ecac72903551
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-09-28T21:25:04+02:00

Commit Message:
LIBRETRO: force slashes in LibRetroFilesystemNode constructor

Changed paths:
    backends/platform/libretro/src/libretro-fs.cpp


diff --git a/backends/platform/libretro/src/libretro-fs.cpp b/backends/platform/libretro/src/libretro-fs.cpp
index 8fc048e0a5f..14747f99954 100644
--- a/backends/platform/libretro/src/libretro-fs.cpp
+++ b/backends/platform/libretro/src/libretro-fs.cpp
@@ -26,6 +26,7 @@
 #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
 #define FORBIDDEN_SYMBOL_EXCEPTION_getenv
 #define FORBIDDEN_SYMBOL_EXCEPTION_strcat
+#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
 #define FORBIDDEN_SYMBOL_EXCEPTION_exit // Needed for IRIX's unistd.h
 
 #include <file/file_path.h>
@@ -62,8 +63,12 @@ LibRetroFilesystemNode::LibRetroFilesystemNode(const Common::String &p) {
 	} else
 		_path = p;
 
+	char portable_path[_path.size()+1];
+	strcpy(portable_path,_path.c_str());
+	pathname_make_slashes_portable(portable_path);
+
 	// Normalize the path (that is, remove unneeded slashes etc.)
-	_path = Common::normalizePath(expanded_path, '/');
+	_path = Common::normalizePath(Common::String(portable_path), '/');
 	_displayName = Common::lastPathComponent(_path, '/');
 
 	setFlags();


Commit: 74dd0af052fe8f0933fa1fc7dbf51b3a0c8574c8
    https://github.com/scummvm/scummvm/commit/74dd0af052fe8f0933fa1fc7dbf51b3a0c8574c8
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-09-28T21:25:21+02:00

Commit Message:
LIBRETRO: change path tests to LibRetroFilesystemNode

Changed paths:
    backends/platform/libretro/include/libretro-os.h
    backends/platform/libretro/src/libretro-os-base.cpp


diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index 9a0133fcd2f..5c9bca80f5f 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -78,8 +78,6 @@ private:
 	uint8 _threadSwitchCaller;
 	uint8_t _cursorStatus;
 	Common::String s_systemDir;
-	Common::String s_themeDir;
-	Common::String s_extraDir;
 	Common::String s_saveDir;
 	static Common::List<Common::Event> _events;
 
@@ -112,8 +110,7 @@ public:
 	void destroy(void);
 	void quit() override {}
 private:
-	bool checkPath(const char *setting, Common::String path);
-	void initPaths(void);
+	bool checkPathSetting(const char *setting, Common::String const &defaultPath);
 
 	/* Graphics */
 public:
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index 6cd61f8e6d9..841f716611e 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -24,8 +24,6 @@
 #endif
 
 #include <features/features_cpu.h>
-#include <file/file_path.h>
-#include <retro_miscellaneous.h>
 
 #include "audio/mixer_intern.h"
 #include "backends/base-backend.h"
@@ -43,23 +41,13 @@
 OSystem_libretro::OSystem_libretro() : _mousePaletteEnabled(false), _mouseVisible(false), _mouseX(0), _mouseY(0), _mouseXAcc(0.0), _mouseYAcc(0.0), _mouseHotspotX(0), _mouseHotspotY(0), _dpadXAcc(0.0), _dpadYAcc(0.0), _dpadXVel(0.0f), _dpadYVel(0.0f), _mouseKeyColor(0), _mouseDontScale(false), _mixer(0), _startTime(0), _threadSwitchCaller(0), _cursorStatus(0) {
 	_fsFactory = new FS_SYSTEM_FACTORY();
 
-	const char *c_systemDir = retro_get_system_dir();
-	if (path_is_directory(c_systemDir)) {
-		s_systemDir = c_systemDir;
-		char c_themeDir[PATH_MAX_LENGTH];
-		fill_pathname_join_special(c_themeDir, c_systemDir, SCUMMVM_SYSTEM_SUBDIR "/" SCUMMVM_THEME_SUBDIR, PATH_MAX_LENGTH);
-		if (path_is_directory(c_themeDir))
-			s_themeDir = c_themeDir;
-
-		char c_extraDir[PATH_MAX_LENGTH];
-		fill_pathname_join_special(c_extraDir, c_systemDir, SCUMMVM_SYSTEM_SUBDIR "/" SCUMMVM_EXTRA_SUBDIR, PATH_MAX_LENGTH);
-		if (path_is_directory(c_extraDir))
-			s_extraDir = c_extraDir;
-	}
+	s_systemDir = retro_get_system_dir();
+	if (s_systemDir.empty() || ! LibRetroFilesystemNode(s_systemDir).isDirectory())
+		s_systemDir.clear();
 
-	const char *c_saveDir = retro_get_save_dir();
-	if (path_is_directory(c_saveDir))
-		s_saveDir = c_saveDir;
+	s_saveDir = retro_get_save_dir();
+	if (s_saveDir.empty() || ! LibRetroFilesystemNode(s_saveDir).isDirectory())
+		s_saveDir.clear();
 
 	memset(_mouseButtons, 0, sizeof(_mouseButtons));
 
@@ -76,8 +64,15 @@ OSystem_libretro::~OSystem_libretro() {
 }
 
 void OSystem_libretro::initBackend() {
-	Common::String s_homeDir = LibRetroFilesystemNode::getHomeDir();
-	if ((s_homeDir.empty() || ! path_is_directory(s_homeDir.c_str())) && !s_systemDir.empty())
+	Common::String s_homeDir(LibRetroFilesystemNode::getHomeDir());
+	Common::String s_themeDir(s_systemDir + "/" + SCUMMVM_SYSTEM_SUBDIR + "/" + SCUMMVM_THEME_SUBDIR);
+	Common::String s_extraDir(s_systemDir + "/" + SCUMMVM_SYSTEM_SUBDIR + "/" + SCUMMVM_EXTRA_SUBDIR);
+
+	if (! LibRetroFilesystemNode(s_themeDir).isDirectory())
+		s_themeDir.clear();
+	if (! LibRetroFilesystemNode(s_extraDir).isDirectory())
+		s_extraDir.clear();
+	if ((s_homeDir.empty() || ! LibRetroFilesystemNode(s_homeDir).isDirectory()) && ! s_systemDir.empty())
 		s_homeDir = s_systemDir;
 
 	//Register default paths
@@ -91,13 +86,13 @@ void OSystem_libretro::initBackend() {
 	}
 
 	//Check current paths
-	if (!checkPath("savepath", s_saveDir))
+	if (!checkPathSetting("savepath", s_saveDir))
 		retro_osd_notification("ScummVM save folder not found.");
-	if (!checkPath("themepath", s_themeDir))
+	if (!checkPathSetting("themepath", s_themeDir))
 		retro_osd_notification("ScummVM theme folder not found.");
-	if (!checkPath("extrapath", s_extraDir))
+	if (!checkPathSetting("extrapath", s_extraDir))
 		retro_osd_notification("ScummVM extra folder not found. Some engines/features (e.g. Virtual Keyboard) will not work without relevant datafiles.");
-	checkPath("browser_lastpath", s_homeDir);
+	checkPathSetting("browser_lastpath", s_homeDir);
 
 	_savefileManager = new DefaultSaveFileManager();
 
@@ -156,13 +151,14 @@ void OSystem_libretro::destroy() {
 	delete this;
 }
 
-bool OSystem_libretro::checkPath(const char *setting, Common::String path) {
-	if (ConfMan.get(setting).empty() || ! path_is_directory(ConfMan.get(setting).c_str()))
+bool OSystem_libretro::checkPathSetting(const char *setting, Common::String const &defaultPath) {
+	Common::String setPath(ConfMan.get(setting));
+	if (setPath.empty() || ! LibRetroFilesystemNode(setPath).isDirectory())
 		ConfMan.removeKey(setting, Common::ConfigManager::kApplicationDomain);
 	if (! ConfMan.hasKey(setting))
-		if (path.empty())
+		if (defaultPath.empty())
 			return false;
 		else
-			ConfMan.set(setting, path);
+			ConfMan.set(setting, defaultPath);
 	return true;
 }


Commit: 0f6773217c670368de73348e201495cc4456023f
    https://github.com/scummvm/scummvm/commit/0f6773217c670368de73348e201495cc4456023f
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-09-28T21:25:36+02:00

Commit Message:
LIBRETRO: add automatic setup of default soundfont file

Changed paths:
    backends/platform/libretro/include/libretro-defs.h
    backends/platform/libretro/include/libretro-os.h
    backends/platform/libretro/src/libretro-os-base.cpp


diff --git a/backends/platform/libretro/include/libretro-defs.h b/backends/platform/libretro/include/libretro-defs.h
index bdbfdcd1868..c33f7b8c375 100644
--- a/backends/platform/libretro/include/libretro-defs.h
+++ b/backends/platform/libretro/include/libretro-defs.h
@@ -21,9 +21,10 @@
 // System analog stick range is -0x8000 to 0x8000
 #define ANALOG_RANGE 0x8000
 
-#define DEFAULT_SAMPLE_RATE     48000
-#define DEFAULT_REFRESH_RATE    60
-#define FRAMESKIP_MAX           DEFAULT_REFRESH_RATE / 2
+#define DEFAULT_SAMPLE_RATE     	48000
+#define DEFAULT_REFRESH_RATE    	60
+#define FRAMESKIP_MAX           	DEFAULT_REFRESH_RATE / 2
+#define DEFAULT_SOUNDFONT_FILENAME	"Roland_SC-55.sf2"
 
 // Audio status
 #define AUDIO_STATUS_MUTE               (1 << 0)
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index 5c9bca80f5f..59a4bed88d3 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -110,7 +110,7 @@ public:
 	void destroy(void);
 	void quit() override {}
 private:
-	bool checkPathSetting(const char *setting, Common::String const &defaultPath);
+	bool checkPathSetting(const char *setting, Common::String const &defaultPath, bool isDirectory = true);
 
 	/* Graphics */
 public:
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index 841f716611e..bbc20de335e 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -67,11 +67,14 @@ void OSystem_libretro::initBackend() {
 	Common::String s_homeDir(LibRetroFilesystemNode::getHomeDir());
 	Common::String s_themeDir(s_systemDir + "/" + SCUMMVM_SYSTEM_SUBDIR + "/" + SCUMMVM_THEME_SUBDIR);
 	Common::String s_extraDir(s_systemDir + "/" + SCUMMVM_SYSTEM_SUBDIR + "/" + SCUMMVM_EXTRA_SUBDIR);
+	Common::String s_soundfontPath(s_extraDir + "/" + DEFAULT_SOUNDFONT_FILENAME);
 
 	if (! LibRetroFilesystemNode(s_themeDir).isDirectory())
 		s_themeDir.clear();
 	if (! LibRetroFilesystemNode(s_extraDir).isDirectory())
 		s_extraDir.clear();
+	if (! LibRetroFilesystemNode(s_soundfontPath).exists())
+		s_soundfontPath.clear();
 	if ((s_homeDir.empty() || ! LibRetroFilesystemNode(s_homeDir).isDirectory()) && ! s_systemDir.empty())
 		s_homeDir = s_systemDir;
 
@@ -92,6 +95,7 @@ void OSystem_libretro::initBackend() {
 		retro_osd_notification("ScummVM theme folder not found.");
 	if (!checkPathSetting("extrapath", s_extraDir))
 		retro_osd_notification("ScummVM extra folder not found. Some engines/features (e.g. Virtual Keyboard) will not work without relevant datafiles.");
+	checkPathSetting("soundfont", s_soundfontPath, false);
 	checkPathSetting("browser_lastpath", s_homeDir);
 
 	_savefileManager = new DefaultSaveFileManager();
@@ -151,9 +155,10 @@ void OSystem_libretro::destroy() {
 	delete this;
 }
 
-bool OSystem_libretro::checkPathSetting(const char *setting, Common::String const &defaultPath) {
+bool OSystem_libretro::checkPathSetting(const char *setting, Common::String const &defaultPath, bool isDirectory) {
 	Common::String setPath(ConfMan.get(setting));
-	if (setPath.empty() || ! LibRetroFilesystemNode(setPath).isDirectory())
+
+	if (setPath.empty() || ! (isDirectory ? LibRetroFilesystemNode(setPath).isDirectory() : LibRetroFilesystemNode(setPath).exists()))
 		ConfMan.removeKey(setting, Common::ConfigManager::kApplicationDomain);
 	if (! ConfMan.hasKey(setting))
 		if (defaultPath.empty())




More information about the Scummvm-git-logs mailing list