[Scummvm-git-logs] scummvm master -> 47fc122e08abace2c38147f21add1d7b01096330

spleen1981 noreply at scummvm.org
Mon Sep 25 12:42:54 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:
adb4fda7f8 LIBRETRO: move libretro.cpp to libretro-core and add header file
1071edd59f LIBRETRO: rework paths initialization
7f6d9542e4 LIBRETRO: add retropad exclusive cursor control setting
47fc122e08 LIBRETRO: add default paths logs


Commit: adb4fda7f88b1cf2e4102e1ac9d6ca44d35f4cea
    https://github.com/scummvm/scummvm/commit/adb4fda7f88b1cf2e4102e1ac9d6ca44d35f4cea
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-09-25T14:41:03+02:00

Commit Message:
LIBRETRO: move libretro.cpp to libretro-core and add header file

Changed paths:
  A backends/platform/libretro/include/libretro-core.h
  A backends/platform/libretro/src/libretro-core.cpp
  R backends/platform/libretro/src/libretro.cpp
    backends/platform/libretro/Makefile.common
    backends/platform/libretro/include/libretro-os.h
    backends/platform/libretro/src/libretro-os-base.cpp
    backends/platform/libretro/src/libretro-os-events.cpp
    backends/platform/libretro/src/libretro-os-graphics.cpp
    backends/platform/libretro/src/libretro-os-inputs.cpp
    backends/platform/libretro/src/libretro-os-utils.cpp


diff --git a/backends/platform/libretro/Makefile.common b/backends/platform/libretro/Makefile.common
index ff8d6d0df13..0ac38c13550 100644
--- a/backends/platform/libretro/Makefile.common
+++ b/backends/platform/libretro/Makefile.common
@@ -118,7 +118,7 @@ endif
 INCLUDES     += -I$(ROOT_PATH)/include
 MODULE_PATHS += $(CORE_PATH)
 
-LIBRETRO_OBJS := $(CORE_PATH)/libretro.o \
+LIBRETRO_OBJS := $(CORE_PATH)/libretro-core.o \
 	$(CORE_PATH)/libretro-fs.o \
 	$(CORE_PATH)/libretro-fs-factory.o \
 	$(CORE_PATH)/libretro-os-base.o \
diff --git a/backends/platform/libretro/include/libretro-core.h b/backends/platform/libretro/include/libretro-core.h
new file mode 100644
index 00000000000..cdcf8bade10
--- /dev/null
+++ b/backends/platform/libretro/include/libretro-core.h
@@ -0,0 +1,43 @@
+/* Copyright (C) 2023 Giovanni Cascione <ing.cascione at gmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef LIBRETRO_CORE_H
+#define LIBRETRO_CORE_H
+
+#include <libretro.h>
+
+extern retro_log_printf_t retro_log_cb;
+extern retro_input_state_t retro_input_cb;
+
+bool retro_get_input_bitmask_supported(void);
+void reset_performance_tuner(void);
+void retro_osd_notification(const char* msg);
+int retro_get_input_device(void);
+const char * retro_get_system_dir(void);
+const char * retro_get_save_dir(void);
+
+bool retro_setting_get_timing_inaccuracies_enabled(void);
+float retro_setting_get_frame_rate(void);
+uint16_t retro_setting_get_sample_rate(void);
+int retro_setting_get_analog_deadzone(void);
+bool retro_setting_get_analog_response_is_quadratic(void);
+float retro_setting_get_mouse_speed(void);
+int retro_setting_get_mouse_fine_control_speed_reduction(void);
+float retro_setting_get_gamepad_cursor_speed(void);
+float retro_setting_get_gamepad_acceleration_time(void);
+
+#endif // LIBRETRO_CORE_H
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index c2e486aeb3f..a53b95bb2ea 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -17,10 +17,6 @@
 #ifndef BACKENDS_LIBRETRO_OS_H
 #define BACKENDS_LIBRETRO_OS_H
 
-#include <libretro.h>
-#include <features/features_cpu.h>
-#include <retro_miscellaneous.h>
-
 #include "audio/mixer_intern.h"
 #include "base/main.h"
 #include "backends/base-backend.h"
@@ -40,24 +36,6 @@
 
 #define LIBRETRO_G_SYSTEM dynamic_cast<OSystem_libretro *>(g_system)
 
-/* libretro.cpp functions */
-extern retro_log_printf_t retro_log_cb;
-extern retro_input_state_t retro_input_cb;
-extern bool retro_setting_get_timing_inaccuracies_enabled(void);
-extern float retro_setting_get_frame_rate(void);
-extern uint16 retro_setting_get_sample_rate(void);
-extern int retro_setting_get_analog_deadzone(void);
-extern bool retro_setting_get_analog_response_is_quadratic(void);
-extern float retro_setting_get_mouse_speed(void);
-extern int retro_setting_get_mouse_fine_control_speed_reduction(void);
-extern float retro_setting_get_gamepad_cursor_speed(void);
-extern float retro_setting_get_gamepad_acceleration_time(void);
-extern void reset_performance_tuner(void);
-extern void retro_osd_notification(const char* msg);
-extern int retro_get_input_device(void);
-extern const char * retro_get_system_dir(void);
-extern const char * retro_get_save_dir(void);
-
 /**
  *  Dummy mutex implementation
  */
