libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
9.81k stars 1.78k forks source link

[Feature request] Rewriting the main retroarch.cfg with another config file #13548

Open jayare5 opened 2 years ago

jayare5 commented 2 years ago

Currently there is no way to load a config file for the whole RetroArch and allowing it to persist after closing / restart / relaunch. This could be fixed if we had something similar to core overrides saving / shader saving options, I'd like to see 2 options for the main retroarch.cfg (in Main Menu / Configuration File):

  1. 'Save to Main Configuration' (rewrites the main retroarch.cfg with the config you have loaded)
  2. 'Save Configuration as...' (to save with a custom name, currently we only have an option that just automatically adds a timestamp)

Expected behavior:

  1. Go to Main Menu / Configuration File
  2. 'Save Configuration as...' (name it "config1")
  3. Make any changes to RetroArch.
  4. 'Save Configuration as...' (name it "config2")
  5. Load either config1.cfg or config2.cfg
  6. 'Save to Main Configuration'
  7. Restarting RetroArch will always start with all the settings of that config file.

Actual behavior: If you were to make a new .cfg file and loaded it, it will always go away after restarting.

I would use this to deal with 3 issues:

hizzlekizzle commented 2 years ago

It saves the current in-memory settings to the retroarch.cfg on exit (or when you 'save current config'). If you 'load a config file' and then exit, does that essentially do the same thing?

jayare5 commented 2 years ago

It saves the current in-memory settings to the retroarch.cfg on exit (or when you 'save current config'). If you 'load a config file' and then exit, does that essentially do the same thing?

Good idea :P but no, I just tested it. Doesn't work that way. It only saves on exit if the current loaded config is the standard retroarch.cfg in the standard directory.

If I load another config, and save on exit is enabled, that doesn't rewrite the standard retroarch.cfg.

EDIT: Mind you, when I said Good idea I meant it's a good thing to check that first, but I don't think it would be a good idea if that's how it worked because that could mean accidentally erasing the standard retroarch.cfg by just loading a new one.

It is best that loading is a temporary load, while a new option makes it clear that it's a "permanent" load that will persist after a restart.

davidhedlund commented 1 month ago

It saves the current in-memory settings to the retroarch.cfg on exit (or when you 'save current config'). If you 'load a config file' and then exit, does that essentially do the same thing?

From:

Expected behavior

The settings should be saved to retroarch.cfg.

Actual behavior

The settings have not been saved to retroarch.cfg.

Steps to reproduce the bug

Version/Commit

You can find this information under Information/System Information

Environment information

ToKe79 commented 1 month ago

Hi!

I have this working for Lakka (not yet as build patch, but tested): https://github.com/ToKe79/RetroArch/commit/d623d54f856b05ebc4a713790cf9d847d0e0a26c.

it does what @jayare5 actually requests.

it adds new item in Main Menu -> Configuration -> Save To Default Configuration File (sublabel: Overwrite default configuration file.). When selected, current configuration is always saved to (in Lakka) /storage/.config/retroarch/retroarch.cfg.

So you can load a custom config file and then select this new item and the settings will be written to the default config file.

the part where the config is saved / save path is determined, needs to be modified for other platforms (Windows, Mac, ...). currently this works only on Linux I guess. Therefore all my changes depend on HAVE_LAKKA define, so it does not break other platforms, if I would decide to upstream it as is.

For the code to determine the save path I reused this part:

https://github.com/libretro/RetroArch/blob/fdd010aebc42ba9080204ce5f6b363dd886a6c1c/configuration.c#L3339-L3351

above this part there are code paths for different platforms, but some of them rely on creating empty configuration file (e.g. conf = ...; if (!conf) ...), so i did not reuse all code.

@sonninnos, @hizzlekizzle - maybe you can expand / optimize my code? I'm no coder by job, only a hobbist, so your help is appreciated :-)

davidhedlund commented 1 month ago

Hi!

