about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-10-11 12:15:05 +0200
committerptitSeb <sebastien.chev@gmail.com>2023-10-11 12:15:05 +0200
commit0499c38466ca094b230ec6c825ec96ddcd987892 (patch)
tree47a4debd9df897c7523059999686b2c994dfe2e4
parent3e18d5ea57c5da660e28acf08127d46336d4d0a0 (diff)
downloadbox64-0499c38466ca094b230ec6c825ec96ddcd987892.tar.gz
box64-0499c38466ca094b230ec6c825ec96ddcd987892.zip
Added BOX64_SDL2_JGUID, a workaround for game using old SDL_GetJoystickGUIDInfo funciton on recent wrapped SDL2 (for #1018)
-rw-r--r--docs/USAGE.md5
-rw-r--r--src/include/debug.h1
-rw-r--r--src/main.c12
-rw-r--r--src/tools/rcfile.c4
-rw-r--r--src/wrapped/wrappedsdl2.c3
-rw-r--r--system/box64.box64rc3
6 files changed, 26 insertions, 2 deletions
diff --git a/docs/USAGE.md b/docs/USAGE.md
index 15566be6..5778a231 100644
--- a/docs/USAGE.md
+++ b/docs/USAGE.md
@@ -230,6 +230,11 @@ Detect libcef and apply malloc_hack settings
 * 0 : Don't detect libcef

 * 1 : Detect libcef, and apply MALLOC_HACK=2 if detected (Default)

 

+#### BOX64_SDL2_JGUID *

+Need a workaround for SDL_GetJoystickGUIDInfo function for wrapped SDL2

+* 0 : Don't use any workaround

+* 1 : Use a workaround for program that use the private SDL_GetJoystickGUIDInfo function with 1 missing argument

+

 #### BOX64_LIBGL *

  * libXXXX set the name for libGL (defaults to libGL.so.1).

  * /PATH/TO/libGLXXX : Sets the name and path for libGL

diff --git a/src/include/debug.h b/src/include/debug.h
index fa387d42..6c1ed419 100644
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -52,6 +52,7 @@ extern int rv64_xtheadfmv;
 #endif
 #endif
 extern int box64_libcef;
+extern int box64_sdl2_jguid;
 extern int dlsym_error;    // log dlsym error
 extern int cycle_log;      // if using rolling logs
 #ifdef HAVE_TRACE
diff --git a/src/main.c b/src/main.c
index 90e3575d..47cff957 100644
--- a/src/main.c
+++ b/src/main.c
@@ -93,6 +93,7 @@ int rv64_xtheadfmv = 0;
 int box64_dynarec = 0;
 #endif
 int box64_libcef = 1;
+int box64_sdl2_jguid = 0;
 int dlsym_error = 0;
 int cycle_log = 0;
 #ifdef HAVE_TRACE
@@ -718,7 +719,16 @@ void LoadLogEnv()
                 box64_libcef = p[0]-'0';
         }
         if(!box64_libcef)
-            printf_log(LOG_INFO, "Dynarec will not detect libcef\n");
+            printf_log(LOG_INFO, "BOX64 will not detect libcef\n");
+    }
+    p = getenv("BOX64_SDL2_JGUID");
+    if(p) {
+        if(strlen(p)==1) {
+            if(p[0]>='0' && p[0]<='1')
+                box64_sdl2_jguid = p[0]-'0';
+        }
+        if(!box64_sdl2_jguid)
+            printf_log(LOG_INFO, "BOX64 will workaround the use of  SDL_GetJoystickGUIDInfo with 4 args instead of 5\n");
     }
     p = getenv("BOX64_LOAD_ADDR");
     if(p) {
diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c
index d3b3e618..98b0d4cb 100644
--- a/src/tools/rcfile.c
+++ b/src/tools/rcfile.c
@@ -48,6 +48,9 @@ static const char default_rcfile[] =
 "[pressure-vessel-wrap]\n"
 "BOX64_NOGTK=1\n"
 "\n"
+"[ShovelKnight]\n"
+"BOX64_SDL2_JGUID=1\n"
+"\n"
 "[Soma.bin.x86_64]\n"
 "BOX64_DYNAREC_FASTROUND=0\n"
 "\n"
@@ -99,6 +102,7 @@ ENTRYINT(BOX64_JITGDB, jit_gdb, 0, 2, 2)                \
 ENTRYBOOL(BOX64_NOSANDBOX, box64_nosandbox)             \
 ENTRYBOOL(BOX64_EXIT, want_exit)                        \
 ENTRYBOOL(BOX64_LIBCEF, box64_libcef)                   \
+ENTRYBOOL(BOX64_SDL2_JGUID, box64_sdl2_jguid)           \
 ENTRYINT(BOX64_MALLOC_HACK, box64_malloc_hack, 0, 2, 2) \
 
 #ifdef HAVE_TRACE
diff --git a/src/wrapped/wrappedsdl2.c b/src/wrapped/wrappedsdl2.c
index 080e9bd5..cf745119 100644
--- a/src/wrapped/wrappedsdl2.c
+++ b/src/wrapped/wrappedsdl2.c
@@ -801,8 +801,9 @@ EXPORT void* my2_SDL_Vulkan_GetVkGetInstanceProcAddr(x64emu_t* emu)
 
 EXPORT void my2_SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, uint16_t *vend, uint16_t *prod, uint16_t *ver, uint16_t* crc16)
 {
+    uint16_t dummy = 0;
     if(my->SDL_GetJoystickGUIDInfo)
-        my->SDL_GetJoystickGUIDInfo(guid, vend, prod, ver, crc16);
+        my->SDL_GetJoystickGUIDInfo(guid, vend, prod, ver, box64_sdl2_jguid?(&dummy):crc16);
     // fallback
     else {
         uint16_t *guid16 = (uint16_t *)guid.data;
diff --git a/system/box64.box64rc b/system/box64.box64rc
index f02d709e..9d397675 100644
--- a/system/box64.box64rc
+++ b/system/box64.box64rc
@@ -110,6 +110,9 @@ BOX64_EXIT=1
 BOX64_NOGTK=1
 BOX64_EXIT=1
 
+[ShovelKnight]
+BOX64_SDL2_JGUID=1
+
 [Torchlight2.bin.x86_64]
 # Those are safe to use on 7z and give a bit of a boost
 BOX64_DYNAREC_SAFEFLAGS=0