News for hackers. Stuff that matters.
Re:Fixing stutters in Papers Please on Linux by nemetroid on Sunday January 02, 2022 @10:40AM (#29769551)
SDL has three methods for detecting input devices [1]: udev, inotify, and, as a fallback, enumerating /dev/input.

It seems like Papers, Please uses a statically linked version of SDL, without udev or inotify support compiled in.

1: https://github.com/libsdl-org/SDL/blob/d0de4c625ad26ef540166...

Re:Fixing stutters in Papers Please on Linux by Sjonny on Sunday January 02, 2022 @11:07AM (#29769859)
I've been wondering.. is it possible to write something to override the statically linked functions? In this case, most (if not all) functions have an SDL_ prefix. Would it be possible to LD_PRELOAD a library that loads a shared version of SDL and goes over all the function pointers to move them point them to a new location? Is there a tool for this?
Re:Fixing stutters in Papers Please on Linux by cesarb on Sunday January 02, 2022 @11:13AM (#29769940)
> I've been wondering.. is it possible to write something to override the statically linked functions?

SDL does have a built-in way to do that trick. A quick web search tells me it's called SDL_DYNAMIC_API.

Re:Fixing stutters in Papers Please on Linux by Sjonny on Sunday January 02, 2022 @11:35AM (#29770151)
cool, I never knew! Somehow the game I thought it would add a feature is still lacking it. For some reason rumble on my xbox joystick with Enter the Gungeon never worked. I thought it was because of an old SDL version, because experimentation showed that. But by using the SDL_DYNAMIC_API env and loading my system SDL the game still not added rumble to my joystick. Ohwell.
Re:Fixing stutters in Papers Please on Linux by seba_dos1 on Sunday January 02, 2022 @01:35PM (#29771937)
SDL_DYNAMIC_API is a relatively recent addition (IIRC 2014), so static SDL2 builds from before that won't work this way.
Re:Fixing stutters in Papers Please on Linux by ds- on Sunday January 02, 2022 @03:28PM (#29773458)
It looks like SDL's public symbols are all global in lime.ndll so LD_PRELOADing SDL should do what you want. Of course it is possible that lime.ndll was built with -fno-semantic-interposition or equivalent in which case the functions might be called directly without going through the dynamic linker or even (partially) inlined.
Re:Fixing stutters in Papers Please on Linux by touisteur on Sunday January 02, 2022 @11:13AM (#29769937)
Well if you know where to fork, you could use Intel Pin and divert the CFG, favorite tool for binary 'patching'.

Edit: though here if it's a problem of file enumeration and access, I'd probably just LD_PRELOAD something to bypass libc file access functions and return the same result than the first time, with no delay.

Re:Fixing stutters in Papers Please on Linux by bregma on Sunday January 02, 2022 @03:58PM (#29773796)
Static linking means the features of the Linux dynamic loader, like using the environment variable LD_PRELOAD to pre-load a dynamic library, are not going to have any effect.