Update Vita3k functions in Configurator and prepare_emulator.sh

Add network checks for resetting emus that require it
This commit is contained in:
icenine451 2023-12-11 10:30:35 -05:00
parent 8f8d09fa1f
commit 621e55a870
4 changed files with 55 additions and 40 deletions

View file

@ -103,6 +103,11 @@ primehackqtconf="/var/config/primehack/Qt.ini"
rpcs3conf="/var/config/rpcs3/config.yml"
rpcs3vfsconf="/var/config/rpcs3/vfs.yml"
# Vita3k config files
vita3kconf="/var/data/Vita3K/config.yml"
vita3kusrconfdir="$bios_folder/Vita3K/Vita3K"
# We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions
if [ -f "$HOME/retrodeck/.lock" ]
then

View file

@ -37,7 +37,7 @@ set_setting_value() {
fi
;;
"rpcs3" ) # This does not currently work for settings with a $ in them
"rpcs3" | "vita3k" ) # This does not currently work for settings with a $ in them
if [[ -z $current_section_name ]]; then
sed -i 's^\^'"$setting_name_to_change"': .*^'"$setting_name_to_change"': '"$setting_value_to_change"'^' "$1"
else
@ -72,7 +72,7 @@ get_setting_name() {
echo ''"$current_setting_line"'' | grep -o -P '(?<=name\=\").*(?=\" value)'
;;
"rpcs3" )
"rpcs3" | "vita3k" )
echo "$current_setting_line" | grep -o -P "^\s*?.*?(?=\s?:\s?)" | sed -e 's/^[ \t]*//;s^\\ ^ ^g'
;;
@ -116,7 +116,7 @@ get_setting_value() {
fi
;;
"rpcs3" ) # For files with this syntax - setting_name: setting_value
"rpcs3" | "vita3k" ) # For files with this syntax - setting_name: setting_value
if [[ -z $current_section_name ]]; then
echo $(grep -o -P "(?<=$current_setting_name: ).*" "$1")
else

View file