diff --git a/backends/platform/libretro/src/libretro.cpp b/backends/platform/libretro/src/libretro-core.cpp
similarity index 99%
rename from backends/platform/libretro/src/libretro.cpp
rename to backends/platform/libretro/src/libretro-core.cpp
index e0542c16aa6..ad3f2981845 100644
--- a/backends/platform/libretro/src/libretro.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -1,8 +1,4 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
+/* Copyright (C) 2023 Giovanni Cascione <ing.cascione at gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,7 +17,6 @@
 
 #define FORBIDDEN_SYMBOL_ALLOW_ALL
 
-#include <libretro.h>
 #include "audio/mixer_intern.h"
 #include "base/main.h"
 #include "common/scummsys.h"
@@ -50,10 +45,11 @@
 #define INCLUDED_FROM_BASE_VERSION_CPP
 #include "base/internal_version.h"
 
+#include "backends/platform/libretro/include/libretro-defs.h"
+#include "backends/platform/libretro/include/libretro-core.h"
 #include "backends/platform/libretro/include/libretro-threads.h"
 #include "backends/platform/libretro/include/libretro-core-options.h"
 #include "backends/platform/libretro/include/libretro-os.h"
-#include "backends/platform/libretro/include/libretro-defs.h"
 #include "backends/platform/libretro/include/libretro-mapper.h"
 
 static struct retro_game_info game_buf;
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index 66072898f49..e99d51f7fe7 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -23,15 +23,19 @@
 #define FS_SYSTEM_FACTORY LibRetroFilesystemFactory
 #endif
 
+#include <features/features_cpu.h>
+
 #include "audio/mixer_intern.h"
 #include "backends/base-backend.h"
 #include "common/config-manager.h"
 #include "common/system.h"
 #include "graphics/surface.h"
+
 #include "backends/saves/default/default-saves.h"
+#include "backends/platform/libretro/include/libretro-defs.h"
+#include "backends/platform/libretro/include/libretro-core.h"
 #include "backends/platform/libretro/include/libretro-timer.h"
 #include "backends/platform/libretro/include/libretro-os.h"
-#include "backends/platform/libretro/include/libretro-defs.h"
 
 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();
diff --git a/backends/platform/libretro/src/libretro-os-events.cpp b/backends/platform/libretro/src/libretro-os-events.cpp
index 84950cfa862..1a573a703f6 100644
--- a/backends/platform/libretro/src/libretro-os-events.cpp
+++ b/backends/platform/libretro/src/libretro-os-events.cpp
@@ -20,9 +20,11 @@
 
 #include "common/list.h"
 #include "common/events.h"
+
+#include "backends/platform/libretro/include/libretro-defs.h"
+#include "backends/platform/libretro/include/libretro-core.h"
 #include "backends/platform/libretro/include/libretro-os.h"
 #include "backends/platform/libretro/include/libretro-timer.h"
-#include "backends/platform/libretro/include/libretro-defs.h"
 
 Common::List<Common::Event> OSystem_libretro::_events;
 
diff --git a/backends/platform/libretro/src/libretro-os-graphics.cpp b/backends/platform/libretro/src/libretro-os-graphics.cpp
index 16e76513bf1..79d5d9dc067 100644
--- a/backends/platform/libretro/src/libretro-os-graphics.cpp
+++ b/backends/platform/libretro/src/libretro-os-graphics.cpp
@@ -17,13 +17,14 @@
 
 #include <retro_inline.h>
 
-//#include "common/system.h"
 #include "graphics/colormasks.h"
 #include "graphics/palette.h"
 #include "graphics/surface.h"
+
+#include "backends/platform/libretro/include/libretro-defs.h"
+#include "backends/platform/libretro/include/libretro-core.h"
 #include "backends/platform/libretro/include/libretro-os.h"
 #include "backends/platform/libretro/include/libretro-timer.h"
-#include "backends/platform/libretro/include/libretro-defs.h"
 
 static INLINE void blit_uint8_uint16_fast(Graphics::Surface &aOut, const Graphics::Surface &aIn, const LibretroPalette &aColors) {
 	for (int i = 0; i < aIn.h; i++) {
diff --git a/backends/platform/libretro/src/libretro-os-inputs.cpp b/backends/platform/libretro/src/libretro-os-inputs.cpp
index 76770c82b1a..6d8b068bd37 100644
--- a/backends/platform/libretro/src/libretro-os-inputs.cpp
+++ b/backends/platform/libretro/src/libretro-os-inputs.cpp
@@ -17,10 +17,10 @@
 #define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
 #define FORBIDDEN_SYMBOL_EXCEPTION_strcat
 
-#include <libretro.h>
+#include "backends/platform/libretro/include/libretro-defs.h"
+#include "backends/platform/libretro/include/libretro-core.h"
 #include "backends/platform/libretro/include/libretro-os.h"
 #include "backends/platform/libretro/include/libretro-mapper.h"
-#include "backends/platform/libretro/include/libretro-defs.h"
 
 void OSystem_libretro::updateMouseXY(float deltaAcc, float *cumulativeXYAcc, int doing_x) {
 	int *mouseXY;
diff --git a/backends/platform/libretro/src/libretro-os-utils.cpp b/backends/platform/libretro/src/libretro-os-utils.cpp
index 0bb44b02464..cab26dda62d 100644
--- a/backends/platform/libretro/src/libretro-os-utils.cpp
+++ b/backends/platform/libretro/src/libretro-os-utils.cpp
@@ -17,11 +17,14 @@
 #define FORBIDDEN_SYMBOL_EXCEPTION_time
 
 #include <features/features_cpu.h>
+
 #include "common/tokenizer.h"
 #include "common/config-manager.h"
 #include "base/commandLine.h"
-#include "backends/platform/libretro/include/libretro-os.h"
+
 #include "backends/platform/libretro/include/libretro-defs.h"
+#include "backends/platform/libretro/include/libretro-core.h"
+#include "backends/platform/libretro/include/libretro-os.h"
 
 void OSystem_libretro::getTimeAndDate(TimeDate &t, bool skipRecord) const {
 	uint32 curTime = (uint32) (cpu_features_get_time_usec() / 1000000);


Commit: 1071edd59fa4e47201721a3e44e09b9a4c326e6c
    https://github.com/scummvm/scummvm/commit/1071edd59fa4e47201721a3e44e09b9a4c326e6c
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-09-25T14:41:22+02:00

Commit Message:
LIBRETRO: rework paths initialization

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


diff --git a/backends/platform/libretro/include/libretro-fs.h b/backends/platform/libretro/include/libretro-fs.h
index 2522c254731..dfcacdca90c 100644
--- a/backends/platform/libretro/include/libretro-fs.h
+++ b/backends/platform/libretro/include/libretro-fs.h
@@ -114,6 +114,7 @@ public:
 	virtual Common::SeekableWriteStream *createWriteStream();
 	virtual bool createDirectory();
 
+	static Common::String getHomeDir(void);
 private:
 	/**
 	 * Tests and sets the _isValid and _isDirectory flags, using the stat() function.
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index a53b95bb2ea..9a0133fcd2f 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -78,10 +78,9 @@ private:
 	uint8 _threadSwitchCaller;
 	uint8_t _cursorStatus;
 	Common::String s_systemDir;
-	Common::String s_saveDir;
-	Common::String s_extraDir;
 	Common::String s_themeDir;
-	Common::String s_lastDir;
+	Common::String s_extraDir;
+	Common::String s_saveDir;
 	static Common::List<Common::Event> _events;
 
 public:
@@ -112,8 +111,12 @@ public:
 	void refreshRetroSettings(void);
 	void destroy(void);
 	void quit() override {}
+private:
+	bool checkPath(const char *setting, Common::String path);
+	void initPaths(void);
 
 	/* Graphics */
