[Scummvm-git-logs] scummvm master -> 754d4b4c0c828902e874eb389df3ceed239b9a3b

chkuendig noreply at scummvm.org
Sun Aug 3 20:52:28 UTC 2025


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

Summary:
0c039741e5 BACKENDS: SDL: Fix SDLPlugin for SDL3
2b0bc6045d BACKENDS: SDL: Fix touch events for SDL3
754d4b4c0c EMSCRIPTEN: Add Emscripten backend to configure and setup SDL3 manually


Commit: 0c039741e549d27e7726fdf5a858133f03c9b343
    https://github.com/scummvm/scummvm/commit/0c039741e549d27e7726fdf5a858133f03c9b343
Author: Christian Kündig (christian at kuendig.info)
Date: 2025-08-03T22:52:23+02:00

Commit Message:
BACKENDS: SDL: Fix SDLPlugin for SDL3

Changed paths:
    backends/plugins/sdl/sdl-provider.cpp


diff --git a/backends/plugins/sdl/sdl-provider.cpp b/backends/plugins/sdl/sdl-provider.cpp
index ad1da0091aa..780592262c3 100644
--- a/backends/plugins/sdl/sdl-provider.cpp
+++ b/backends/plugins/sdl/sdl-provider.cpp
@@ -32,10 +32,19 @@
 
 class SDLPlugin : public DynamicPlugin {
 protected:
+#if SDL_VERSION_ATLEAST(3, 0, 0)
+	SDL_SharedObject *_dlHandle;
+#else
 	void *_dlHandle;
+#endif
 
 	virtual VoidFunc findSymbol(const char *symbol) {
-		void *func = SDL_LoadFunction(_dlHandle, symbol);
+#if SDL_VERSION_ATLEAST(3, 0, 0)
+		SDL_FunctionPointer func;
+#else
+		void *func ;
+#endif
+		func = SDL_LoadFunction(_dlHandle, symbol);
 		if (!func)
 			warning("Failed loading symbol '%s' from plugin '%s' (%s)", symbol, _filename.toString(Common::Path::kNativeSeparator).c_str(), SDL_GetError());
 


Commit: 2b0bc6045d35fa1993880d21b875f8991a9a11dc
    https://github.com/scummvm/scummvm/commit/2b0bc6045d35fa1993880d21b875f8991a9a11dc
Author: Christian Kündig (christian at kuendig.info)
Date: 2025-08-03T22:52:23+02:00

Commit Message:
BACKENDS: SDL: Fix touch events for SDL3

- SDL_FingerID is now uint64 and 0 is defined as an invalid ID
- Timestamps are now based on nanoseconds and have to be converted to ms

Changed paths:
    backends/events/sdl/sdl-events.h
    backends/events/sdl/sdl3-events.cpp


diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
index 02b548ee9de..695ec1a909f 100644
--- a/backends/events/sdl/sdl-events.h
+++ b/backends/events/sdl/sdl-events.h
@@ -236,7 +236,11 @@ protected:
 	};
 
 	struct TouchFinger {
+#if SDL_VERSION_ATLEAST(3, 0, 0)
+		SDL_FingerID id = 0; // 0: no touch
+#else 
 		int id = -1; // -1: no touch
+#endif
 		uint32 timeLastDown = 0;
 		int lastX = 0; // last known screen coordinates
 		int lastY = 0; // last known screen coordinates
diff --git a/backends/events/sdl/sdl3-events.cpp b/backends/events/sdl/sdl3-events.cpp
index c2f7080a49e..8fbca068593 100644
--- a/backends/events/sdl/sdl3-events.cpp
+++ b/backends/events/sdl/sdl3-events.cpp
@@ -359,7 +359,7 @@ void SdlEventSource::preprocessFingerDown(SDL_Event *event) {
 	// make sure each finger is not reported down multiple times
 	for (int i = 0; i < MAX_NUM_FINGERS; i++) {
 		if (_touchPanels[port]._finger[i].id == id) {
-			_touchPanels[port]._finger[i].id = -1;
+			_touchPanels[port]._finger[i].id = 0;
 		}
 	}
 
@@ -367,9 +367,9 @@ void SdlEventSource::preprocessFingerDown(SDL_Event *event) {
 	// or a long tap (drag)
 	// we also need the last coordinates for each finger to keep track of dragging
 	for (int i = 0; i < MAX_NUM_FINGERS; i++) {
-		if (_touchPanels[port]._finger[i].id == -1) {
+		if (_touchPanels[port]._finger[i].id == 0) {
 			_touchPanels[port]._finger[i].id = id;
-			_touchPanels[port]._finger[i].timeLastDown = event->tfinger.timestamp;
+			_touchPanels[port]._finger[i].timeLastDown = SDL_NS_TO_MS(event->tfinger.timestamp);
 			_touchPanels[port]._finger[i].lastDownX = event->tfinger.x;
 			_touchPanels[port]._finger[i].lastDownY = event->tfinger.y;
 			_touchPanels[port]._finger[i].lastX = x;
@@ -414,7 +414,7 @@ bool SdlEventSource::preprocessFingerUp(SDL_Event *event, Common::Event *ev) {
 	// find out how many fingers were down before this event
 	int numFingersDown = 0;
 	for (int i = 0; i < MAX_NUM_FINGERS; i++) {
-		if (_touchPanels[port]._finger[i].id >= 0) {
+		if (_touchPanels[port]._finger[i].id != 0) {
 			numFingersDown++;
 		}
 	}
@@ -424,9 +424,9 @@ bool SdlEventSource::preprocessFingerUp(SDL_Event *event, Common::Event *ev) {
 
 	for (int i = 0; i < MAX_NUM_FINGERS; i++) {
 		if (_touchPanels[port]._finger[i].id == id) {
-			_touchPanels[port]._finger[i].id = -1;
+			_touchPanels[port]._finger[i].id = 0;
 			if (!_touchPanels[port]._multiFingerDragging) {
-				if ((event->tfinger.timestamp - _touchPanels[port]._finger[i].timeLastDown) <= MAX_TAP_TIME && !_touchPanels[port]._tapMade) {
+				if ((SDL_NS_TO_MS(event->tfinger.timestamp) - _touchPanels[port]._finger[i].timeLastDown) <= MAX_TAP_TIME && !_touchPanels[port]._tapMade) {
 					// short (<MAX_TAP_TIME ms) tap is interpreted as right/left mouse click depending on # fingers already down
 					// but only if the finger hasn't moved since it was pressed down by more than MAX_TAP_MOTION_DISTANCE pixels
 					Common::Point touchscreenSize = getTouchscreenSize();
@@ -443,12 +443,12 @@ bool SdlEventSource::preprocessFingerUp(SDL_Event *event, Common::Event *ev) {
 							if (numFingersDown == 2) {
 								simulatedButton = SDL_BUTTON_RIGHT;
 								// need to raise the button later
-								_touchPanels[port]._simulatedClickStartTime[1] = event->tfinger.timestamp;
+								_touchPanels[port]._simulatedClickStartTime[1] = SDL_NS_TO_MS(event->tfinger.timestamp);
 								_touchPanels[port]._tapMade = true;
 							} else if (numFingersDown == 1) {
 								simulatedButton = SDL_BUTTON_LEFT;
 								// need to raise the button later
-								_touchPanels[port]._simulatedClickStartTime[0] = event->tfinger.timestamp;
+								_touchPanels[port]._simulatedClickStartTime[0] = SDL_NS_TO_MS(event->tfinger.timestamp);
 								if (!isTouchPortTouchpadMode(port)) {
 									convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
 								}
@@ -497,7 +497,7 @@ void SdlEventSource::preprocessFingerMotion(SDL_Event *event) {
 	// find out how many fingers were down before this event
 	int numFingersDown = 0;
 	for (int i = 0; i < MAX_NUM_FINGERS; i++) {
-		if (_touchPanels[port]._finger[i].id >= 0) {
+		if (_touchPanels[port]._finger[i].id != 0) {
 			numFingersDown++;
 		}
 	}
@@ -544,8 +544,8 @@ void SdlEventSource::preprocessFingerMotion(SDL_Event *event) {
 				// only start a multi-finger drag if at least two fingers have been down long enough
 				int numFingersDownLong = 0;
 				for (int i = 0; i < MAX_NUM_FINGERS; i++) {
-					if (_touchPanels[port]._finger[i].id >= 0) {
-						if (event->tfinger.timestamp - _touchPanels[port]._finger[i].timeLastDown > MAX_TAP_TIME) {
+					if (_touchPanels[port]._finger[i].id != 0) {
+						if (SDL_NS_TO_MS(event->tfinger.timestamp) - _touchPanels[port]._finger[i].timeLastDown > MAX_TAP_TIME) {
 							numFingersDownLong++;
 						}
 					}
@@ -560,7 +560,7 @@ void SdlEventSource::preprocessFingerMotion(SDL_Event *event) {
 							if (_touchPanels[port]._finger[i].id == id) {
 								Uint32 earliestTime = _touchPanels[port]._finger[i].timeLastDown;
 								for (int j = 0; j < MAX_NUM_FINGERS; j++) {
-									if (_touchPanels[port]._finger[j].id >= 0 && (i != j) ) {
+									if (_touchPanels[port]._finger[j].id != 0 && (i != j) ) {
 										if (_touchPanels[port]._finger[j].timeLastDown < earliestTime) {
 											mouseDownX = _touchPanels[port]._finger[j].lastX;
 											mouseDownY = _touchPanels[port]._finger[j].lastY;
@@ -596,7 +596,7 @@ void SdlEventSource::preprocessFingerMotion(SDL_Event *event) {
 			for (int i = 0; i < MAX_NUM_FINGERS; i++) {
 				if (_touchPanels[port]._finger[i].id == id) {
 					for (int j = 0; j < MAX_NUM_FINGERS; j++) {
-						if (_touchPanels[port]._finger[j].id >= 0 && (i != j) ) {
+						if (_touchPanels[port]._finger[j].id != 0 && (i != j) ) {
 							if (_touchPanels[port]._finger[j].timeLastDown < _touchPanels[port]._finger[i].timeLastDown) {
 								updatePointer = false;
 							}


Commit: 754d4b4c0c828902e874eb389df3ceed239b9a3b
    https://github.com/scummvm/scummvm/commit/754d4b4c0c828902e874eb389df3ceed239b9a3b
Author: Christian Kündig (christian at kuendig.info)
Date: 2025-08-03T22:52:23+02:00

Commit Message:
EMSCRIPTEN: Add Emscripten backend to configure and setup SDL3 manually

Changed paths:
    configure


diff --git a/configure b/configure
index 44d4bf0f3f1..84f558be37a 100755
--- a/configure
+++ b/configure
@@ -3275,9 +3275,21 @@ EOF
 			append_var LDFLAGS "-O3"
 		fi
 
-		# activate emscripten-ports
-		if test "$_sdl" != no; then # we enable SDL2 by default
-			append_var LDFLAGS "-s USE_SDL=2 "
+		# enable SDL3 and set it up correctly
+		if test "$_dynamic_modules" = "yes" ; then
+			embuilder build sdl3 --pic 
+		else
+			embuilder build sdl3
+		fi
+		_pkg_config=yes
+		PKG_CONFIG_LIBDIR="$EMSDK/upstream/emscripten/cache/sysroot/local/lib/pkgconfig:$EMSDK/upstream/emscripten/cache/sysroot/lib/pkgconfig"
+		_sdlconfig="pkg-config sdl3"
+		_sdlversion=`$_sdlconfig --modversion`
+		append_var SDL_CFLAGS "`$_sdlconfig --cflags | sed 's/[[:space:]]*-Dmain=SDL_main//g'`"
+		if test "$_static_build" = yes ; then
+			append_var SDL_LIBS "`$_sdlconfig --static-libs`"
+		else
+			append_var SDL_LIBS "`$_sdlconfig --libs`"
 		fi
 
 		# We explicitly disable optional libraries if not enabled. "auto" would depend
@@ -3630,7 +3642,7 @@ if test -n "$_host"; then
 			_strip=$_host-strip
 			;;
 		wasm*-emscripten)
-			_backend="sdl"
+			_backend="emscripten"
 			# Disable cloud and SDL_Net as this is handled in the browser
 			_cloud=no
 			_sdlnet=no
@@ -4123,6 +4135,10 @@ case $_backend in
 	ds)
 		append_var INCLUDES '-I$(srcdir)/backends/platform/ds'
 		;;
+	emscripten)
+		_sdl=yes
+		append_var MODULES "backends/platform/sdl"
+		;;
 	ios7)
 		append_var LIBS "-lobjc -framework UIKit -framework CoreGraphics -framework OpenGLES"
 		append_var LIBS "-framework QuartzCore -framework CoreFoundation -framework Foundation"
@@ -4658,7 +4674,7 @@ fi
 # Enable 16bit support only for backends which support it
 #
 case $_backend in
-	3ds | android | dc | ds | ios7 | kolibrios | maemo | null | opendingux | miyoomini | miyoo | openpandora | psp | psp2 | sailfish | samsungtv | sdl | switch | wii)
+	3ds | android | dc | ds | emscripten |ios7 | kolibrios | maemo | null | opendingux | miyoomini | miyoo | openpandora | psp | psp2 | sailfish | samsungtv | sdl | switch | wii)
 		if test "$_16bit" = auto ; then
 			_16bit=yes
 		else
@@ -4694,7 +4710,7 @@ esac
 # Enable Event Recorder only for backends that support it
 #
 case $_backend in
-	sdl)
+	sdl | emscripten)
 		;;
 	*)
 		_eventrec=no
@@ -6499,6 +6515,11 @@ if test "$_opengl_mode" != none ; then
 			_opengl_mode=gles2
 			_opengl_glad=yes
 			;;
+		emscripten)
+			_opengl_mode=gles2
+			_opengl_glad=no # https://github.com/Dav1dde/glad-web/issues/12
+			append_var OPENGL_LIBS "-s FULL_ES2=1 -s MAX_WEBGL_VERSION=1"
+			;;
 		ios7)
 			_opengl_mode=gles2
 			_opengl_glad=yes
@@ -6527,11 +6548,6 @@ if test "$_opengl_mode" != none ; then
 						darwin*)
 							_opengl_mode=gl
 							;;
-						emscripten)
-							_opengl_mode=gles2
-							_opengl_glad=no # https://github.com/Dav1dde/glad-web/issues/12
-							append_var OPENGL_LIBS "-s FULL_ES2=1 -s MAX_WEBGL_VERSION=1"
-							;;
 						*)
 							# As SDL2 supports everything, let the user choose if he wants to
 							test "$_opengl_mode" = "auto" && _opengl_mode=any
@@ -6935,7 +6951,7 @@ echocheck "ImGui"
 if test "$_imgui" != no ; then
 	if test "$_freetype2" = yes ; then
 		case $_backend in
-			sdl | sailfish)
+			sdl | sailfish | emscripten)
 				if test "$_sdlMajorVersionNumber" -ge 3 ; then
 					cat > $TMPC << EOF
 #include <SDL3/SDL.h>




More information about the Scummvm-git-logs mailing list