@@ -939,37 +939,59 @@ function setESSystem() {
939
939
940
940
# # @fn ensureSystemretroconfig()
941
941
# # @param system system to create retroarch.cfg for
942
- # # @param shader set a default shader to use (deprecated)
943
- # # @brief Creates a default retroarch.cfg for specified system in `/opt/retropie/configs /$system/retroarch.cfg`.
942
+ # # @brief Deprecated - use defaultRAConfig
943
+ # # @details Creates a default retroarch.cfg for specified system in `$configdir /$system/retroarch.cfg`.
944
944
function ensureSystemretroconfig() {
945
945
# don't do any config work on module removal
946
946
[[ " $md_mode " == " remove" ]] && return
947
947
948
+ # reset "$md_conf_root" to "$configdir" as defaultRAConfig handles this whereas ensureSystemretroconfig
949
+ # expects system to include any subdirectory in the first parameter such as "ports/$system".
950
+ local save_conf_root=" $md_conf_root "
951
+ md_conf_root=" $configdir "
952
+ defaultRAConfig " $1 "
953
+ md_conf_root=" $save_conf_root "
954
+ }
955
+
956
+ # # @fn defaultRAConfig()
957
+ # # @param system system to create retroarch.cfg for
958
+ # # @param ... optional key then value parameters to be used in the config
959
+ # # @brief Creates a default retroarch.cfg for specified system in `$md_root_dir/$system/retroarch.cfg`.
960
+ # # @details Additional default configuration values can be provided as parameters to the function - eg. "fps_show" "true"
961
+ # # as two parameters would add a default entry of fps_show = "true" to the default configuration.
962
+ # # This function uses $md_conf_root as a base, so there is no need to use "ports/$system" for libretro ports as with
963
+ # # the older ensureSystemretroconfig
964
+ function defaultRAConfig() {
965
+ # don't do any config work on module removal
966
+ [[ " $md_mode " == " remove" ]] && return
967
+
948
968
local system=" $1 "
949
- local shader=" $2 "
969
+ shift
970
+ local defaults=(" $@ " )
950
971
951
- if [[ ! -d " $configdir /$system " ]] ; then
952
- mkUserDir " $configdir / $system "
953
- fi
972
+ local config_path= " $md_conf_root /$system "
973
+
974
+ [[ ! -d " $config_path " ]] && mkUserDir " $config_path "
954
975
955
976
local config=" $( mktemp) "
956
977
# add the initial comment regarding include order
957
978
echo -e " # Settings made here will only override settings in the global retroarch.cfg if placed above the #include line\n" > " $config "
958
979
959
980
# add the per system default settings
960
981
iniConfig " = " ' "' " $config "
961
- iniSet " input_remapping_directory" " $configdir / $system / "
982
+ iniSet " input_remapping_directory" " $config_path "
962
983
963
- if [[ -n " $shader " ]]; then
964
- iniUnset " video_smooth" " false"
965
- iniSet " video_shader" " $emudir /retroarch/shader/$shader "
966
- iniUnset " video_shader_enable" " true"
967
- fi
984
+ # add any additional config key / values from function parameters
985
+ local key
986
+ local value
987
+ while read key value; do
988
+ [[ -n " $key " ]] && iniSet " $key " " $value "
989
+ done <<< " ${defaults[@]}"
968
990
969
991
# include the main retroarch config
970
992
echo -e " \n#include \" $configdir /all/retroarch.cfg\" " >> " $config "
971
993
972
- copyDefaultConfig " $config " " $configdir / $system /retroarch.cfg"
994
+ copyDefaultConfig " $config " " $config_path /retroarch.cfg"
973
995
rm " $config "
974
996
}
975
997
0 commit comments