+public:
 	Common::List<Graphics::PixelFormat> getSupportedFormats() const override;
 	const GraphicsMode *getSupportedGraphicsModes(void) const override;
 	void initSize(uint width, uint height, const Graphics::PixelFormat *format) override;
diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index ad3f2981845..cbc963e977f 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -719,34 +719,19 @@ void retro_get_system_av_info(struct retro_system_av_info *info) {
 }
 
 const char *retro_get_system_dir(void) {
-	const char *sysdir;
-	const char *coredir;
+	const char *sysdir = NULL;
 
-	if (environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &sysdir))
-		return sysdir;
-	else {
-		if (retro_log_cb)
-			retro_log_cb(RETRO_LOG_WARN, "No System directory specified, using current directory.\n");
-		if (! environ_cb(RETRO_ENVIRONMENT_GET_LIBRETRO_PATH, &coredir))
-			coredir = ".";
-		return coredir;
-	}
+	environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &sysdir);
+
+	return sysdir;
 }
 
 const char *retro_get_save_dir(void) {
-	const char *savedir;
-	const char *coredir;
+	const char *savedir = NULL;
 
+	environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &savedir);
 
-	if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &savedir))
-		return savedir;
-	else {
-		if (retro_log_cb)
-			retro_log_cb(RETRO_LOG_WARN, "No Save directory specified, using current directory.\n");
-		if (! environ_cb(RETRO_ENVIRONMENT_GET_LIBRETRO_PATH, &coredir))
-			coredir = ".";
-		return coredir;
-	}
+	return savedir;
 }
 
 void retro_init(void) {
diff --git a/backends/platform/libretro/src/libretro-fs.cpp b/backends/platform/libretro/src/libretro-fs.cpp
index d11f0e89a90..3be686ee5e2 100644
--- a/backends/platform/libretro/src/libretro-fs.cpp
+++ b/backends/platform/libretro/src/libretro-fs.cpp
@@ -25,6 +25,7 @@
 #define FORBIDDEN_SYMBOL_EXCEPTION_unistd_h
 #define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
 #define FORBIDDEN_SYMBOL_EXCEPTION_getenv
+#define FORBIDDEN_SYMBOL_EXCEPTION_strcat
 #define FORBIDDEN_SYMBOL_EXCEPTION_exit // Needed for IRIX's unistd.h
 
 #include <file/file_path.h>
@@ -48,21 +49,23 @@ 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("~/")) {
-		const char *home = getenv("HOME");
-		if (home != NULL && strlen(home) < MAXPATHLEN) {
-			_path = home;
-			// Skip over the tilda.  We know that p contains at least
-			// two chars, so this is safe:
-			_path += p.c_str() + 1;
-		}
-	} else {
-		_path = p;
+		Common::String homeDir = getHomeDir();
+		if (homeDir.empty())
+			homeDir = ".";
+
+		// Skip over the tilda.  We know that p contains at least
+		// two chars, so this is safe:
+		_path = homeDir + (p.c_str() + 1);
+
 	}
 
 	// Normalize the path (that is, remove unneeded slashes etc.)
