Beta Advanced Emulator Launcher - Multi-emulator frontend for Kodi
(2017-09-08, 10:38)Wintermute0110 Wrote:
(2017-09-08, 04:42)berlinchair Wrote: That sounds like the issue that I was having with mine.
I have tried a few things to get that .sh file to execute (which stops kodi prior to launching the emulator), but to no avail......... sh just for some reason complains that it can't find the file, no matter which directory I put it in Undecided

Hi berlinchair,

Some other guy in the Gamestarter addon thread also is having issues when launching shell scripts in Linux. Since I added the new launching mechanism based on the subprocess module in 0.9.6 I haven't tested launching of shell scripts. In my setup I always launch Retroarch and MAME which are ELF executables (the equivalent to Windows EXEs, in a way of speaking). Tonight I will have a look at this matter.

Also, if you like the technicalities, have a look here regarding the shell argument. Currently, AEL always sets shell = False but maybe for shell scripts in Linux this must be true. If so, I will create a per-launcher setting to enable this flag if I find it must be true for shell launchers.

Yesterday I tried to use a wrapper script in Linux (Kodibuntu) and it works well with 0.9.7-alpah. It should work also with 0.9.6 because the Linux launching code is exactly the same. This is the wrapper script:

Code:
#!/bin/sh
# Script arguments: core_name "$rom$" $categoryID$ $launcherID$ $romID$
#
RETROARCH="/home/kodi/bin/retroarch"
LIBRETRO_PATH="/home/kodi/bin/libretro/"
LOG_FILE="/home/kodi/bin/run_retroarch.log"
LOG_RETROARCH="/home/kodi/bin/retroarch.log"

kodi_rpc()
{
    METHOD="$1"
    json_str="{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"$METHOD\"}\""
    curl -H "Content-type: application/json" -d "$json_str" http://localhost:8080/jsonrpc
}

kodi_rpc_params()
{
    METHOD="$1"
    PARAMS="$2"
    json_str="{\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"$METHOD\",$PARAMS}\""
    curl -H "Content-type: application/json" -d "$json_str" http://localhost:8080/jsonrpc
}

# --- Print some information ---
echo "Retroarch core  \"$1\"" > $LOG_FILE
echo "ROM filename    \"$2\"" >> $LOG_FILE
echo "Category ID     \"$3\"" >> $LOG_FILE
echo "Launcher ID     \"$4\"" >> $LOG_FILE
echo "ROM ID          \"$5\"" >> $LOG_FILE
echo "PID             \"$$\"" >> $LOG_FILE
echo "Parent PID      \"$PPID\"" >> $LOG_FILE

# --- Check if libretro core exists ---
core_file="$LIBRETRO_PATH/$1_libretro.so"
if [ ! -f "$core_file" ]; then
    PARAMS="\"params\":{\"title\" : \"run_retroarch error\", \"message\":\"Core file not found\"}"
    kodi_rpc_params "GUI.ShowNotification" "$PARAMS"
    exit 1
fi
echo "Core \"$core_file\" found." >> $LOG_FILE

# --- Check if retroarch executable exists ---
if [ ! -f "$RETROARCH" ]; then
    PARAMS="\"params\":{\"title\" : \"run_retroarch error\", \"message\":\"Retroarch exectuable not found\"}"
    kodi_rpc_params "GUI.ShowNotification" "$PARAMS"
    exit 1
fi
echo "Retroarch executable \"$RETROARCH\" found." >> $LOG_FILE

# --- In LibreELEC use this ---
# echo "Shutting down Kodi (LibreELEC) ..." >> $LOG_FILE
# systemctl stop kodi

# --- In Kodibuntu kill the Kodi process after shutdown ---
echo "Shutting down Kodi (Linux) ..." >> $LOG_FILE
kodi_rpc "Application.Quit"
sleep 2
killall -9 kodi
killall -9 kodi.bin

echo "Running Retroarch ..." >> $LOG_FILE
$RETROARCH -L $core_file -v "$2" > $LOG_RETROARCH 2>&1

# --- In LibreELEC use this ---
# echo "Starting Kodi (LibreELEC) ..." >> $LOG_FILE
# systemctl start kodi

# --- In Kodibuntu use this ---
echo "Starting Kodi (Linux) ..." >> $LOG_FILE
/usr/bin/kodi &
sleep 2

# --- Tell Kodi to open AEL in the correct Launcher ---
echo "Starting AEL Launcher ..." >> $LOG_FILE
ael_id="\"addonid\":\"plugin.program.advanced.emulator.launcher\""
ael_pars="\"params\":{\"com\":\"SHOW_ROMS\",\"catID\":\"$3\",\"launID\":\"$4\"}"
PARAMS="\"params\":{$ael_id,$ael_pars}"
kodi_rpc_params "Addons.ExecuteAddon" "$PARAMS"

An a launcher example of how to use it:

Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<advanced_emulator_launcher_configuration>
<launcher>
  <name>GameCube (Retroarch wrapper)</name>
  <category>Nintendo</category>
  <year>2001</year>
  <genre>Sixth generation console</genre>
  <developer>Nintendo</developer>
  <rating></rating>
  <plot>The GameCube is a home video game console released by Nintendo in Japan on September 14, 2001; in North America on November 18, 2001; in Europe on May 3, 2002; and in Australia on May 17, 2002. The sixth-generation console is the successor to the Nintendo 64 and competed with Sony Computer Entertainment's PlayStation 2 and Microsoft's Xbox. The GameCube is the first Nintendo console to use optical discs as its primary storage medium. The discs are similar to the miniDVD format; as a result of their smaller size and the console's small disc compartment, the system was not designed to play standard DVDs or audio CDs. The console supports online gaming for a small number of titles via the broadband or modem adapter and connects to the Game Boy Advance via the link cable, allowing players to access exclusive in-game features using the handheld as a second screen and controller.</plot>
  <platform>Nintendo GameCube</platform>
  <application>/home/kodi/bin/retroarch</application>
  <args>dolphin &quot;$rom$&quot; $categoryID$ $launcherID$ $romID$</args>
  <ROM_path>/home/kodi/AEL-ROMs/nintendo-gamecube/</ROM_path>
  <ROM_ext>iso|gcm</ROM_ext>
  <ROM_asset_path>/home/kodi/AEL-assets/nintendo-gamecube</ROM_asset_path>
  <Asset_Prefix>GameCube</Asset_Prefix>
</launcher>
</advanced_emulator_launcher_configuration>

The wrapper script must be place in /home/kodi/bin/run_retroarch.sh and permissions must be 755. Also, for LibreELECT some modifications are required which are commented in the script code. The script checks if Retroarch executable and the core exist. If they don't exist, a warning notification shows up in Kodi. The wrapper script requires the curl command to be installed to use Kodi JSON RPC interface.

There are currently a couple of (minor) problems:

1) Kodi cannot be stopped because AEL uses a blocking launcher. I have to kill the process.

2) When Kodi is restarted is complains that the remote interface cannot be inisialised. This could be a side effect of having to use the kill command with Kodi.

I'm investigating how to solve those problems.
Reply


Messages In This Thread
RE: Advanced Emulator Launcher - Multi-emulator frontend for Kodi - by Wintermute0110 - 2017-09-09, 11:02
Can You create A Sub Category? - by Wild_Tom - 2020-07-13, 04:43
Crash & Lost my launchers? - by eirrocmh - 2020-11-29, 02:25
RE: Crash & Lost my launchers? - by eirrocmh - 2020-12-19, 00:19
Logout Mark Read Team Forum Stats Members Help
Advanced Emulator Launcher - Multi-emulator frontend for Kodi12