Löve2d patch

Hey,
I’ve been working on a patchset to update love2d to 11.3 and then to 11.4

after haikuporter managed to destroy my patchset for the third time I simply don’t have the energy to finish it. I’m putting it here in the hopes that another interested party may finish it.

Goals of the patch:

  • update löve2d to 11.4
  • Remove B_SINGLE_LAUNCH | B_ARGV_ONLY;
    Single launch is uneccesary (works just fine with multiple games, or multiple times the same game running) and ARGV_ONLY is always wrong for GUI applications (it breaks screenshotting windows because the app_server can’t ask for the window dimensions), Additionally SDL2 processes BMessages just fine, and BMessages are required to get the game archive path for running archives.
  • Use the Love argv hack with the sdl filedrop event to enable running love2d game archives by double clicking
  • add a mimetype for love2d game archives for easy packaging of games
  • add proper Haiku integration for love2d, in particular implement stuff like letting lua know we run on Haiku, find the correct cache/data dir for games; add way to properly open links in browser, let love2d get the executable path etc.

Mainly I wrote this because I’d like to package my own love2d game for haiku as a .hpkg that can be directly downloaded from my git, and then run from it with double clicking. All without shipping the love2d executable in my repo.

I am available for any questions regarding this patch. :slight_smile:
(On another note, has anyone ported lövr yet?)

(and another note… composing this post has been quite annoying, I blame markdown and slow inefficient web apps)

From 346257ccad99d552eba705f42379a7be38744ad7 Mon Sep 17 00:00:00 2001
From: Pascal Abresch <nep@packageloss.eu>
Date: Wed, 6 Apr 2022 19:46:31 +0200
Subject: [PATCH] WIP: love2d

---
 .../love/additional-files/love.rdef.in        |   2 +-
 .../love/additional-files/x-love-game.rdef    |  26 +
 .../love/additional-files/x-love-game.rsrc    | Bin 0 -> 2647 bytes
 .../{love-11.2.recipe => love-11.4.recipe}    |  26 +-
 games-engines/love/patches/love-11.2.patchset | 136 -----
 games-engines/love/patches/love-11.4.patchset | 485 ++++++++++++++++++
 6 files changed, 528 insertions(+), 147 deletions(-)
 create mode 100644 games-engines/love/additional-files/x-love-game.rdef
 create mode 100644 games-engines/love/additional-files/x-love-game.rsrc
 rename games-engines/love/{love-11.2.recipe => love-11.4.recipe} (80%)
 delete mode 100644 games-engines/love/patches/love-11.2.patchset
 create mode 100644 games-engines/love/patches/love-11.4.patchset

diff --git a/games-engines/love/additional-files/love.rdef.in b/games-engines/love/additional-files/love.rdef.in
index f37650bdb..fc92699b0 100644
--- a/games-engines/love/additional-files/love.rdef.in
+++ b/games-engines/love/additional-files/love.rdef.in
@@ -1,5 +1,5 @@
 