-	_path = Common::normalizePath(_path, '/');
+	_path = Common::normalizePath(expanded_path, '/');
 	_displayName = Common::lastPathComponent(_path, '/');
 
 	setFlags();
@@ -226,3 +229,19 @@ bool assureDirectoryExists(const Common::String &dir, const char *prefix) {
 }
 
 } // End of namespace Posix
+
+Common::String LibRetroFilesystemNode::getHomeDir(void) {
+	Common::String path;
+#if defined(__WIN32)
+	const char *c_homeDriveDir = getenv("HOMEDRIVE");
+	const char *c_homePathDir = getenv("HOMEPATH");
+	char c_homeDir[strlen(c_homeDriveDir) + strlen(c_homePathDir) + 1] = {0};
+	strcat(strcat(c_homeDir, c_homeDriveDir), c_homePathDir);
+#else
+	const char *c_homeDir = getenv("HOME");
+#endif
+	if (c_homeDir && *c_homeDir)
+		path = c_homeDir;
+
+	return path;
+}
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index e99d51f7fe7..bbb4d0d0e2d 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -24,6 +24,8 @@
 #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"
@@ -36,16 +38,30 @@
 #include "backends/platform/libretro/include/libretro-core.h"
 #include "backends/platform/libretro/include/libretro-timer.h"
 #include "backends/platform/libretro/include/libretro-os.h"
