RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Individual per game profiles for pcsx2 [x86 only]

    Scheduled Pinned Locked Moved Ideas and Development
    pcsx2runcommandps2
    6 Posts 2 Posters 4.3k 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.
    • parasvenP
      parasven
      last edited by parasven

      Since the pcsx2 emulator does not natively support per game profiles i came up with this custom solution to make it possible to use indivudual configs.

      What it does:

      • Extracts the ps exe id from the passed rom.
      • Creates a folder based on the titlename + titleid under the directory "/opt/retropie/configs/ps2/game_configs" and copy over the default config inis to the folder. Example Foldername: Resident_Evil_-_Outbreak_SLUS20765.
      • Changes the SettingsFolder to the newly created folder.

      I chose to use psisotool since it does not matter then what the rom file is named, because the title name and titleid are extracted from within the iso itself.

      This was tested with the latest version of pcsx2 1.7.0

      Requirements:

      • Ubuntu install of Retopie since pcsx2 does not run on arm devices.
      • psisotool by CaptainCPS Get it from here https://github.com/parasven/PS_ISO_Tool
      • Installed pcsx2(Retropie Setup installs it via ppa)

      Compile psisotool:

      1. git clone https://github.com/parasven/PS_ISO_Tool
      2. make

      The compiled tool will then reside in the bin folder.
      Compliation on Ubuntu 20.04 worked without problems for me.

      I have also added make install and make uninstall to the Makefile.

      To install the tool to the system use:

      • sudo make install

      To uninstall it use:

      • sudo make uninstall

      The tool will be installed to "/usr/local" so it does not collide with any binaries that are installed via repositories.
      The makefile can be seen here: https://github.com/parasven/PS_ISO_Tool/blob/master/Makefile

      Note: If you do not install it to the system you will have to edit the variable psiso_tool_bin="$(which psiso_tool)" so it points to where your compiled psisotool resides
      Note2: Getting the gamenames via psisotoll will not work if not installed because the textdatabasefiles cant be found by the tool


      set_settingfolder_pcsx2.sh:

      #!/bin/bash
      ## This script makes it possible to user individual per game configurationfiles for PCSX2.
      ## With the default install PCSX2 will only use the default configfolder under "$HOME/.config/PCSX2/inis/"
      ## 20171026sh
      ## Edit 20122021: Added getting the gamename from psisotool. If the name couldnt be found it uses the romname that is passed from runcommand as second parameter
      ##                Getting the Serial from psisotool now gets the cleaned up version of the Serial which looks nicer
      ##
      ## Example for runcommand-onstart.sh Skript:
      ## # get the full path filename of the ROM
      ## rom=$3
      ## rom_with_extension="${rom##*/}"
      ## rom_without_extension="${rom_with_extension%.*}"
      ## /opt/Retropie_Skripte/set_settingfolder_pcsx2.sh "$rom" "$rom_without_extension"
      
      
      pcsx2_ini="$HOME/.config/PCSX2/PCSX2-reg.ini"
      game_configpath="/opt/retropie/configs/ps2/game_configs"
      pcsx2_config_default="$HOME/.config/PCSX2/inis"
      psiso_tool_bin="$(which psiso_tool)"
      ## Get titleid and titlename with psiso_tool
      title_id=$($psiso_tool_bin --ps2  --verbose "$1" | grep "Getting title for:" | awk '{printf $4}')
      title=$($psiso_tool_bin --ps2 "$1" | grep "TITLE:" | cut -d "(" -f2 | cut -d ")" -f1 | xargs)
      
      ## Check if $title is empty and fall back to second parameter for naming
      if [ -z "$title" ]
      then
              gamename=${2//" "/_}
      else
              gamename=${title//" "/_}
      fi
      
      
      ## If no parameter was passed set default path and exit
      if [[ ! $1 ]]
      then
              ## Exchange the configpath
              sed -i s@"^SettingsFolder=.*"@"SettingsFolder=\"$pcsx2_config_default\""@g "$pcsx2_ini"
              exit
      fi
      
      
      ## When the config folder does not exist then create it and copy over the default inis from the default ini folder
      if [[ ! -e "$game_configpath/${gamename}_${title_id}"  ]]
      then
              ## Create folder based on the ps2 exe id
              mkdir -p "$game_configpath/${gamename}_${title_id}/"
              ## Copy over the default inis from default directory for a start.
      
              for ini in $(ls "$pcsx2_config_default")
              do
                      echo $ini
                      if [[ $ini == *PAD* ]]
                      then
                              ln -s "$pcsx2_config_default"/$ini "$game_configpath/${gamename}_${title_id}/"
                      else
                              cp -a "$pcsx2_config_default"/$ini "$game_configpath/${gamename}_${title_id}/"
                      fi
      
              done
      fi
      
      ## Make sure the customsettingsfolder get used actually used.
      sed -i s@"^UseDefaultSettingsFolder=enabled"@"UseDefaultSettingsFolder=disabled"@g "$pcsx2_ini"
      ## Exchange the configpath
      sed -i s@"^SettingsFolder=.*"@"SettingsFolder=\"$game_configpath/${gamename}_${title_id}\""@g "$pcsx2_ini"
      

      Modifications to :/opt/retropie/configs/all/runcommand-onstart.sh

      # get the system name
      system=$1
      # get the full path filename of the ROM
      rom=$3
      rom_with_extension="${rom##*/}"
      rom_without_extension="${rom_with_extension%.*}"
      
      ## Call the set_settingfolder_pcsx2.sh if the ps2 emulator is run. The Script modifiys the PCSX2 config to point to the new settingfolder based on the games executable id and titlename
      if [[ "$system" == "ps2" ]]
      then
              ## Needs to pass the romfullpath to the script
              /opt/Retropie_Skripte/set_settingfolder_pcsx2.sh "$rom" "$rom_without_extension"
      fi
      


      Old Scripts below incase someone needs them


      set_settingfolder_pcsx2.sh:

      #!/bin/bash
      ## This script makes it possible to user individual per game configurationfiles for PCSX2.
      ## With the default install PCSX2 will only use the default configfolder under "$HOME/.config/PCSX2/inis_1.4.0/"
      ## 20171026sh
      
      
      pcsx2_ini="$HOME/.config/PCSX2/PCSX2-reg.ini"
      game_configpath="/opt/retropie/configs/ps2/game_configs"
      pcsx2_config_default="$HOME/.config/PCSX2/inis_1.4.0"
      psiso_tool_bin="/opt/Retropie_Skripte/additional_binaries_and_sources/psiso_tool/bin/psiso_tool"
      
      
      
      ## If no parameter was passed set default path and exit
      if [[ ! $1 ]]
      then
              ## Exchange the configpath
              sed -i s@"^SettingsFolder=.*"@"SettingsFolder=\"$pcsx2_config_default\""@g "$pcsx2_ini"
              exit
      fi
      
      
      ## Get Titleid with psiso_tool
      title_id=$($psiso_tool_bin --ps2  "$1" | grep "TITLE ID:" | awk '{printf $4}')
      
      ## When the config folder does not exist then create it and copy over the default inis from the default ini folder
      if [[ ! -e "$game_configpath/$title_id"  ]]
      then
              ## Create folder based on the ps2 exe id
              mkdir -p "$game_configpath/$title_id/"
              ## Copy over the default inis from default directory for a start.
              cp -a "$pcsx2_config_default"/*.ini "$game_configpath/$title_id/"
      fi
      
      ## Make sure the customsettingsfolder get used actually used.
      sed -i s@"^UseDefaultSettingsFolder=enabled"@"UseDefaultSettingsFolder=disabled"@g "$pcsx2_ini"
      ## Exchange the configpath
      sed -i s@"^SettingsFolder=.*"@"SettingsFolder=\"$game_configpath/$title_id\""@g "$pcsx2_ini"
      

      Note:
      You will have to edit the path in variable "psiso_tool_bin" to point to your compiled ps_iso_tool
      Everything else should be generic enough to work out of the box.

      Modifications to :/opt/retropie/configs/all/runcommand-onstart.sh

      # get the system name
      system=$1
      # get the full path filename of the ROM
      rom=$3
      
      ## Call the set_settingfolder_pcsx2.sh if the ps2 emulator is run. The Script modifiys the PCSX2 config to point to the new settingfolder based on the games executable id
      if [[ "$system" == "ps2" ]]
      then
              ## Needs to pass the romfullpath to the script
              /opt/Retropie_Skripte/set_settingfolder_pcsx2.sh "$rom"
      fi
      

      Note:
      Obviously you will need the modify the path to the script to point where it is located on your system.

      https://github.com/parasven

      meleuM 1 Reply Last reply Reply Quote 2
      • meleuM
        meleu @parasven
        last edited by

        @parasven after -onstart execution doesn't runcommand.sh try to launch the game again?

        • Useful topics
        • joystick-selection tool
        • rpie-art tool
        • achievements I made
        parasvenP 1 Reply Last reply Reply Quote 0
        • parasvenP
          parasven @meleu
          last edited by

          @meleu
          What do you mean by "try to launch the game again"?
          As far as i saw the -onstart script get executed and after that the normal runcommand finishes its job and starts the emulator?

          What i was originally trying to do is:
          Modify the passed "startcommand" within -onstart and then execute the emulator with the modified "startcommand"

          https://github.com/parasven

          meleuM 1 Reply Last reply Reply Quote 0
          • meleuM
            meleu @parasven
            last edited by

            @parasven oh. sorry, I misunderstood your script. I thought it was to to actually launch the game. Now everything is clear.

            Thanks for sharing this trick!

            I'll add it to the "useful topics" post. ;-)

            • Useful topics
            • joystick-selection tool
            • rpie-art tool
            • achievements I made
            parasvenP 1 Reply Last reply Reply Quote 0
            • parasvenP
              parasven @meleu
              last edited by

              @meleu
              No worries, thanks for hinting to the"Useful topics" havent seen that thread before.
              I will definatly take a look into that.
              Btw. i found your joystick selection script quite handy.

              Do you by any change know if there is a guide or wikipage, in case i would want to create a scriptmodule?

              https://github.com/parasven

              meleuM 1 Reply Last reply Reply Quote 0
              • meleuM
                meleu @parasven
                last edited by

                @parasven said in Individual per game profiles for pcsx2 [x86 only]:

                Do you by any change know if there is a guide or wikipage, in case i would want to create a scriptmodule?

                I answered this kind of question here.

                • Useful topics
                • joystick-selection tool
                • rpie-art tool
                • achievements I made
                1 Reply Last reply Reply Quote 1
                • 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.