RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    RetroPie - custom runcommand.sh - Find Emulator function

    Scheduled Pinned Locked Moved Help and Support
    runcommand.sh
    2 Posts 1 Posters 262 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      Langerz82
      last edited by Langerz82

      Hello,
      I am trying to create a find emulator function for retropie which automatically loads through the MAME emulators and saves if the emulator loads successful or continue through the emulator list if failed. Here is my main function, the prob is I think I need to properly call the run command to try and launch with each emulator in a loop. Here is my code so far:

      function find_emulator() {
          local mode="$1"
      
          local options=()
          local i=1
          while read line; do
              # convert key=value to array
              local line=(${line/=/ })
              local id=${line[0]}
              [[ "$id" == "" ]] && continue
              [[ "$id" == "default" ]] && continue
      	options+=("$id")
              ((i++))
          done < <(sort "$EMU_SYS_CONF")
          
          local max=$i
          i=0
          while [ $i -lt $max ]; do
      	echo "default_emulator set $mode ${options[$i]}"
      	default_emulator set "$mode" "${options[$i]}"
      	get_sys_command
      	set_save_vars
      	load_mode_defaults
      	echo "$COMMAND"	
      	runcommand "$@" | if grep -ewq "ERROR.*CONTENT LOAD" || grep -wq "supported"; then
                 continue
      	else
                 return
      	fi
              ((i++))
          done
      }
      

      Can anyone tell me the correct way to attempt a launch with each emulator, and is my grep finding text output correct? If you know any help would be appreciated. ^_^

      1 Reply Last reply Reply Quote 0
      • L
        Langerz82
        last edited by Langerz82

        I have completed the emulator finder. For those interested in using, see: https://gist.github.com/Langerz82/ec7c60edd6b02da78018fa113fda27b0

        Hey just a note: The video output will most likely corrupt and show random pixels, this is normal operation and due to sending the emulator process in the background.

        All the best!

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

        Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.