+#include "backends/platform/libretro/include/libretro-fs.h"
 
 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();
-	memset(_mouseButtons, 0, sizeof(_mouseButtons));
 
-	s_systemDir = Common::String(retro_get_system_dir());
-	s_saveDir = Common::String(retro_get_save_dir());
-	s_themeDir = s_systemDir + "/" + SCUMMVM_SYSTEM_SUBDIR + "/" + SCUMMVM_THEME_SUBDIR;
-	s_extraDir = s_systemDir + "/" + SCUMMVM_SYSTEM_SUBDIR + "/" + SCUMMVM_EXTRA_SUBDIR;
-	s_lastDir = s_systemDir;
+	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;
+	}
+
+	const char *c_saveDir = retro_get_save_dir();
+	if (path_is_directory(c_saveDir))
+		s_saveDir = c_saveDir;
+
+	memset(_mouseButtons, 0, sizeof(_mouseButtons));
 
 	_startTime = (uint32)(cpu_features_get_time_usec() / 1000);
 }
@@ -60,25 +76,26 @@ OSystem_libretro::~OSystem_libretro() {
 }
 
 void OSystem_libretro::initBackend() {
-
-	_savefileManager = new DefaultSaveFileManager(s_saveDir);
-
-	if (! ConfMan.hasKey("themepath")) {
-		if (! Common::FSNode(s_themeDir).exists())
-			retro_osd_notification("ScummVM theme folder not found.");
-		else
-			ConfMan.set("themepath", s_themeDir);
-	}
-
-	if (! ConfMan.hasKey("extrapath")) {
-		if (! Common::FSNode(s_extraDir).exists())
-			retro_osd_notification("ScummVM datafiles folder not found. Some engines/features will not work.");
-		else
-			ConfMan.set("extrapath", s_extraDir);
-	}
-
-	if (! ConfMan.hasKey("browser_lastpath"))
-		ConfMan.set("browser_lastpath", s_lastDir);
+	Common::String s_homeDir = LibRetroFilesystemNode::getHomeDir();
+	if ((s_homeDir.empty() || ! path_is_directory(s_homeDir.c_str())) && !s_systemDir.empty())
+		s_homeDir = s_systemDir;
+
+	//Register default paths
+	if (! s_homeDir.empty())
+		ConfMan.registerDefault("browser_lastpath", s_homeDir);
+	if (! s_saveDir.empty())
+		ConfMan.registerDefault("savepath", s_saveDir);
+
+	//Check current paths
+	if (!checkPath("savepath", s_saveDir))
+		retro_osd_notification("ScummVM save folder not found.");
+	if (!checkPath("themepath", s_themeDir))
+		retro_osd_notification("ScummVM theme folder not found.");
+	if (!checkPath("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);
+
+	_savefileManager = new DefaultSaveFileManager();
 
 #ifdef FRONTEND_SUPPORTS_RGB565
 	_overlay.create(RES_W_OVERLAY, RES_H_OVERLAY, Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0));
@@ -86,7 +103,7 @@ void OSystem_libretro::initBackend() {
 	_overlay.create(RES_W_OVERLAY, RES_H_OVERLAY, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
 #endif
 	_mixer = new Audio::MixerImpl(retro_setting_get_sample_rate());
-	retro_log_cb(RETRO_LOG_DEBUG,"Mixer set up at %dHz\n", retro_setting_get_sample_rate());
+	retro_log_cb(RETRO_LOG_DEBUG, "Mixer set up at %dHz\n", retro_setting_get_sample_rate());
 
 	_timerManager = new LibretroTimerManager(retro_setting_get_frame_rate());
 
@@ -123,14 +140,25 @@ bool OSystem_libretro::getFeatureState(Feature f) {
 }
 
 Audio::Mixer *OSystem_libretro::getMixer() {
-        return _mixer;
+	return _mixer;
 }
 
 void OSystem_libretro::refreshRetroSettings() {
-        _adjusted_cursor_speed = (float)BASE_CURSOR_SPEED * retro_setting_get_gamepad_cursor_speed() * (float)(_overlayInGUI ? _overlay.w : _gameScreen.w) / 320.0f; // Dpad cursor speed should always be based off a 320 wide screen, to keep speeds consistent;
-        _inverse_acceleration_time = (retro_setting_get_gamepad_acceleration_time() > 0.0) ? (1.0f / (float)retro_setting_get_frame_rate()) * (1.0f / retro_setting_get_gamepad_acceleration_time()) : 1.0f;
+	_adjusted_cursor_speed = (float)BASE_CURSOR_SPEED * retro_setting_get_gamepad_cursor_speed() * (float)(_overlayInGUI ? _overlay.w : _gameScreen.w) / 320.0f; // Dpad cursor speed should always be based off a 320 wide screen, to keep speeds consistent;
+	_inverse_acceleration_time = (retro_setting_get_gamepad_acceleration_time() > 0.0) ? (1.0f / (float)retro_setting_get_frame_rate()) * (1.0f / retro_setting_get_gamepad_acceleration_time()) : 1.0f;
 }
 
 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()))
+		ConfMan.removeKey(setting, Common::ConfigManager::kApplicationDomain);
+	if (! ConfMan.hasKey(setting))
+		if (path.empty())
+			return false;
+		else
+			ConfMan.set(setting, path);
+	return true;
+}
diff --git a/backends/platform/libretro/src/libretro-os-utils.cpp b/backends/platform/libretro/src/libretro-os-utils.cpp
index cab26dda62d..254f2411308 100644
--- a/backends/platform/libretro/src/libretro-os-utils.cpp
+++ b/backends/platform/libretro/src/libretro-os-utils.cpp
@@ -27,7 +27,7 @@
 #include "backends/platform/libretro/include/libretro-os.h"
 
 void OSystem_libretro::getTimeAndDate(TimeDate &t, bool skipRecord) const {
-	uint32 curTime = (uint32) (cpu_features_get_time_usec() / 1000000);
+	uint32 curTime = (uint32)(cpu_features_get_time_usec() / 1000000);
 
 #define YEAR0 1900
 #define EPOCH_YR 1970
@@ -56,21 +56,24 @@ void OSystem_libretro::getTimeAndDate(TimeDate &t, bool skipRecord) const {
 }
 
 Common::String OSystem_libretro::getDefaultConfigFileName() {
-	return s_systemDir + "/scummvm.ini";
+	if (s_systemDir.empty())
+		return Common::String("scummvm.ini");
+	else
+		return s_systemDir + "/scummvm.ini";
 }
 
 void OSystem_libretro::logMessage(LogMessageType::Type type, const char *message) {
 	retro_log_level loglevel = RETRO_LOG_INFO;
 	switch (type) {
-		case LogMessageType::kDebug:
-			loglevel = RETRO_LOG_DEBUG;
-			break;
-		case LogMessageType::kWarning:
-			loglevel = RETRO_LOG_WARN;
-			break;
-		case LogMessageType::kError:
-			loglevel = RETRO_LOG_ERROR;
-			break;
+	case LogMessageType::kDebug:
+		loglevel = RETRO_LOG_DEBUG;
+		break;
+	case LogMessageType::kWarning:
+		loglevel = RETRO_LOG_WARN;
+		break;
+	case LogMessageType::kError:
+		loglevel = RETRO_LOG_ERROR;
+		break;
 	}
 
 	if (retro_log_cb)
@@ -79,7 +82,7 @@ void OSystem_libretro::logMessage(LogMessageType::Type type, const char *message
 
 
 bool OSystem_libretro::parseGameName(const Common::String &gameName, Common::String &engineId,
-				   Common::String &gameId) {
+                                     Common::String &gameId) {
 	Common::StringTokenizer tokenizer(gameName, ":");
 	Common::String token1, token2;
 


Commit: 7f6d9542e4f2665a84b2988dbe41592c2ef396ba
    https://github.com/scummvm/scummvm/commit/7f6d9542e4f2665a84b2988dbe41592c2ef396ba
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-09-25T14:42:06+02:00

Commit Message:
LIBRETRO: add retropad exclusive cursor control setting

Changed paths:
    backends/platform/libretro/include/libretro-core-options-intl.h
    backends/platform/libretro/include/libretro-core-options.h
    backends/platform/libretro/include/libretro-core.h
    backends/platform/libretro/src/libretro-core.cpp
    backends/platform/libretro/src/libretro-os-inputs.cpp


diff --git a/backends/platform/libretro/include/libretro-core-options-intl.h b/backends/platform/libretro/include/libretro-core-options-intl.h
index ef0c6d02d70..9dceb8d5c87 100644
--- a/backends/platform/libretro/include/libretro-core-options-intl.h
+++ b/backends/platform/libretro/include/libretro-core-options-intl.h
@@ -72,7 +72,7 @@ extern "C" {
 struct retro_core_option_v2_category option_cats_it[] = {
 	{
 		"cursor",
-		"Movimento del cursore",
+		"Cursore",
 		"Impostazioni relative al movimento del cursore"
 	},
 	{
@@ -94,6 +94,20 @@ struct retro_core_option_v2_category option_cats_it[] = {
 };
 
 struct retro_core_option_v2_definition option_defs_it[] = {
+	{
+		"scummvm_gamepad_cursor_only",
+		"Cursore > Controllo esclusivo del cursore con RetroPad",
+		"Controllo esclusivo del cursore con RetroPad",
+		"Consente di usare solo RetroPad per il controllo del cursore del mouse, escludento gli altri input (es. mouse fisico, touch screen).",
+		NULL,
+		"cursor",
+		{
+			{"disabled", NULL},
+			{"enabled", NULL},
+			{NULL, NULL},
+		},
+		"disabled"
+	},
 	{
 		"scummvm_gamepad_cursor_speed",
 		"Cursore > Velocità del cursore",
diff --git a/backends/platform/libretro/include/libretro-core-options.h b/backends/platform/libretro/include/libretro-core-options.h
index 6321fdc37f9..c4b22b3bbee 100644
--- a/backends/platform/libretro/include/libretro-core-options.h
+++ b/backends/platform/libretro/include/libretro-core-options.h
@@ -96,6 +96,20 @@ struct retro_core_option_v2_category option_cats_us[] = {
 };
 
 struct retro_core_option_v2_definition option_defs_us[] = {
+	{
+		"scummvm_gamepad_cursor_only",
+		"Cursor > Exclusive cursor control with RetroPad",
+		"Exclusive cursor control with RetroPad",
+		"Allows the use of RetroPad only to control mouse cursor, excluding the other inputs (e.g. physical mouse, touch screen).",
+		NULL,
+		"cursor",
+		{
+			{"disabled", NULL},
+			{"enabled", NULL},
+			{NULL, NULL},
+		},
+		"disabled"
+	},
 	{
 		"scummvm_gamepad_cursor_speed",
 		"Cursor > Gamepad Cursor Speed",
diff --git a/backends/platform/libretro/include/libretro-core.h b/backends/platform/libretro/include/libretro-core.h
index cdcf8bade10..41c51c1651a 100644
--- a/backends/platform/libretro/include/libretro-core.h
+++ b/backends/platform/libretro/include/libretro-core.h
@@ -37,6 +37,7 @@ int retro_setting_get_analog_deadzone(void);
 bool retro_setting_get_analog_response_is_quadratic(void);
 float retro_setting_get_mouse_speed(void);
 int retro_setting_get_mouse_fine_control_speed_reduction(void);
+bool retro_setting_get_gamepad_cursor_only(void);
 float retro_setting_get_gamepad_cursor_speed(void);
 float retro_setting_get_gamepad_acceleration_time(void);
 
diff --git a/backends/platform/libretro/src/libretro-core.cpp b/backends/platform/libretro/src/libretro-core.cpp
index cbc963e977f..950d657099e 100644
--- a/backends/platform/libretro/src/libretro-core.cpp
+++ b/backends/platform/libretro/src/libretro-core.cpp
@@ -68,6 +68,7 @@ static int analog_deadzone = (int)(0.15f * ANALOG_RANGE);
 
 static float gamepad_cursor_speed = 1.0f;
 static bool analog_response_is_quadratic = false;
+static bool gamepad_cursor_only = false;
 
 static float mouse_speed = 1.0f;
 static float gamepad_acceleration_time = 0.2f;
@@ -193,6 +194,14 @@ static void update_variables(void) {
 	updating_variables = true;
 	const char *osd_msg = "";
 
+	var.key = "scummvm_gamepad_cursor_only";
+	var.value = NULL;
+	gamepad_cursor_only = false;
+	if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) {
+		if (strcmp(var.value, "enabled") == 0)
+			gamepad_cursor_only = true;
+	}
+
 	var.key = "scummvm_gamepad_cursor_speed";
 	var.value = NULL;
 	gamepad_cursor_speed = 1.0f;
@@ -511,6 +520,10 @@ bool retro_setting_get_timing_inaccuracies_enabled() {
 		return timing_inaccuracies_enabled;
 }
 
+bool retro_setting_get_gamepad_cursor_only(void) {
+	return gamepad_cursor_only;
+}
+
 int retro_setting_get_analog_deadzone(void) {
 	return analog_deadzone;
 }
diff --git a/backends/platform/libretro/src/libretro-os-inputs.cpp b/backends/platform/libretro/src/libretro-os-inputs.cpp
index 6d8b068bd37..0b4e0fd1566 100644
--- a/backends/platform/libretro/src/libretro-os-inputs.cpp
+++ b/backends/platform/libretro/src/libretro-os-inputs.cpp
@@ -207,6 +207,9 @@ void OSystem_libretro::processInputs(void) {
 		}
 	}
 
+	if (retro_setting_get_gamepad_cursor_only())
+		return;
+
 #if defined(WIIU) || defined(__SWITCH__)
 	int p_x = retro_input_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
 	int p_y = retro_input_cb(0, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);


Commit: 47fc122e08abace2c38147f21add1d7b01096330
    https://github.com/scummvm/scummvm/commit/47fc122e08abace2c38147f21add1d7b01096330
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-09-25T14:42:30+02:00

Commit Message:
LIBRETRO: add default paths logs

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


diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index bbb4d0d0e2d..6cd61f8e6d9 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -81,10 +81,14 @@ void OSystem_libretro::initBackend() {
 		s_homeDir = s_systemDir;
 
 	//Register default paths
-	if (! s_homeDir.empty())
+	if (! s_homeDir.empty()) {
 		ConfMan.registerDefault("browser_lastpath", s_homeDir);
-	if (! s_saveDir.empty())
+		retro_log_cb(RETRO_LOG_DEBUG, "Default browser last path set to: %s\n", s_homeDir.c_str());
+	}
+	if (! s_saveDir.empty()) {
 		ConfMan.registerDefault("savepath", s_saveDir);
+		retro_log_cb(RETRO_LOG_DEBUG, "Default save path set to: %s\n", s_saveDir.c_str());
+	}
 
 	//Check current paths
 	if (!checkPath("savepath", s_saveDir))




More information about the Scummvm-git-logs mailing list