diff --git a/docs/USAGE.md b/docs/USAGE.md index 76650c125..26519f84b 100755 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -210,6 +210,11 @@ Detect libcef and apply malloc_hack settings * 0 : Don't detect libcef * 1 : Detect libcef, and apply MALLOC_HACK=2 if detected (Default) +#### BOX86_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 + #### BOX86_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 942cda0e8..2aadb6b42 100755 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -36,6 +36,7 @@ extern int arm_div; #endif #endif extern int box86_libcef; +extern int box86_sdl2_jguid; extern int dlsym_error; // log dlsym error extern int cycle_log; // if using rolling logs extern int trace_xmm; // include XMM reg in trace? diff --git a/src/main.c b/src/main.c index 3838d69ae..21960bb80 100755 --- a/src/main.c +++ b/src/main.c @@ -84,6 +84,7 @@ int arm_v8 = 0; int box86_dynarec = 0; #endif int box86_libcef = 1; +int box86_sdl2_jguid = 0; int dlsym_error = 0; int cycle_log = 0; int trace_xmm = 0; @@ -539,6 +540,15 @@ void LoadLogEnv() if(!box86_libcef) printf_log(LOG_INFO, "Dynarec will not detect libcef\n"); } + p = getenv("BOX86_SDL2_JGUID"); + if(p) { + if(strlen(p)==1) { + if(p[0]>='0' && p[0]<='1') + box86_sdl2_jguid = p[0]-'0'; + } + if(!box86_sdl2_jguid) + printf_log(LOG_INFO, "BOX86 will workaround the use of SDL_GetJoystickGUIDInfo with 4 args instead of 5\n"); + } p = getenv("BOX86_LOAD_ADDR"); if(p) { if(sscanf(p, "0x%zx", &box86_load_addr)!=1) diff --git a/src/tools/rcfile.c b/src/tools/rcfile.c index 1baf9fb29..3b6503c2f 100644 --- a/src/tools/rcfile.c +++ b/src/tools/rcfile.c @@ -51,6 +51,7 @@ ENTRYSTRING_(BOX86_BOX64, box64) \ ENTRYSTRING_(BOX86_LD_PRELOAD, ld_preload) \ ENTRYBOOL(BOX86_NOSANDBOX, box86_nosandbox) \ ENTRYBOOL(BOX86_LIBCEF, box86_libcef) \ +ENTRYBOOL(BOX86_SDL2_JGUID, box86_sdl2_jguid) \ ENTRYINT(BOX86_MALLOC_HACK, box86_malloc_hack, 0, 2, 2) \ #ifdef HAVE_TRACE diff --git a/src/wrapped/wrappedsdl2.c b/src/wrapped/wrappedsdl2.c index 6b6ff68ee..074a9615f 100755 --- a/src/wrapped/wrappedsdl2.c +++ b/src/wrapped/wrappedsdl2.c @@ -868,13 +868,14 @@ EXPORT void* my2_SDL_LoadFunction(x86emu_t* emu, void* handle, void* name) EXPORT void my2_SDL_GetJoystickGUIDInfo(x86emu_t* emu, uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint16_t* vendor, uint16_t* product, uint16_t* version, uint16_t* crc16) { (void)emu; + uint16_t dummy = 0; SDL_JoystickGUID_Helper guid; guid.u[0] = a; guid.u[1] = b; guid.u[2] = c; guid.u[3] = d; if(my->SDL_GetJoystickGUIDInfo) { - my->SDL_GetJoystickGUIDInfo(guid.guid, vendor, product, version, crc16); + my->SDL_GetJoystickGUIDInfo(guid.guid, vendor, product, version, box86_sdl2_jguid?(&dummy):crc16); } else { // dummy, set everything to "unknown" if (guid.u16[1]==0x0000 && guid.u16[3]==0x0000 && guid.u16[5]==0x0000) diff --git a/system/box86.box86rc b/system/box86.box86rc index 146a4dae6..39259ff0c 100644 --- a/system/box86.box86rc +++ b/system/box86.box86rc @@ -62,6 +62,9 @@ BOX86_DYNAREC_SAFEFLAGS=0 BOX86_DYNAREC_BIGBLOCK=2 BOX86_DYNAREC_FORWARD=512 +[ShovelKnight] +BOX86_SDL2_JGUID=1 + [sof-bin] BOX86_LD_PRELOAD=libX11.so.6