Skip to content

Commit

Permalink
Added BOX86_SDL2_JGUID, a workaround for game using old SDL_GetJoysti…
Browse files Browse the repository at this point in the history
…ckGUIDInfo funciton on recent wrapped SDL2 (backported from box64)
  • Loading branch information
ptitSeb committed Oct 11, 2023
1 parent 6e51e73 commit a0a3389
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
10 changes: 10 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/tools/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/wrapped/wrappedsdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions system/box86.box86rc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a0a3389

Please sign in to comment.