@ -668,30 +668,25 @@ prepare_emulator() {
fi
if [[ "$emulator" =~ ^(vita3k|Vita3K|all)$ ]]; then
# TODO: do a proper script
# This is just a placeholder script to test the emulator's flow
if [[ "$action" == "reset" ]]; then # Run reset-only commands
echo "----------------------"
echo "Initializing Vita3K"
echo "----------------------"
# extracting the emulator
# NOTE: the emulator is writing in "." so it must be placed in the rw filesystem. A symlink of the binary is already placed in /app/bin/Vita3K
rm -rf "/var/data/Vita3K"
mkdir -p "/var/data/Vita3K"
unzip "/app/retrodeck/vita3k.zip" -d "/var/data/Vita3K"
chmod +x "/var/data/Vita3K/Vita3K"
rm -f "/var/data/Vita3K/update-vita3k.sh"
# copying config file
cp -fvr "$emuconfigs/vita3k/config.yml" "/var/data/Vita3K"
# TODO: this step is to be done properly: Replacing RETRODECKHOMEDIR placeholder
sed -i 's#RETRODECKHOMEDIR#'$rdhome'#g' "/var/data/Vita3K/config.yml"
# copying vita user config
cp -fvr "$emuconfigs/vita3k/ux0" "$bios_folder/Vita3K/Vita3K"
# prep saves folder
dir_prep "$saves_folder/psvita/vita3k" "$bios_folder/Vita3K/Vita3K/ux0/user/00/savedata"
if [[ $multi_user_mode == "true" ]]; then # Multi-user actions
echo "Figure out what Vita3k needs for multi-user"
else # Single-user actions
# NOTE: the emulator is writing in "." so it must be placed in the rw filesystem. A symlink of the binary is already placed in /app/bin/Vita3K
rm -rf "/var/data/Vita3K"
mkdir -p "/var/data/Vita3K"
unzip "/app/retrodeck/vita3k.zip" -d "/var/data/Vita3K"
chmod +x "/var/data/Vita3K/Vita3K"
rm -f "/var/data/Vita3K/update-vita3k.sh"
cp -fvr "$emuconfigs/vita3k/config.yml" "/var/data/Vita3K" # Emulator config
cp -fvr "$emuconfigs/vita3k/ux0" "$bios_folder/Vita3K/Vita3K" # User config
set_setting_value "$vita3kconf" "pref-path" "$rdhome/bios/Vita3K/Vita3K/" "vita3k"
fi
# Shared actions
dir_prep "$saves_folder/psvita/vita3k" "$bios_folder/Vita3K/Vita3K/ux0/user/00/savedata" # Multi-user safe?
# Installing firmware
# TODO: at the moment this is here instead of a tool because it seems like it cannot run without Firmware
@ -699,7 +694,10 @@ prepare_emulator() {
curl "http://dus01.psp2.update.playstation.net/update/psp2/image/2019_0924/sd_8b5f60b56c3da8365b973dba570c53a5/PSP2UPDAT.PUP?dest=us" -po /tmp/PSP2UPDAT.PUP
Vita3K --firmware /tmp/PSVUPDAT.PUP
Vita3K --firmware /tmp/PSP2UPDAT.PUP
if [[ "$action" == "postmove" ]]; then # Run only post-move commands
dir_prep "$saves_folder/psvita/vita3k" "$bios_folder/Vita3K/Vita3K/ux0/user/00/savedata" # Multi-user safe?
set_setting_value "$vita3kconf" "pref-path" "$rdhome/bios/Vita3K/Vita3K/" "vita3k"
fi
fi
if [[ "$emulator" =~ ^(mame|MAME|all)$ ]]; then

View file

@ -78,6 +78,7 @@ source /app/libexec/global.sh
# - Reset Primehack
# - Reset RPCS3
# - Reset Ryujinx
# - Reset Vita3k
# - Reset XEMU
# - Reset Yuzu
# - Reset All Emulators
@ -1004,17 +1005,23 @@ configurator_reset_dialog() {
"Primehack" "Reset the Metroid Prime emulator Primehack to default settings" \
"RPCS3" "Reset the PS3 emulator RPCS3 to default settings" \
"Ryujinx" "Reset the Switch emulator Ryujinx to default settings" \
"Vita3k" "Reset the PS Vita emulator Vita3k to default settings" \
"XEMU" "Reset the XBOX emulator XEMU to default settings" \
"Yuzu" "Reset the Switch emulator Yuzu to default settings" )
case $emulator_to_reset in
"RetroArch" | "XEMU" ) # Emulators that require network access
if [[ $(configurator_reset_confirmation_dialog "$emulator_to_reset" "Are you sure you want to reset the $emulator_to_reset emulator to default settings?\n\nThis process cannot be undone.") == "true" ]]; then
prepare_emulator "reset" "$emulator_to_reset" "configurator"
configurator_process_complete_dialog "resetting $emulator_to_reset"
"RetroArch" | "Vita3k" | "XEMU" ) # Emulators that require network access
if [[ $(check_network_connectivity) == "true" ]]; then
if [[ $(configurator_reset_confirmation_dialog "$emulator_to_reset" "Are you sure you want to reset the $emulator_to_reset emulator to default settings?\n\nThis process cannot be undone.") == "true" ]]; then
prepare_emulator "reset" "$emulator_to_reset" "configurator"
configurator_process_complete_dialog "resetting $emulator_to_reset"
else
configurator_generic_dialog "RetroDeck Configurator - RetroDECK: Reset" "Reset process cancelled."
configurator_reset_dialog
fi
else
configurator_generic_dialog "RetroDeck Configurator - RetroDECK: Reset" "Reset process cancelled."
configurator_generic_dialog "RetroDeck Configurator - RetroDECK: Reset" "Resetting this emulator requires active network access.\nPlease try again when you are connected to an Internet-capable network.\n\nReset process cancelled."
configurator_reset_dialog
fi
;;
@ -1037,17 +1044,22 @@ configurator_reset_dialog() {
;;
"Reset All Emulators" )
if [[ $(configurator_reset_confirmation_dialog "all emulators" "Are you sure you want to reset all emulators to default settings?\n\nThis process cannot be undone.") == "true" ]]; then
(
prepare_emulator "reset" "all"
) |
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Finishing Initialization" \
--text="RetroDECK is finishing the reset process, please wait."
configurator_process_complete_dialog "resetting all emulators"
if [[ $(check_network_connectivity) == "true" ]]; then
if [[ $(configurator_reset_confirmation_dialog "all emulators" "Are you sure you want to reset all emulators to default settings?\n\nThis process cannot be undone.") == "true" ]]; then
(
prepare_emulator "reset" "all"
) |
zenity --icon-name=net.retrodeck.retrodeck --progress --no-cancel --pulsate --auto-close \
--window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \
--title "RetroDECK Finishing Initialization" \
--text="RetroDECK is finishing the reset process, please wait."
configurator_process_complete_dialog "resetting all emulators"
else
configurator_generic_dialog "RetroDeck Configurator - RetroDECK: Reset" "Reset process cancelled."
configurator_reset_dialog
fi
else
configurator_generic_dialog "RetroDeck Configurator - RetroDECK: Reset" "Reset process cancelled."
configurator_generic_dialog "RetroDeck Configurator - RetroDECK: Reset" "Resetting all emulators requires active network access.\nPlease try again when you are connected to an Internet-capable network.\n\nReset process cancelled."
configurator_reset_dialog
fi
;;