Using Retro Arch in Openelec with Advanced Launcher

Hello everyone, first of all, I would like to thank everyone involved in this amazing system, I truly value all of the hard work you’ve put into this!

I’m attempting to set everything up within Openelec. I had originally set everything up using Zaggash’s addon of Retroarch (here http://sourceforge.net/projects/zaggxbmcaddons/) which for the most part worked great. Well, after several days of trial and error, I was able to get roms from NES to PSX to work great. As long as I was only using one controller. I could never seem to get a second controller working properly. Openelec detected my controllers, when I was in the rGUI menu mapping inputs, I could use either controller to run joyconfig, but I couldn’t get both controllers to operate while in a game.

That’s when this wonderful person shared how they were able to get the retroarch 1.2.2 to install as an addon for Openelec (http://openelec.tv/forum/128-addons/64970-retroarch-addon-32-64-bits?start=600#145242) which I was able to install without an issue! The new menu works amazingly, and the individual controller mapping worked perfectly! I set it up one time and it worked everytime I tried it! I could load games from the menu that played great, I was even able to get the overlays working!

However, now I’m stuck trying to get Advanced Launcher to run the games. Previously, I would add an emulator (which I would just link to the retroarch.sh in the bin directory) with an argument like this:

snes9x "%ROM%"

but when I try that now, pointing to the only “retroarch.sh” I can find in this system, but no matter what I set this to, everytime I go to load a rom, it just loads the retroarch menu with nothing added and no cores loaded. Is there anyone that perhaps knows a way to fix this?

Thanks!

I don’t have any experience with OpenElec addons, but you probably need to pass your arguments to advanced launcher, like ‘-L /usr/lib/libretro/snes9x.so -c /path/to/custom/config.cfg "%ROM%’

Thanks for your reply! Do you know if I need to encase either of those paths with quotes? Or would that not matter? I’m trying it either way, but I did find a setting within Retroarch that said something like 'start with core loaded", do you think that could be preventing advanced launcher from working?

Thank you again!

You’ll need to enclose paths with quotes if they have spaces in them (i.e., unlike in Windows). I’m not sure which option that would be, but you could certainly try disabling it. /shrug

I actually managed to get Advanced Launcher to work! I’ll post what I did, just in case someone happens to find this thread. I know this isn’t exactly relevant to this forum, and I apologize if I’ve offended anyone. Please note, back up this file before you make any changes!

Using the addon I linked to in my OP, you’re going to want to edit one file, /storage/.kodi/addons/plugin.retroarch/retroarch.sh I’ll post my file, but please note, I barely know (if I even know) what I’m doing :slight_smile:

###To the best of my knowledge, this bit of code is only needed on the first run, it was causing errors
#VER=$1
#ADDON_DIR=$2
#cd $ADDON_DIR
#[ -f retroarch-install-$VER.sh ] && ./retroarch-install-$VER.sh && mv retroarch-install-$VER.sh ~/retroarch

BASE_DIR=/storage/retroarch/default
RETROARCH=$BASE_DIR/bin/retroarch
CORES=$BASE_DIR/libretro/cores

if [ ! "$#" = "2" ];
then
  echo "Usage: `basename $0` core /path/to/romfile"
  echo "Example: `basename $0` snes9x /storage/mario.sfc"
  echo
  echo "Available cores:"
  echo " `ls -1 $CORES/*.so  |  cut -d - -f 1 | cut -d / -f 7`"
  echo
  exit 1
fi

if [ ! -f $CORES/$1_libretro.so ]; then
  echo "Core $1 not found, exiting."
  exit 1
fi

if [ ! -f "$2" ]; then
  echo "Rom file $2 not found, exiting."
  exit 1
fi

if [ -f "$2.cfg" ]; then
  echo "Config file for `basename "$2"` found, using."
  EXTRAFLAG="--appendconfig "$2.cfg""
fi

###If you wish to kill Kodi on each game launch, uncomment these lines and comment out the next set of code.
#systemctl stop xbmc.service
#systemctl stop kodi.service
#LD_LIBRARY_PATH=$BASE_DIR/lib $RETROARCH -c $BASE_DIR/config/retroarch.cfg $EXTRAFLAG -L $CORES/$1_libretro.so "$2"
#systemctl start xbmc.service
#systemctl start kodi.service

pgrep kodi.bin | xargs kill -SIGSTOP
sleep 1
LD_LIBRARY_PATH=$BASE_DIR/lib $RETROARCH -c $BASE_DIR/config/retroarch.cfg $EXTRAFLAG -L $CORES/$1_libretro.so "$2" &
while [ $(pidof retroarch) ];do
usleep 200000
done;

rm /var/lock/kodi.disabled
pgrep kodi.bin | xargs kill -SIGCONT 

Now, when you setup Advanced Launcher, you want to add a new launcher, select “Files Launcher” and load /storage/.kodi/addons/plugin.retroarch/retroarch.sh. The only other important thing you have to set are the arguments for this launcher. You’re going to want to make a new launcher for each emulator. When you set the arguments, set it to:

CORE-NAME "%ROM%"

So, if you’re wanting to run SNES roms using snes9x as your core, you’d set it to:

snes9x "%ROMS%"

Don’t forget the space between the core name and the ROM code.

That’s it, it should launch for you! I do need to point out though, that since I made these changes, I can’t load Retroarch manually from the Programs section, which means if you prefer to just load the Retroarch menu and load your ROM from in there, do not make these changes. Also, before you make these changes, you’re going to want to set a hotkey on your controller (if you don’t have a keyboard) so you can access the Retroarch menu from within a game.

I hope this helps someone!

I managed to get the system to now load a ROM directly from Advanced Launcher and additionally load Retroarch directly from command line or the Programs addon section.

###To the best of my knowledge, this bit of code is only needed on the install, it was causing errors
#VER=$1
#ADDON_DIR=$2
#cd $ADDON_DIR
#[ -f retroarch-install-$VER.sh ] && ./retroarch-install-$VER.sh && mv retroarch-install-$VER.sh ~/retroarch

BASE_DIR=/storage/retroarch/default
RETROARCH=$BASE_DIR/bin/retroarch
CONFIG=$BASE_DIR/config/retroarch.cfg
CORES=$BASE_DIR/libretro/cores
CORE=$CORES/$1_libretro.so

if [ ! -f "$2" ]
then
  pgrep kodi.bin | xargs kill -SIGSTOP
  sleep 1
  LD_LIBRARY_PATH=$BASE_DIR/lib
  $RETROARCH --menu -c $CONFIG
  while [ $(pidof retroarch) ];do
  usleep 200000
  done;
  rm /var/lock/kodi.disabled
  pgrep kodi.bin | xargs kill -SIGCONT
#  echo "Test"
  exit 1
fi

if [ -f "$2.cfg" ]; then
  echo "Config file for `basename "$2"` found, using."
  EXTRAFLAG="--appendconfig "$2.cfg""
fi

###If you wish to kill Kodi on each game launch, uncomment these lines and comment out the next set of code.
#systemctl stop xbmc.service
#systemctl stop kodi.service
#LD_LIBRARY_PATH=$BASE_DIR/lib $RETROARCH -c $CONFIG $EXTRAFLAG -L $CORE "$2"
#systemctl start xbmc.service
#systemctl start kodi.service

pgrep kodi.bin | xargs kill -SIGSTOP
sleep 1
LD_LIBRARY_PATH=$BASE_DIR/lib $RETROARCH -c $CONFIG $EXTRAFLAG -L $CORE "$2" &
while [ $(pidof retroarch) ];do
usleep 200000
done;

rm /var/lock/kodi.disabled
pgrep kodi.bin | xargs kill -SIGCONT 


SPECIAL NOTE!!

The person who made the newer addon I linked to in my original post noticed my changes and updated his addon to use them. So, if you download his addon now, you will not need to make any changes! It’ll just work out of the box.

I am having serious trouble over figuring out how to prevent KODI from receiving signals from my game controllers after launching snes roms through Rom collection browser or advanced launcher. I am strictly using retroarch 1.2.2 for my emulator. The game controller is reeking havoc in the background after playing a game. It is simply a mess when exiting retroarch. I painfully have everything working after weeks of researching. This seems to be the last issue (hopefully) almost a week of searching and I am at the end of my wits. I am not a Linux expert. This is the closest solution I have seen yet. Not sure if it can help me. I am running Kodibuntu with rom collection browser, and retroarch. I just want to be able to launch a snes game, use my game controller with out the inputs running in the background, and I want to be where I was when I exit the game. Can anyone please give me an Idea How I can do this, or direct me in the right area? I do not wish to kill kodi, but if I have to, so be it. Thank you so much in advance for any help.