Config swapping in RGUI implemented

I’ve implemented in-RGUI config swapping. This allows full flexibility for users to fine-tune globally, per-game, per system or per sub-system. As expected, nothing is enforced, automated or in general moron-ified. Currently, it’s quite experimental (expect minor bugs), so you can find it on the configswap branch: https://github.com/libretro/RetroArch/tree/configswap

An example on how I expect this to be used is shown below. Note that most of the boilerplate here can be done beforehand by people who distribute builds.

Create desired config files, e.g.: retroarch.cfg n64.cfg psx.cfg snes.cfg snes-particular-game.cfg

One of these configs should be a default (retroarch.cfg). It makes no sense for RetroArch to “remember” the last config used, as it’s a chicken and egg problem. Changing a config with this method takes a few seconds anyways.

In RGUI, you can load configs with RetroArch Config. Where it looks for configs is set by rgui_config_directory. Replacing an entire config file is a very intrusive operation. We have to reset RetroArch into some default state by exiting the game cleanly, and load a dummy core (similar to just retroarch --menu). It makes no sense to replace an entire config mid-game anyways, and it would be impossible to ensure that every little thing is done correctly. Exiting the game is also a good way to ensure that we don’t risk corrupting the game state while doing this.

When you swap configs, make sure that basically every setting is swapped out. If you want configs to be saved automatically for all configs, make sure it’s set in every config. There is no “master config” or anything like that.

Saving new configs from within RGUI is not supported atm. I am not sure how this should be done considering there is no sane way to allow typing in a new filename + browsing to the right directory. It’s also waaaaay too ugly implementation wise, and it won’t work with gamepads anyways (which RGUI must absolutely support 100%). Learn to use the proper file manager/browser, seriously. RGUI is not a replacement for your OS.

Finally if you don’t want to load unrelated games from Load Game (History) (e.g. N64 games with PSX config enabled), use different history files per-config. That way, you can keep history files lean and mean while avoiding mistakes.

I’ve added config saving as well.

Since typing would be a complete nightmare, I use heuristics to figure out a config path. It tries to use a config based on the libretro core used. If it’s been saved before, it’ll append -1, -2, -3.cfg, etc. If it cannot infer, it’ll just create a name based on current time, like screenshots.

Issues with save dir/state dir not being handled correctly on config swap should also be fixed now.