I have this working for Lakka (not yet as build patch, but tested): ToKe79@d623d54.

it does what @jayare5 actually requests.

it adds new item in Main Menu -> Configuration -> Save To Default Configuration File (sublabel: Overwrite default configuration file.). When selected, current configuration is always saved to (in Lakka) /storage/.config/retroarch/retroarch.cfg.

So you can load a custom config file and then select this new item and the settings will be written to the default config file.

the part where the config is saved / save path is determined, needs to be modified for other platforms (Windows, Mac, ...). currently this works only on Linux I guess. Therefore all my changes depend on HAVE_LAKKA define, so it does not break other platforms, if I would decide to upstream it as is.

For the code to determine the save path I reused this part:

https://github.com/libretro/RetroArch/blob/fdd010aebc42ba9080204ce5f6b363dd886a6c1c/configuration.c#L3339-L3351

above this part there are code paths for different platforms, but some of them rely on creating empty configuration file (e.g. conf = ...; if (!conf) ...), so i did not reuse all code.

@sonninnos, @hizzlekizzle - maybe you can expand / optimize my code? I'm no coder by job, only a hobbist, so your help is appreciated :-)

Good work! I suggest that your code is applied automatically once a config file has been loaded, so the default config file is overwritten when you hit Main Menu -> Quit -- the required way to close RetroArch in Android to save the configuration on quit.

ToKe79 commented 1 month ago

Good work! I suggest that your code is applied automatically once a config file has been loaded, so the default config file is overwritten when you hit Main Menu -> Quit -- the required way to close RetroArch in Android to save the configuration on quit.

Unfortunately not, still on quit saves to the loaded config file - I did not change this behavior (not sure if this is globally wanted). With this patch (currently tested only on Lakka) before Quit you can use

Main Menu → Configuration → Save To Default Configuration File

to overwrite the default retroarch.cfg (in Lakka in ~/.config/retroarch/retrorach.cfg). However there are different code paths for different platforms to determine the save location of the default config file, so this change currently does not work on Android, Mac/OSX, iOS, Windows, ...

To support other platforms, this part needs to be expaded:

https://github.com/ToKe79/RetroArch/blob/d623d54f856b05ebc4a713790cf9d847d0e0a26c/command.c#L1867-L1877

in same way as for example here: https://github.com/libretro/RetroArch/blob/fdd010aebc42ba9080204ce5f6b363dd886a6c1c/configuration.c#L3252-L3360

davidhedlund commented 1 month ago

Good work! I suggest that your code is applied automatically once a config file has been loaded, so the default config file is overwritten when you hit Main Menu -> Quit -- the required way to close RetroArch in Android to save the configuration on quit.

Unfortunately not, still on quit saves to the loaded config file - I did not change this behavior (not sure if this is globally wanted). With this patch (currently tested only on Lakka) before Quit you can use

Main Menu → Configuration → Save To Default Configuration File

to overwrite the default retroarch.cfg (in Lakka in ~/.config/retroarch/retrorach.cfg). However there are different code paths for different platforms to determine the save location of the default config file, so this change currently does not work on Android, Mac/OSX, iOS, Windows, ...

To support other platforms, this part needs to be expaded:

https://github.com/ToKe79/RetroArch/blob/d623d54f856b05ebc4a713790cf9d847d0e0a26c/command.c#L1867-L1877

in same way as for example here:

https://github.com/libretro/RetroArch/blob/fdd010aebc42ba9080204ce5f6b363dd886a6c1c/configuration.c#L3252-L3360

On many Android devices, you can't access certain folders (such as /storage/emulated/0/Android/data/) without special permissions. This makes it tricky to copy a RetroArch configuration file (retroarch.cfg) to its usual location (/storage/emulated/0/Android/data/com.retroarch/files/retroarch.cfg). The result? Settings have to be done manually, taking up precious gaming time.

Your solution will streamline this process and save you the hassle!