LÖVE libretro module
Posted: Mon Apr 27, 2020 10:38 pm
Hi All,
I've created a module that makes it possible to load and run libretro cores in LÖVE. It's a native module and it uses the native LÖVE API, so it needs to be built with LÖVE.
The repository is here, and the module is in the libretro branch. After switching to that branch, build LÖVE how you normally would, the module should be compiled in.
Load a core with love.libretro.newCore('path_to_so', 'path_to_rom'), and call core:step() at a fixed interval depending on the core. Get an image to draw with core:getImage(), audio plays automatically. Use core:setInput() and core:setKey() to send inputs to the core before calling core:step().
There are more methods, i.e. to query information from the core, exist, take a look at the wrap_Core.cpp file to see them all.
The API is not set in stone, the input API is likely to change. I'm also thinking in returning ImageData and SoundData from core:step() instead of having the core:getImage() method and playing the audio automatically. Ideas welcome.
Yes, I've been told that a pure Lua module is possible, using FFI. While I think it's completely feasible, my focus for now is to finish this native module. If someone wants to make a pure Lua module, it shouldn't be difficult to translate the b.
Cheers,
Andre
I've created a module that makes it possible to load and run libretro cores in LÖVE. It's a native module and it uses the native LÖVE API, so it needs to be built with LÖVE.
The repository is here, and the module is in the libretro branch. After switching to that branch, build LÖVE how you normally would, the module should be compiled in.
Load a core with love.libretro.newCore('path_to_so', 'path_to_rom'), and call core:step() at a fixed interval depending on the core. Get an image to draw with core:getImage(), audio plays automatically. Use core:setInput() and core:setKey() to send inputs to the core before calling core:step().
There are more methods, i.e. to query information from the core, exist, take a look at the wrap_Core.cpp file to see them all.
The API is not set in stone, the input API is likely to change. I'm also thinking in returning ImageData and SoundData from core:step() instead of having the core:getImage() method and playing the audio automatically. Ideas welcome.
Yes, I've been told that a pure Lua module is possible, using FFI. While I think it's completely feasible, my focus for now is to finish this native module. If someone wants to make a pure Lua module, it shouldn't be difficult to translate the b.
Cheers,
Andre