diff --git a/emu-configs/defaults/retrodeck/input_validation.cfg b/emu-configs/defaults/retrodeck/input_validation.cfg new file mode 100644 index 00000000..5c0a35e7 --- /dev/null +++ b/emu-configs/defaults/retrodeck/input_validation.cfg @@ -0,0 +1,5 @@ +uuddlrlrstart^set_setting_value /var/config/retrodeck/retrodeck.cfg developer_options true retrodeck +uuddlrlrstart^echo Visit the Configurator to behold your new-found powers. +uuddlrlrstart^echo But beware, with great power comes great responsibility... +gameovermangameover^set_setting_value /var/config/retrodeck/retrodeck.cfg developer_options false retrodeck +gameovermangameover^echo You have relinquished your powers in the name of saftey. \ No newline at end of file diff --git a/functions.sh b/functions.sh index 56158710..40f161a6 100644 --- a/functions.sh +++ b/functions.sh @@ -631,6 +631,17 @@ check_network_connectivity() { fi } +validate_input() { + while IFS="^" read -r input action + do + if [[ "$input" == "$1" ]]; then + # $action line must be completely literal in the $input_validation file. No shell expansion or extra characters. + $action + input_validated="true" + fi + done < $input_validation +} + update_rd_conf() { # This function will import a default retrodeck.cfg file and update it with any current settings. This will allow us to expand the file over time while retaining current user settings. # USAGE: update_rd_conf diff --git a/global.sh b/global.sh index 0f29dfc2..472ed4c0 100755 --- a/global.sh +++ b/global.sh @@ -13,6 +13,7 @@ rd_update_patch="/var/config/retrodeck/rd_update.patch" bios_checklist="$emuconfigs/defaults/retrodeck/bios_checklist.cfg" # A config file listing BIOS file information that can be verified compression_targets="$emuconfigs/defaults/retrodeck/compression_targets.cfg" # A config file containing supported compression types per system easter_egg_checklist="$emuconfigs/defaults/retrodeck/easter_egg_checklist.cfg" # A config file listing days and times when special splash screens should show up +input_validation="$emuconfigs/defaults/retrodeck/input_validation.cfg" # List of valid CLI inputs splashscreen_dir="/var/config/emulationstation/.emulationstation/resources/graphics/extra-splashes" # The default location of extra splash screens current_splash_file="/var/config/emulationstation/.emulationstation/resources/graphics/splash.svg" # The active splash file that will be shown on boot default_splash_file="/var/config/emulationstation/.emulationstation/resources/graphics/splash-orig.svg" # The default RetroDECK splash screen diff --git a/retrodeck.sh b/retrodeck.sh index 634c38b7..8cf77def 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -96,7 +96,10 @@ https://retrodeck.net exit 1 ;; *) - echo "Please specify a valid option. Use -h for more information." + validate_input "$i" + if [[ ! $input_validated == "true" ]]; then + echo "Please specify a valid option. Use -h for more information." + fi ;; esac done