RetroArch icon indicating copy to clipboard operation
RetroArch copied to clipboard

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

Open jayare5 opened this issue 3 years ago • 7 comments

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:

  • Currently, if you load a cfg file that has a different playlist folder, it will just break the currently loaded playlists and not show the new ones because they require a restart to update, but restarting means it will load the default cfg and thus the playlists wouldn't change. Instead of fixing that issue alone, it seems easier to just add this option to rewrite the default cfg as a workaround.

  • When I use a different setup, like when I move to a different TV for a day or more, or even visit a friend for example, I may want to use a different config made for this other TV's resolution and stay with those settings even after turning off and on the device. I guess on a PC it's a lot easier, but this is more necessary when using Lakka devices like the Raspberry Pi, where you can't just easily go into the files, plus those are compatible with CRTs too, which require very different configs.

  • Multiple people can share the same install of RetroArch by permanently loading completely customized configurations which can change everything for each person's config preferences / list of games!

jayare5 avatar Jan 25 '22 20:01 jayare5

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?

hizzlekizzle avatar Jan 25 '22 22:01 hizzlekizzle

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.

jayare5 avatar Jan 25 '22 22:01 jayare5

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:

  • https://github.com/libretro/RetroArch/issues/16491

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

  • Main Menu -> Configuration File -> Load Configuration, select your retroarch.cfg file
  • Main Menu -> Quit -- It does not save the settings to retroarch.cfg.

Version/Commit

You can find this information under Information/System Information

  • RetroArch: 1.17.0 apk from retroarch.com

Environment information

  • OS: Android

davidhedlund avatar May 20 '24 10:05 davidhedlund

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 :-)

ToKe79 avatar May 20 '24 20:05 ToKe79

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.

davidhedlund avatar May 21 '24 05:05 davidhedlund

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

ToKe79 avatar May 21 '24 05:05 ToKe79

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!

davidhedlund avatar Jun 11 '24 18:06 davidhedlund