Skip to content

Commit 82204f1

Browse files
authored
Merge pull request #3404 from joolswills/defaultRASystemConfig
Add defaultRAConfig to replace ensureSystemretroconfig
2 parents 9939afa + 02ffad4 commit 82204f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+154
-130
lines changed

scriptmodules/helpers.sh

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -939,37 +939,59 @@ function setESSystem() {
939939
940940
## @fn ensureSystemretroconfig()
941941
## @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`.
944944
function ensureSystemretroconfig() {
945945
# don't do any config work on module removal
946946
[[ "$md_mode" == "remove" ]] && return
947947
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+
948968
local system="$1"
949-
local shader="$2"
969+
shift
970+
local defaults=("$@")
950971
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"
954975
955976
local config="$(mktemp)"
956977
# add the initial comment regarding include order
957978
echo -e "# Settings made here will only override settings in the global retroarch.cfg if placed above the #include line\n" >"$config"
958979
959980
# add the per system default settings
960981
iniConfig " = " '"' "$config"
961-
iniSet "input_remapping_directory" "$configdir/$system/"
982+
iniSet "input_remapping_directory" "$config_path"
962983
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[@]}"
968990
969991
# include the main retroarch config
970992
echo -e "\n#include \"$configdir/all/retroarch.cfg\"" >>"$config"
971993
972-
copyDefaultConfig "$config" "$configdir/$system/retroarch.cfg"
994+
copyDefaultConfig "$config" "$config_path/retroarch.cfg"
973995
rm "$config"
974996
}
975997

scriptmodules/libretrocores/lr-81.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function install_lr-81() {
3535

3636
function configure_lr-81() {
3737
mkRomDir "zx81"
38-
ensureSystemretroconfig "zx81"
38+
defaultRAConfig "zx81"
3939

4040
addEmulator 1 "$md_id" "zx81" "$md_inst/81_libretro.so"
4141
addSystem "zx81"

scriptmodules/libretrocores/lr-atari800.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ function configure_lr-atari800() {
3737
mkRomDir "atari800"
3838
mkRomDir "atari5200"
3939

40-
ensureSystemretroconfig "atari800"
41-
ensureSystemretroconfig "atari5200"
40+
defaultRAConfig "atari800"
41+
defaultRAConfig "atari5200"
4242

4343
mkUserDir "$md_conf_root/atari800"
4444
moveConfigFile "$home/.lr-atari800.cfg" "$md_conf_root/atari800/lr-atari800.cfg"

scriptmodules/libretrocores/lr-beetle-lynx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function install_lr-beetle-lynx() {
3434

3535
function configure_lr-beetle-lynx() {
3636
mkRomDir "atarilynx"
37-
ensureSystemretroconfig "atarilynx"
37+
defaultRAConfig "atarilynx"
3838

3939
addEmulator 0 "$md_id" "atarilynx" "$md_inst/mednafen_lynx_libretro.so"
4040
addSystem "atarilynx"

scriptmodules/libretrocores/lr-beetle-ngp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function configure_lr-beetle-ngp() {
4141
local system
4242
for system in ngp ngpc; do
4343
mkRomDir "$system"
44-
ensureSystemretroconfig "$system"
44+
defaultRAConfig "$system"
4545
addEmulator 1 "$md_id" "$system" "$md_inst/mednafen_ngp_libretro.so"
4646
addSystem "$system"
4747
done

scriptmodules/libretrocores/lr-beetle-pce-fast.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function install_lr-beetle-pce-fast() {
4040

4141
function configure_lr-beetle-pce-fast() {
4242
mkRomDir "pcengine"
43-
ensureSystemretroconfig "pcengine"
43+
defaultRAConfig "pcengine"
4444

4545
addEmulator 1 "$md_id" "pcengine" "$md_inst/mednafen_pce_fast_libretro.so"
4646
addSystem "pcengine"

scriptmodules/libretrocores/lr-beetle-pcfx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function install_lr-beetle-pcfx() {
3434

3535
function configure_lr-beetle-pcfx() {
3636
mkRomDir "pcfx"
37-
ensureSystemretroconfig "pcfx"
37+
defaultRAConfig "pcfx"
3838

3939
addEmulator 1 "$md_id" "pcfx" "$md_inst/mednafen_pcfx_libretro.so"
4040
addSystem "pcfx"

scriptmodules/libretrocores/lr-beetle-psx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function install_lr-beetle-psx() {
4242

4343
function configure_lr-beetle-psx() {
4444
mkRomDir "psx"
45-
ensureSystemretroconfig "psx"
45+
defaultRAConfig "psx"
4646

4747
addEmulator 0 "$md_id" "psx" "$md_inst/mednafen_psx_hw_libretro.so"
4848
addSystem "psx"

scriptmodules/libretrocores/lr-beetle-saturn.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function install_lr-beetle-saturn() {
3535

3636
function configure_lr-beetle-saturn() {
3737
mkRomDir "saturn"
38-
ensureSystemretroconfig "saturn"
38+
defaultRAConfig "saturn"
3939

4040
addEmulator 1 "$md_id" "saturn" "$md_inst/mednafen_saturn_libretro.so"
4141
addSystem "saturn"

scriptmodules/libretrocores/lr-beetle-supergrafx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function install_lr-beetle-supergrafx() {
3434

3535
function configure_lr-beetle-supergrafx() {
3636
mkRomDir "pcengine"
37-
ensureSystemretroconfig "pcengine"
37+
defaultRAConfig "pcengine"
3838

3939
addEmulator 0 "$md_id" "pcengine" "$md_inst/mednafen_supergrafx_libretro.so"
4040
addSystem "pcengine"

0 commit comments

Comments
 (0)