-resource app_flags B_SINGLE_LAUNCH | B_ARGV_ONLY;
+resource app_flags B_MULTIPLE_LAUNCH;
 
 resource app_version {
 	major  = @MAJOR@,
diff --git a/games-engines/love/additional-files/x-love-game.rdef b/games-engines/love/additional-files/x-love-game.rdef
new file mode 100644
index 000000000..b5c7b60cd
--- /dev/null
+++ b/games-engines/love/additional-files/x-love-game.rdef
@@ -0,0 +1,26 @@
+
+resource(0, "BEOS:TYPE") #'MIMS' "application/x-vnd.Be-meta-mime";
+
+resource(1, "META:TYPE") "application/x-love-game";
+
+resource(2, "META:S:DESC") #'MSDC' "LÖVE game";
+
+resource(3, "META:L:DESC") #'MLDC' "A LÖVE based game archive";
+
+resource(4, "META:PREF_APP") #'MSIG' "application/x-vnd.love";
+
+resource(5, "META:ICON") #'VICN' array {
+	$"6E6369660403E74A9904004C0327AAE105FF040607FF1FC6D5B92DC6D5B92DC3"
+	$"E7B632BFB9B354C0A2B354BE55B354B382BF8BB382BE47B382C025B945C651B6"
+	$"52C358B982C62AB9F7C5CCB9BDC5FEBE5FC1A9C6D5B92DC38ABE34C6D5B92DB9"
+	$"2D0607FF1FC731B9B7C731B9B7C3E6BEBEBA53C655BEBBC233BA19C688B9A1C6"
+	$"DBB9DEC6B4BC6DC9AEC015CC4DBF57CC4DC1C3CC4DCC4DC015CC4DC130CC4DBF"
+	$"4DC731B9B7C9E5BC75C731B9B7B9B70607FF1FC6D5B92DC6D5B92DC38ABE34B9"
+	$"F7C5CCBE5FC1A9B9BDC5FEB945C651B982C62ABC11C925BFB9CBC3BEFBCBC3C1"
+	$"67CBC3CBF1BF8BCBF1C0A6CBF1BEC3C6D5B92DC989BBEBC6D5B92DB92D0608FE"
+	$"7FC01BBCBABCCABAE8BF08BA5FBA8CBB71BFC1C5B8B5DEC005BFC1C5B8BFBFC5"
+	$"B840C5B8C9A2C005C2B7BAE8C4F4BB71C079BA5FBF66BCBABF66BCBABFA2BCBA"
+	$"C01BBCBABFDFBCBAC01BBCBABCBA040A000100000A010101000A020102000A03"
+	$"010300"
+};
+
diff --git a/games-engines/love/additional-files/x-love-game.rsrc b/games-engines/love/additional-files/x-love-game.rsrc
new file mode 100644
index 0000000000000000000000000000000000000000..2a485a83b68ded62e243c3bd84e615285e4d3545
GIT binary patch
literal 2647
zcmeHJPiWI%6#vpcTNg$2ASyeommvuC|7j<?G>%HM)+U>JDzWRf!rE;*i=KpfQRht%
zJlcbxh?nTvFO5mM*l0};UOXui5#2-(3W5h=^?OOJ)RPFi<%7rj<^8_*dykJ7cu5{1
zv@;&*BQ634;6D!JB9i;X>uAhU4u)`>9EfiPzBYi+Ya$H#kNOcBa>^i!;JqFEk>G6|
z{Egtj4ju>~w5NlE1gA;Qzt2|o3^iPR=cV0uaNoh50e1%68Thvu5EmBavT1QCJD)#v
zIaJ6`9URSsa+xJDl*{HasF$9bFJwY9B8kV0JCkhChT)*|abCQbnX*Gc@j`kwTlhO0
z#6bb&)7fdCcm32|ABuVRKm6ct`}+FZL*^SC0yEZEj%rvE^pYf~6OtemwPmTOj!8v*
z7_;W-m85YN7tI6sN4<%k)i>2t?SY+lQ#}qIhd}Mc5nKi{KC7zCn-gkv^_aZRypHdg
zZ}FP>M9DQC>${trcBaYIj3(FQ;H!3+L^#N6d{Qof$K{^hNDZh9HK8{21HCA_8p9g4
z4E3jF)MhNhYH7<>OTTZmR0Dcy+^Bx-^cL8>st+o%@=D&&0&+^eRbA9-^~%#V-49;V
z>Xj4qN~5IvSIhFo^Y7I~{feB@rWM(?k|IO8_TKS|?4uFcGiZvU5bdEni1t!m#B)&&
z1^_k?8jZ4XendEzVC^*levPESGr)Olo@0e@FV94H4mjAdwj-P8M<OiGbQPFLj04v9
x=SHme##of+fb|pG;b<h1?8#I(k?5+7Gto)lVN0Z)J5eS+-sRtUUfw1Y`UL_GCMf^_

literal 0
HcmV?d00001

diff --git a/games-engines/love/love-11.2.recipe b/games-engines/love/love-11.4.recipe
similarity index 80%
rename from games-engines/love/love-11.2.recipe
rename to games-engines/love/love-11.4.recipe
index e8c7a316d..db2230ac9 100644
--- a/games-engines/love/love-11.2.recipe
+++ b/games-engines/love/love-11.4.recipe
@@ -2,13 +2,14 @@ SUMMARY="A framework to make 2D games in Lua"
 DESCRIPTION="LÖVE is a framework to make 2D games in Lua.
 It's free, open-source, and works also on Windows, Mac OS X and Linux."
 HOMEPAGE="http://love2d.org/"
-COPYRIGHT="2010-2018 Löve"
+COPYRIGHT="2010-2022 Löve"
 LICENSE="Zlib"
-REVISION="3"
-SOURCE_URI="https://bitbucket.org/rude/love/downloads/love-$portVersion-linux-src.tar.gz"
-CHECKSUM_SHA256="6aaf8104fc35bb8bbd7865986b98079e7564ffdb374ea4d33604b46b458444f6"
-PATCHES="love-$portVersion.patchset"
-ADDITIONAL_FILES="love.rdef.in"
+REVISION="1"
+SOURCE_URI="https://github.com/love2d/love/releases/download/${portVersion}/love-${portVersion}-linux-src.tar.gz"
+CHECKSUM_SHA256="e32feecaf5f4f210242a4b5f26cdf9ce9014bfde18d51286f643bb7fe51f5369"
+PATCHES="love-${portVersion}.patchset"
+ADDITIONAL_FILES="love.rdef.in
+x-love-game.rsrc"
 
 ARCHITECTURES="all !x86_gcc2"
 SECONDARY_ARCHITECTURES="x86"
@@ -16,7 +17,7 @@ SECONDARY_ARCHITECTURES="x86"
 PROVIDES="
 	love$secondaryArchSuffix = $portVersion
 	cmd:love$secondaryArchSuffix = $portVersion
-	lib:liblove_11.2$secondaryArchSuffix = $portVersion
+	lib:liblove_11.4$secondaryArchSuffix = $portVersion
 	"
 REQUIRES="
 	haiku$secondaryArchSuffix
@@ -45,7 +46,7 @@ REQUIRES="
 PROVIDES_devel="
 	love${secondaryArchSuffix}_devel = $portVersion
 	devel:liblove$secondaryArchSuffix = $portVersion
-	devel:liblove_11.2$secondaryArchSuffix = $portVersion
+	devel:liblove_11.4$secondaryArchSuffix = $portVersion
 	"
 REQUIRES_devel="
 	love$secondaryArchSuffix == $portVersion base
@@ -105,7 +106,12 @@ INSTALL()
 	rm -f $libDir/*.la
 
 	# remove not relevant files
-	rm -rf $dataDir/{applications,icons,pixmaps}
+	rm -rf $dataDir/{applications,icons,pixmaps,mime}
+
+	# copy mimetype rsrc for love2d games
+	mkdir -p $dataDir/mime_db/application/
+	resattr -o $dataDir/mime_db/application/x-love-game $portDir/additional-files/x-love-game.rsrc
+
 
 	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
 	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
@@ -118,7 +124,7 @@ INSTALL()
 
 	addResourcesToBinaries love.rdef $binDir/love
 
-	prepareInstalledDevelLibs liblove-11.2 liblove
+	prepareInstalledDevelLibs liblove-11.4 liblove
 
 	packageEntries devel \
 		$developDir
diff --git a/games-engines/love/patches/love-11.2.patchset b/games-engines/love/patches/love-11.2.patchset
deleted file mode 100644
index 886555318..000000000
--- a/games-engines/love/patches/love-11.2.patchset
+++ /dev/null
@@ -1,136 +0,0 @@
-From c54427cc117d031d9eb3dbce07340de9229660ba Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
-Date: Sat, 6 May 2017 11:09:02 +0200
-Subject: Add Haiku to the known platforms
-
-
-diff --git a/src/common/config.h b/src/common/config.h
-index 8180f6a..72b2496 100644
---- a/src/common/config.h
-+++ b/src/common/config.h
-@@ -48,7 +48,7 @@
- #		define LOVE_MACOSX 1
- #	endif
- #endif
--#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
-+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__HAIKU__)
- // I know it's not linux, but it seems most "linux-only" code is bsd-compatible
- #	define LOVE_LINUX 1
- #endif
--- 
-2.30.0
-
-
-From a975efb2a9af608abb8c0e9a213ff27fa04037e8 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= <zmizsei@extrowerk.com>
-Date: Sat, 6 May 2017 11:18:30 +0200
-Subject: Build fix for Haiku
-
-
-diff --git a/src/modules/system/System.cpp b/src/modules/system/System.cpp
-index d85a947..3a9d441 100644
---- a/src/modules/system/System.cpp
-+++ b/src/modules/system/System.cpp
-@@ -39,8 +39,10 @@
- #if defined(LOVE_ANDROID)
- #include "common/android.h"
- #elif defined(LOVE_LINUX)
-+#ifndef __HAIKU__
- #include <spawn.h>
- #endif
-+#endif
- 
- namespace love
- {
-@@ -106,8 +108,10 @@ bool System::openURL(const std::string &url) const
- 
- 	// Note: at the moment this process inherits our file descriptors.
- 	// Note: the below const_cast is really ugly as well.
-+	#ifndef __HAIKU__
- 	if (posix_spawnp(&pid, "xdg-open", nullptr, nullptr, const_cast<char **>(argv), environ) != 0)
- 		return false;
-+	#endif
- 
- 	// Check if xdg-open already completed (or failed.)
- 	int status = 0;
--- 
-2.30.0
-
-
-From fefdfa8ca95a20e939de01dcd9a1a729d93c9ce0 Mon Sep 17 00:00:00 2001
-From: begasus <begasus@gmail.com>
-Date: Fri, 26 Apr 2019 19:14:39 +0200
-Subject: Build fix for Haiku #2
-
-
-diff --git a/src/libraries/luasocket/libluasocket/compat.h b/src/libraries/luasocket/libluasocket/compat.h
-index 7bf8010..9e3b43f 100644
---- a/src/libraries/luasocket/libluasocket/compat.h
-+++ b/src/libraries/luasocket/libluasocket/compat.h
-@@ -5,6 +5,8 @@
- #include "lauxlib.h"
- 
- #if LUA_VERSION_NUM==501
-+#define luaL_setfuncs socket_setfuncs
-+#define luaL_testudata socket_testudata
- void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
- #endif
- 
--- 
-2.30.0
-
-
-From 823e7ebebfafc3b11e0d125671a8f00310a71e7f Mon Sep 17 00:00:00 2001
-From: Jerome Duval <jerome.duval@gmail.com>
-Date: Sun, 14 Feb 2021 11:49:17 +0100
-Subject: links against libnetwork
-
-
-diff --git a/configure.ac b/configure.ac
-index 781680c..9fbaeb1 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -64,6 +64,7 @@ ACLOVE_DEP_SDL2
- ACLOVE_DEP_LIBM
- ACLOVE_DEP_ZLIB
- ACLOVE_DEP_PTHREAD
-+ACLOVE_DEP_SOCKET
- 
- # Conditional dependencies
- AS_VAR_IF([enable_module_audio], [yes], [ACLOVE_DEP_OPENAL], [])
-diff --git a/platform/unix/deps.m4 b/platform/unix/deps.m4
-index 42938d9..af4c10f 100644
---- a/platform/unix/deps.m4
-+++ b/platform/unix/deps.m4
-@@ -25,6 +25,16 @@ AC_DEFUN([ACLOVE_DEP_SDL2], [
- AC_DEFUN([ACLOVE_DEP_PTHREAD], [
- 	AC_SEARCH_LIBS([pthread_create], [pthread], [], [LOVE_MSG_ERROR([the POSIX threads library])])])
- 
-+AC_DEFUN([ACLOVE_DEP_SOCKET], [
-+  AC_CHECK_FUNCS(connect,,[
-+    AC_CHECK_LIB(network,connect,[
-+      LIBS_SOCKET="-lnetwork"
-+      AC_SUBST([LIBS_SOCKET],[])
-+    ])
-+  ])
-+])
-+
-+
- # does not use pkg-config because of the FILE_OFFSET_BITS.. bit
- AC_DEFUN([ACLOVE_DEP_MPG123], [
- 	AC_SEARCH_LIBS([mpg123_open_feed], [mpg123], [],
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 0d87ac4..df3e874 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -1023,6 +1023,7 @@ endif
- 
- if LOVE_LIBRARY_LUASOCKET
- liblove_la_SOURCES += $(liblove_library_luasocket)
-+liblove_la_LIBADD += $(LIBS_SOCKET)
- endif
- 
- if LOVE_LIBRARY_LZ4
--- 
-2.30.0
-
diff --git a/games-engines/love/patches/love-11.4.patchset b/games-engines/love/patches/love-11.4.patchset
new file mode 100644
index 000000000..2c9ab2cc0
--- /dev/null
+++ b/games-engines/love/patches/love-11.4.patchset
@@ -0,0 +1,485 @@
+From 244eef63889592db0e8d513b24780e886acbcce2 Mon Sep 17 00:00:00 2001
+From: begasus <begasus@gmail.com>
+Date: Fri, 26 Apr 2019 19:14:39 +0200
+Subject: Build fix for Haiku #2
+
+
+diff --git a/src/libraries/luasocket/libluasocket/compat.h b/src/libraries/luasocket/libluasocket/compat.h
+index 7bf8010..9e3b43f 100644
+--- a/src/libraries/luasocket/libluasocket/compat.h
++++ b/src/libraries/luasocket/libluasocket/compat.h
+@@ -5,6 +5,8 @@
+ #include "lauxlib.h"
+ 
+ #if LUA_VERSION_NUM==501
++#define luaL_setfuncs socket_setfuncs
++#define luaL_testudata socket_testudata
+ void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);
+ #endif
+ 
+-- 
+2.30.2
+
+
+From cb13079abfba285ec1a3ed2eb39d055dba7bce5f Mon Sep 17 00:00:00 2001
+From: Jerome Duval <jerome.duval@gmail.com>
+Date: Sun, 14 Feb 2021 11:49:17 +0100
+Subject: links against libnetwork
+
+
+diff --git a/configure.ac b/configure.ac
+index 89ad64b..5275899 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -64,6 +64,7 @@ ACLOVE_DEP_SDL2
+ ACLOVE_DEP_LIBM
+ ACLOVE_DEP_ZLIB
+ ACLOVE_DEP_PTHREAD
++ACLOVE_DEP_SOCKET
+ 
+ # Conditional dependencies
+ AS_VAR_IF([enable_module_audio], [yes], [ACLOVE_DEP_OPENAL], [])
+diff --git a/platform/unix/deps.m4 b/platform/unix/deps.m4
+index fbfb1c9..430fc0e 100644
+--- a/platform/unix/deps.m4
++++ b/platform/unix/deps.m4
+@@ -27,6 +27,16 @@ AC_DEFUN([ACLOVE_DEP_SDL2], [
+ AC_DEFUN([ACLOVE_DEP_PTHREAD], [
+ 	AC_SEARCH_LIBS([pthread_create], [pthread], [], [LOVE_MSG_ERROR([the POSIX threads library])])])
+ 
++AC_DEFUN([ACLOVE_DEP_SOCKET], [
++  AC_CHECK_FUNCS(connect,,[
++    AC_CHECK_LIB(network,connect,[
++      LIBS_SOCKET="-lnetwork"
++      AC_SUBST([LIBS_SOCKET],[])
++    ])
++  ])
++])
++
++
+ # does not use pkg-config because of the FILE_OFFSET_BITS.. bit
+ AC_DEFUN([ACLOVE_DEP_MPG123], [
+ 	AC_SEARCH_LIBS([mpg123_open_feed], [mpg123], [],
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 1d822b7..461ced1 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -1041,6 +1041,7 @@ endif
+ 
+ if LOVE_LIBRARY_LUASOCKET
+ liblove_la_SOURCES += $(liblove_library_luasocket)
++liblove_la_LIBADD += $(LIBS_SOCKET)
+ endif
+ 
+ if LOVE_LIBRARY_LZ4
+-- 
+2.30.2
+
+
+From 1978ba3b5759ef16403a160b582fa25ec18047f3 Mon Sep 17 00:00:00 2001
+From: Pascal Abresch <nep@packageloss.eu>
+Date: Mon, 14 Mar 2022 11:11:24 +0100
+Subject: Add Haiku support
+
+
+diff --git a/src/common/config.h b/src/common/config.h
+index 5aef35f..e9ff75f 100644
+--- a/src/common/config.h
++++ b/src/common/config.h
+@@ -52,7 +52,9 @@
+ // I know it's not linux, but it seems most "linux-only" code is bsd-compatible
+ #	define LOVE_LINUX 1
+ #endif
+-
++#if defined(__HAIKU__)
++#	define LOVE_HAIKU 1
++#endif
+ // Endianness.
+ #if defined(__ppc__) || defined(__ppc) || defined(__powerpc__) || defined(__powerpc)
+ #	define LOVE_BIG_ENDIAN 1
+@@ -164,7 +166,7 @@
+ #endif
+ 
+ // Check we have a sane configuration
+-#if !defined(LOVE_WINDOWS) && !defined(LOVE_LINUX) && !defined(LOVE_IOS) && !defined(LOVE_MACOSX) && !defined(LOVE_ANDROID)
++#if !defined(LOVE_WINDOWS) && !defined(LOVE_LINUX) && !defined(LOVE_IOS) && !defined(LOVE_MACOSX) && !defined(LOVE_ANDROID) && !defined(LOVE_ANDROID)
+ #	error Could not detect target platform
+ #endif
+ #if !defined(LOVE_LITTLE_ENDIAN) && !defined(LOVE_BIG_ENDIAN)
+diff --git a/src/modules/audio/openal/Audio.cpp b/src/modules/audio/openal/Audio.cpp
+index 3f8193f..5af5afe 100644
+--- a/src/modules/audio/openal/Audio.cpp
++++ b/src/modules/audio/openal/Audio.cpp
+@@ -100,7 +100,7 @@ Audio::Audio()
+ 	, poolThread(nullptr)
+ 	, distanceModel(DISTANCE_INVERSE_CLAMPED)
+ {
+-#if defined(LOVE_LINUX)
++#if defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ 	// Temporarly block signals, as the thread inherits this mask
+ 	love::thread::disableSignals();
+ #endif
+@@ -134,7 +134,7 @@ Audio::Audio()
+ 	if (!alcMakeContextCurrent(context) || alcGetError(device) != ALC_NO_ERROR)
+ 		throw love::Exception("Could not make context current.");
+ 
+-#if defined(LOVE_LINUX)
++#if defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ 	love::thread::reenableSignals();
+ #endif
+ 
+diff --git a/src/modules/filesystem/Filesystem.cpp b/src/modules/filesystem/Filesystem.cpp
+index a80d33c..4f9fe01 100644
+--- a/src/modules/filesystem/Filesystem.cpp
++++ b/src/modules/filesystem/Filesystem.cpp
+@@ -33,6 +33,8 @@
+ #elif defined(LOVE_WINDOWS)
+ #include <windows.h>
+ #include "common/utf8.h"
++#elif defined(LOVE_HAIKU)
++#include <Application.h>
+ #elif defined(LOVE_LINUX)
+ #include <unistd.h>
+ #endif
+@@ -105,6 +107,14 @@ std::string Filesystem::getExecutablePath() const
+ 
+ 	return to_utf8(buffer);
+ 
++#elif defined(LOVE_HAIKU)
++	app_info info;
++	if (be_app->GetAppInfo(&info) != B_OK)
++		return "";
++
++	BPath entry(&info.ref);
++	return entry.Path();
++
+ #elif defined(LOVE_LINUX)
+ 
+ 	char buffer[2048] = {0};
+diff --git a/src/modules/filesystem/Filesystem.h b/src/modules/filesystem/Filesystem.h
+index 5952a06..bb9e070 100644
+--- a/src/modules/filesystem/Filesystem.h
++++ b/src/modules/filesystem/Filesystem.h
+@@ -43,7 +43,7 @@
+ #else
+ #	if defined(LOVE_MACOSX) || defined(LOVE_IOS)
+ #		define LOVE_APPDATA_FOLDER "LOVE"
+-#	elif defined(LOVE_LINUX)
++#	elif defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ #		define LOVE_APPDATA_FOLDER "love"
+ #	else
+ #		define LOVE_APPDATA_PREFIX "."
+diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp
+index b48c80a..7bf460b 100644
+--- a/src/modules/filesystem/physfs/Filesystem.cpp
++++ b/src/modules/filesystem/physfs/Filesystem.cpp
+@@ -534,6 +534,8 @@ std::string Filesystem::getAppdataDirectory()
+ 		appdata = normalize(udir);
+ #elif defined(LOVE_IOS)
+ 		appdata = normalize(love::ios::getAppdataDirectory());
++#elif defined(LOVE_HAIKU)
++		find_directory(B_USER_DATA_DIRECTORY, &appdata);
+ #elif defined(LOVE_LINUX)
+ 		char *xdgdatahome = getenv("XDG_DATA_HOME");
+ 		if (!xdgdatahome)
+diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp
+index bf2e715..067239e 100644
+--- a/src/modules/graphics/opengl/OpenGL.cpp
++++ b/src/modules/graphics/opengl/OpenGL.cpp
+@@ -149,7 +149,7 @@ bool OpenGL::initContext()
+ 
+ 	initOpenGLFunctions();
+ 
+-#if defined(LOVE_WINDOWS) || defined(LOVE_LINUX)
++#if defined(LOVE_WINDOWS) || defined(LOVE_LINUX) || defined(HAIKU)
+ 	// See the comments in OpenGL.h.
+ 	if (getVendor() == VENDOR_AMD)
+ 	{
+diff --git a/src/modules/love/love.cpp b/src/modules/love/love.cpp
+index a75d3c9..858226a 100644
+--- a/src/modules/love/love.cpp
++++ b/src/modules/love/love.cpp
+@@ -490,6 +490,8 @@ int luaopen_love(lua_State *L)
+ 	lua_pushstring(L, "Android");
+ #elif defined(LOVE_LINUX)
+ 	lua_pushstring(L, "Linux");
++#elif defined(LOVE_HAIKU)
++	lua_pushstring(L, "Haiku");
+ #else
+ 	lua_pushstring(L, "Unknown");
+ #endif
+diff --git a/src/modules/system/System.cpp b/src/modules/system/System.cpp
+index 981dcff..caae6a1 100644
+--- a/src/modules/system/System.cpp
++++ b/src/modules/system/System.cpp
+@@ -26,6 +26,8 @@
+ #include <CoreServices/CoreServices.h>
+ #elif defined(LOVE_IOS)
+ #include "common/ios.h"
++#elif defined(LOVE_HAIKU)
++#include <Url.h>
+ #elif defined(LOVE_LINUX) || defined(LOVE_ANDROID)
+ #include <signal.h>
+ #include <sys/wait.h>
+@@ -76,6 +78,8 @@ std::string System::getOS() const
+ 	return "Android";
+ #elif defined(LOVE_LINUX)
+ 	return "Linux";
++#elif defined(LOVE_HAIKU)
++	return "Haiku";
+ #else
+ 	return "Unknown";
+ #endif
+@@ -112,6 +116,11 @@ bool System::openURL(const std::string &url) const
+ 
+ 	return love::android::openURL(url);
+ 
++#elif defined(LOVE_HAIKU)
++
++	BUrl bUrl(*url);
++	return bUrl.OpenWithPreferredApplication() == B_OK)
++
+ #elif defined(LOVE_LINUX)
+ 
+ 	pid_t pid;
+diff --git a/src/modules/thread/sdl/Thread.cpp b/src/modules/thread/sdl/Thread.cpp
+index cfc63e3..226bae0 100644
+--- a/src/modules/thread/sdl/Thread.cpp
++++ b/src/modules/thread/sdl/Thread.cpp
+@@ -42,7 +42,7 @@ Thread::~Thread()
+ 
+ bool Thread::start()
+ {
+-#if defined(LOVE_LINUX)
++#if defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ 	// Temporarly block signals, as the thread inherits this mask
+ 	love::thread::disableSignals();
+ #endif
+@@ -55,7 +55,7 @@ bool Thread::start()
+ 	thread = SDL_CreateThread(thread_runner, t->getThreadName(), this);
+ 	running = (thread != nullptr);
+ 
+-#if defined(LOVE_LINUX)
++#if defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ 	love::thread::reenableSignals();
+ #endif
+ 	return running;
+diff --git a/src/modules/thread/threads.cpp b/src/modules/thread/threads.cpp
+index f680d08..9e92347 100644
+--- a/src/modules/thread/threads.cpp
++++ b/src/modules/thread/threads.cpp
+@@ -20,7 +20,7 @@
+ 
+ #include "threads.h"
+ 
+-#if defined(LOVE_LINUX)
++#if defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ #include <signal.h>
+ #endif
+ 
+@@ -157,7 +157,7 @@ Conditional *ConditionalRef::operator->() const
+ 	return conditional;
+ }
+ 
+-#if defined(LOVE_LINUX)
++#if defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ static sigset_t oldset;
+ 
+ void disableSignals()
+diff --git a/src/modules/thread/threads.h b/src/modules/thread/threads.h
+index 5f607ba..cde0ab8 100644
+--- a/src/modules/thread/threads.h
++++ b/src/modules/thread/threads.h
+@@ -129,7 +129,7 @@ Mutex *newMutex();
+ Conditional *newConditional();
+ Thread *newThread(Threadable *t);
+ 
+-#if defined(LOVE_LINUX)
++#if defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ void disableSignals();
+ void reenableSignals();
+ #endif
+diff --git a/src/modules/timer/Timer.cpp b/src/modules/timer/Timer.cpp
+index 48d1d5f..a8b1c2e 100644
+--- a/src/modules/timer/Timer.cpp
++++ b/src/modules/timer/Timer.cpp
+@@ -30,7 +30,7 @@
+ #elif defined(LOVE_MACOSX) || defined(LOVE_IOS)
+ #include <mach/mach_time.h>
+ #include <sys/time.h>
+-#elif defined(LOVE_LINUX)
++#elif defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ #include <unistd.h>
+ #include <time.h>
+ #include <sys/time.h>
+@@ -101,7 +101,7 @@ double Timer::getAverageDelta() const
+ 	return averageDelta;
+ }
+ 
+-#if defined(LOVE_LINUX)
++#if defined(LOVE_LINUX) || defined(LOVE_HAIKU)
+ 
+ static inline timespec getTimeOfDay()
+ {
+-- 
+2.30.2
+
+
+From fb9e50cfde1e261089bb88040f81f93c1be739eb Mon Sep 17 00:00:00 2001
+From: Pascal Abresch <nep@packageloss.eu>
+Date: Mon, 14 Mar 2022 12:05:13 +0100
+Subject: Add ARGV hack for Haiku
+
+
+diff --git a/src/common/config.h b/src/common/config.h
+index e9ff75f..d2a3a04 100644
+--- a/src/common/config.h
++++ b/src/common/config.h
+@@ -119,7 +119,7 @@
+ #	define NOMINMAX
+ #endif
+ 
+-#if defined(LOVE_MACOSX) || defined(LOVE_IOS)
++#if defined(LOVE_MACOSX) || defined(LOVE_IOS) || defined(HAIKU)
+ #	define LOVE_LEGENDARY_APP_ARGV_HACK
+ #endif
+ 
+diff --git a/src/common/haiku.cpp b/src/common/haiku.cpp
+new file mode 100644
+index 0000000..715949a
+--- /dev/null
++++ b/src/common/haiku.cpp
+@@ -0,0 +1,58 @@
++/**
++ * Copyright (c) 2006-2022 LOVE Development Team
++ *
++ * This software is provided 'as-is', without any express or implied
++ * warranty.  In no event will the authors be held liable for any damages
++ * arising from the use of this software.
++ *
++ * Permission is granted to anyone to use this software for any purpose,
++ * including commercial applications, and to alter it and redistribute it
++ * freely, subject to the following restrictions:
++ *
++ * 1. The origin of this software must not be misrepresented; you must not
++ *    claim that you wrote the original software. If you use this software
++ *    in a product, an acknowledgment in the product documentation would be
++ *    appreciated but is not required.
++ * 2. Altered source versions must be plainly marked as such, and must not be
++ *    misrepresented as being the original software.
++ * 3. This notice may not be removed or altered from any source distribution.
++ **/
++
++#include "haiku.h"
++
++#ifdef LOVE_HAIKU
++
++#include <SDL2/SDL.h>
++
++namespace love
++{
++namespace haiku
++{
++
++
++std::string checkDropEvents()
++{
++	std::string dropstr;
++	SDL_Event event;
++
++	SDL_InitSubSystem(SDL_INIT_VIDEO);
++
++	SDL_PumpEvents();
++	if (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_DROPFILE, SDL_DROPFILE) > 0)
++	{
++		if (event.type == SDL_DROPFILE)
++		{
++			dropstr = std::string(event.drop.file);
++			SDL_free(event.drop.file);
++		}
++	}
++
++	SDL_QuitSubSystem(SDL_INIT_VIDEO);
++
++	return dropstr;
++}
++
++} // haiku
++} // love
++
++#endif // LOVE_HAIKU
+diff --git a/src/common/haiku.h b/src/common/haiku.h
+new file mode 100644
+index 0000000..1cf6bdc
+--- /dev/null
++++ b/src/common/haiku.h
+@@ -0,0 +1,46 @@
++/**
++ * Copyright (c) 2006-2022 LOVE Development Team
++ *
++ * This software is provided 'as-is', without any express or implied
++ * warranty.  In no event will the authors be held liable for any damages
++ * arising from the use of this software.
++ *
++ * Permission is granted to anyone to use this software for any purpose,
++ * including commercial applications, and to alter it and redistribute it
++ * freely, subject to the following restrictions:
++ *
++ * 1. The origin of this software must not be misrepresented; you must not
++ *    claim that you wrote the original software. If you use this software
++ *    in a product, an acknowledgment in the product documentation would be
++ *    appreciated but is not required.
++ * 2. Altered source versions must be plainly marked as such, and must not be
++ *    misrepresented as being the original software.
++ * 3. This notice may not be removed or altered from any source distribution.
++ **/
++
++#ifndef LOVE_HAIKU_H
++#define LOVE_HAIKU_H
++
++#include "config.h"
++
++#ifdef LOVE_HAIKU
++
++#include <string>
++
++namespace love
++{
++namespace haiku
++{
++
++/**
++ * Checks for drop-file events. Returns the filepath if an event occurred, or
++ * an empty string otherwise.
++ **/
++std::string checkDropEvents();
++
++} // haiku
++} // love
++
++#endif // LOVE_HAIKU
++
++#endif // LOVE_HAIKU_H
+diff --git a/src/love.cpp b/src/love.cpp
+index c8af859..7c0f5c3 100644
+--- a/src/love.cpp
++++ b/src/love.cpp
+@@ -108,7 +108,14 @@ static void get_app_arguments(int argc, char **argv, int &new_argc, char **&new_
+ 		}
+ 	}
+ #endif
+-
++#ifdef LOVE_HAIKU
++	else
++	{
++		static std::string dropfilestr = love::haiku::checkDropEvents();
++		if (!dropfilestr.empty())
++			temp_argv.insert(temp_argv.begin() +1, dropfilestr);
++	}
++#endif
+ 	// Copy temp argv vector to new argv array.
+ 	new_argc = (int) temp_argv.size();
+ 	new_argv = new char *[new_argc+1];
+-- 
+2.30.2
+
-- 
2.30.2


1 Like

I want to try it, maybe I’ll have better luck.

1 Like

I’ve done a small part directly now Love2d: enable multiple launch by nephele-gh · Pull Request #7279 · haikuports/haikuports · GitHub

This atleast acomplishes running the engine multiple times at once (required for my game atleast)

1 Like