Closed notimaginative closed 1 year ago
I made suggested improvements. It probably could be a little cleaner still, but looking at it with vague python knowledge, it's the best I can do without it getting into hard-to-read/understand territory.
This is now rebased against the current develop
branch with conflicts resolved and should be safe to merge.
This probably breaks joystick settings on old FSO builds. The comment which explains why the mapping logic was removed is a misunderstanding. The code was never meant to handle removed joysticks, instead the code assumes that the user selected joystick is still connected.
What it does check is whether FSO sees the same GUID for the selected joystick as Knossos and if it doesn't (which is the case for very old FSO builds), it tries to map the GUID that Knossos sees to the one it gets from FSO. Without this mapping, old FSO builds will just ignore the GUID setting since it will never see the GUID written to fs2_open.ini
. This is also the reason the joystick settings are rewritten before each FSO launch since the correct GUID for the same device depends on the FSO version.
The root cause here is SDL2: For whatever reason, they changed how the GUID is generated which means that an old SDL2 lib will give different GUIDs for the same device compared to a newer SDL2 lib.
This matters because the GUID for the joystick selection screen comes from Knossos' SDL2 lib which won't necessarily match tue SDL2 lib that's bundled with FSO since different FSO versions bundle different SDL2 versions.
The best solution here would be to just deprecate the affected FSO builds but that wasn't simple back when I wrote this code because they weren't as old as they are now and IIRC even now some mods (like Diaspora) are configured to use one of the affected builds.
I'm aware of the SDL issues, but that's not something I was trying to address. The problem with the code was that it could enter into a config error loop preventing the launch of FSO. These changes have gone through a great deal of testing and I don't recall any issues with older builds, though I can't confirm how far back anyone went with it.
In my opinion Knossos was just doing far too much work here when it should have left such error handing up to FSO. Even older builds should have been able handle joystick issues if allowed to do so. Newer builds are even better at it. Even if it doesn't end up being able to use the exact same joystick it should be able to fallback to something that is usable or at least not prevent you from playing the game.