05 ‐ RetroArch POC - Zorglub51/Project-Chronos GitHub Wiki

How to integrate RetroArch to the original PCE mini beautiful UI

Principle

Use inotifyd deamon availble from busybox.

Steps

  • add a game to the m2engage system, use a valid PC Engine / TG16 rom, in this example Tonma_J.PCE(.m). Use the name and cover of the targeted game you want to launch with RetroArch, in this example Sonic 2 on Megadrive.
  • configure inotifyd to execute a script that will launch Sonic2 with RA if a program attempts to read the rom file in a setup_inotifyd script:
    busybox-hack inotifyd /usr/game/ra_sonic2 /usr/game/system/roms/Tonma_J.PCE.m
    (busybox-hack is the custom version of busybox that comes with the hack on the new partition 7, it includes a few applets that are not in the original busybox binary and that are used to open the tftp connection)
  • the ra_sonic2 script will stop m2engage, launch RA with proper configuration, and relaunch m2engage when the user quits RA:
/etc/init.d/gameapp stop  
./retroarch/retroarch -c ./retroarch/config/retroarch/retroarch_DEFAULT.cfg -L ./retroarch/config/retroarch/cores/genesis_plus_gx_libretro.so ./retroarch/roms/genesis/sonic2.md  
/etc/init.d/gameapp start  

In this example, the ra_sonic2 and setup_inotifyd scripts are in /usr/game next to m2engage

From POC to prod

This proof of concept has been successfully implemented. To take it further, one would have to automate the creation of the config lines in setup_inotifyd as well as the creation of the game launching scripts ra_MYGAMEXXX. This can be achieved by the pmgm.exe program without difficulty. Also partition 7 would have to include the loading of setup_inotifyd at startup, possibly through a additional command in /etc/init.d/S99first_startup.

Known limitations

The m2engage UI only recognizes the original HORI 2 button joypads, even if the console's kernel is modified to accept any USB device. This means that launching a game with RetroArch limits the games you can play to 2 button + run + select.
Workaround #1 : RetroArch will properly recognize and work with any joypad, and can be launched at startup time to bypass m2engage.
Workaround #2 : Write a driver that will translate the custom joypad's keycodes to the hard-coded keycodes in m2engage.

Additional information

I used a RetroArch binary and package from the Lunar project. In order to use it with the original HORI PC Engine mini joypad, I had to add the following configuration to a HORI CO.,LTD. PCEngine PAD.cfg file to be added to the retroarch\config\retroarch\autoconfig\udev directory:

input_driver = "udev"  
input_device = "HORI CO.,LTD. PCEngine PAD"  
input_vendor_id = "3853"  
input_product_id = "312"  
input_b_btn = "1"  
input_select_btn = "8"  
input_start_btn = "9"  
input_up_btn = "h0up"  
input_a_btn = "2"  
input_down_btn = "h0down"  
input_left_btn = "h0left"  
input_right_btn = "h0right"