2015-04-13, 23:10
See status of all game add-ons: http://kodi.wiki/view/Game_add-ons
Here's my explanation of how to port libretro cores to Kodi.
For this example I'm going to use Mupen64Plus (game.libretro.mupen64plus from https://github.com/libretro/mupen64plus-libretro)
This will cover:
1. Add-on fluff
This consists of four files:
CMakeLists.txt - the build system that imports the libretro core dependency
addon.xml.in - the add-on definition. The schema is still subject to change (the <platforms> tag isn't used and needs to be changed).
(optional) changelog.txt - this file is not required
icon.png - shown in the GUI. Try searching deviantart, and be nice and credit the author in the addon.xml description.
2. Controllers and button map
Kodi's controller add-ons allow independent button maps for each platform. The available controller add-ons can be found in the kodi-game-controllers repo.
game.libretro.mupen64plus uses the controller add-on game.controller.n64. Specify all the supported controllers by importing them in addon.xml:
If a platform's controller doesn't exist in the game controllers repo, you have two options:
Next, create resources/buttonmap.xml. This file maps the controller add-on to the "RetroPad" abstraction that libretro uses.
Create a <controller> element for each imported controller add-on. The type attribute corresponds to the libretro device type. Basically, if the controller has analog sticks, use the "analog" type. Otherwise, use the "joypad" type (as in game.libretro.genplus's buttonmap.xml)
The feature name is from the controller add-on's layout.xml.
The available "mapto" features are defined in LibretroTranslator::GetFeatureIndex().
3. Adding the libretro core as a dependency
Create depends/common/mupen64plus/mupen64plus.txt pointing to the libretro repo (use hash or "master"):
Create depends/common/mupen64plus/windows-deps.txt with the following contents:
depends/common/mupen64plus/CMakeLists.txt - the build command needs to point to the libretro Makefile of libretro's Mupen64Plus repo. You might need to use make -f Makefile.libretro as in FCEUmm's CMakeLists.txt or make -C libretro as in Nestopia's CMakeLists.txt. Here, the Makefile is in the "libretro" directory. Notice the extra "libretro" in Nestopia's install() command in CMakeLists.txt:
Finally, add any patches required directly to the folder with the .patch extension.
4. Importing the add-on to Kodi
As uncomfortable as the switch to Kodi's new CMake system was, it sure has its benefits. Adding a new add-on only requires a (github) target commit and list of platforms it should be built for. see project/cmake/addons/addons/game.libretro.mupen64plus
Build instructions can be found in RetroPlayer's readme.
Here's my explanation of how to port libretro cores to Kodi.
For this example I'm going to use Mupen64Plus (game.libretro.mupen64plus from https://github.com/libretro/mupen64plus-libretro)
This will cover:
- Creating the add-on fluff
- Defining the controllers and their buttonmaps
- Adding the libretro core as a dependency
- Importing the add-in into Kodi's binary add-on build system.
1. Add-on fluff
This consists of four files:
CMakeLists.txt - the build system that imports the libretro core dependency
addon.xml.in - the add-on definition. The schema is still subject to change (the <platforms> tag isn't used and needs to be changed).
(optional) changelog.txt - this file is not required
icon.png - shown in the GUI. Try searching deviantart, and be nice and credit the author in the addon.xml description.
2. Controllers and button map
Kodi's controller add-ons allow independent button maps for each platform. The available controller add-ons can be found in the kodi-game-controllers repo.
game.libretro.mupen64plus uses the controller add-on game.controller.n64. Specify all the supported controllers by importing them in addon.xml:
Code:
<requires>
<import addon="game.controller.n64" version="1.0.0"/>
</requires>
If a platform's controller doesn't exist in the game controllers repo, you have two options:
- (preferred) Create a controller (see the game controllers readme) and send a pull request or host it yourself
- Don't import a game controller add-on. The game add-on will receive input in the form of the default controller
Next, create resources/buttonmap.xml. This file maps the controller add-on to the "RetroPad" abstraction that libretro uses.
Code:
<buttonmap>
<controller id="game.controller.n64" type="analog">
<feature name="a" mapto="a"/>
<feature name="b" mapto="b"/>
<feature name="cup" mapto="x"/>
<feature name="cdown" mapto="r3"/>
<feature name="cright" mapto="l3"/>
<feature name="cleft" mapto="y"/>
<feature name="start" mapto="start"/>
<feature name="up" mapto="up"/>
<feature name="down" mapto="down"/>
<feature name="right" mapto="right"/>
<feature name="left" mapto="left"/>
<feature name="leftbumper" mapto="l"/>
<feature name="rightbumper" mapto="r"/>
<feature name="z" mapto="l2"/>
<feature name="analogstick" mapto="leftstick"/>
</controller>
</buttonmap>
Create a <controller> element for each imported controller add-on. The type attribute corresponds to the libretro device type. Basically, if the controller has analog sticks, use the "analog" type. Otherwise, use the "joypad" type (as in game.libretro.genplus's buttonmap.xml)
The feature name is from the controller add-on's layout.xml.
The available "mapto" features are defined in LibretroTranslator::GetFeatureIndex().
3. Adding the libretro core as a dependency
Create depends/common/mupen64plus/mupen64plus.txt pointing to the libretro repo (use hash or "master"):
Code:
mupen64plus https://github.com/libretro/mupen64plus-libretro 1ec2a3a
Create depends/common/mupen64plus/windows-deps.txt with the following contents:
Code:
mingw
depends/common/mupen64plus/CMakeLists.txt - the build command needs to point to the libretro Makefile of libretro's Mupen64Plus repo. You might need to use make -f Makefile.libretro as in FCEUmm's CMakeLists.txt or make -C libretro as in Nestopia's CMakeLists.txt. Here, the Makefile is in the "libretro" directory. Notice the extra "libretro" in Nestopia's install() command in CMakeLists.txt:
Code:
#install the generated shared library
install(FILES ${PROJECT_SOURCE_DIR}/libretro/nestopia_libretro${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
Finally, add any patches required directly to the folder with the .patch extension.
4. Importing the add-on to Kodi
As uncomfortable as the switch to Kodi's new CMake system was, it sure has its benefits. Adding a new add-on only requires a (github) target commit and list of platforms it should be built for. see project/cmake/addons/addons/game.libretro.mupen64plus
Build instructions can be found in RetroPlayer's readme.