Help building Native standalone LÖVE games

Hi, I have a project ready to be deployed containing a touch control demo for LÖVE games.
I tried everything to build on the sdk but the virtual machine never starts and the process get stucked there, maybe someone with more success could try?
The app simply runs a löve game on start.
If someone manage to deploy it I have ported a few games to mobiles and added touch controls and they can be deployed as standalone sailfish apps.
Thanks!

2 Likes

It would be much easier to try to help if you had some code to try on.
I find the docker build engine much better than the VM one, though it might not be available on all platforms.
Also consider joining #sailfishos on OFTC IRC for more interactive help.

I will connect and ask on IRC.
Is it ok to post code here? This is basically all there is to it:

#ifdef QT_QML_DEBUG
#include <QtQuick>
#endif

#include <sailfishapp.h>

int main(int argc, char *argv[])
{
    // SailfishApp::main() will display "qml/VirtualTouchpad.qml", if you need more
    // control over initialization, you can use:
    //
    //   - SailfishApp::application(int, char *[]) to get the QGuiApplication *
    //   - SailfishApp::createView() to get a new QQuickView * instance
    //   - SailfishApp::pathTo(QString) to get a QUrl to a resource file
    //   - SailfishApp::pathToMainQml() to get a QUrl to the main QML file
    //
    // To display the view, call "show()" (will show fullscreen on device).

    QGuiApplication app(argc, argv);

       // Path to your game.love within your app's directory structure
       QString loveGame = QStringLiteral(":/data/game.love");

       // Launch the .love game using QProcess
       QProcess loveProcess;
       QString loveExecutable = "love";
       QStringList arguments;
       arguments << loveGame;
       loveProcess.start(loveExecutable, arguments);
       loveProcess.waitForStarted();


    return SailfishApp::main(argc, argv);
}

I also installed the SDK with docker after failing with virtualbox, but the virtual machine on docker does not start either…

Are you using the i686 build target? From my understanding of the sdk you only get access to the VM with the i686 target. That threw me off my first time using it.

I’m not even sure but I believe something got wrong while installing the virtual machine on docker and there is no virtual machine.
I gave up for now and since what I’m trying to achieve does not requires using silica or any feature of the sdk, I’m approaching the problem by building an RPM that runs the game directly.

so I managed to create a working rpm with help from the irc channel so there’s no need to use the sdk for this purpose, thanks for the help!

4 Likes

Hello @RosSigudottir,

I think I have found a solution for sailjail issues. I will add a Sailjail permission file to my build of the love engine.

What you would have to do is:

Desktop files for each game:

  1. In the Exec= line, use the full path to the love binary, /usr/bin/love
  2. add a section at the bottom like the one below:
[X-Sailjail]
Permissions=Love2D

This will use my custom sailjail permissions, allowing the application paths.

At least one app, Spring screensaver, also needs the Internet permission to load the weather data:

[X-Sailjail]
Permissions=Love2D;Internet

In general it would be good if you changed the installation directory for all your games to

/usr/share/games/love

The reason is that SailJail permissions have to whitelist paths explicitly, and while I have added all known paths from your packages for now, I don’t want to maintain a list in that permission file.

These changes should make the games launch however I have seen some of them crash for various reasons even with the sailjail thing out of the way. Infact, the only ones that work for me are VirtualInput (but it is fixed Portrait and hence too small), and the Screensaver thing.

Others crash with messages like:

love /usr/share/Boxclip/boxclip-mobile-fork-v0.1-3-4.love

initialized title
resized window (1080.0x2520.0)
Error: joystick.lua:47: attempt to index a boolean value (field 'active')
stack traceback:
        [string "boot.lua"]:777: in metamethod '__index'
        joystick.lua:47: in function 'joystick.updateAxes'
        main.lua:100: in function 'love.update'
        [string "boot.lua"]:612: in function <[string "boot.lua"]:594>
        [C]: in function 'xpcall'
Error: tools.lua:34: attempt to get length of a nil value (local 't2')
stack traceback:
        [string "boot.lua"]:777: in metamethod '__len'
        tools.lua:34: in function 'table.concat'
        [string "boot.lua"]:686: in function 'love.errhand'
        [string "boot.lua"]:777: in metamethod '__index'
        joystick.lua:47: in function 'joystick.updateAxes'
        main.lua:100: in function 'love.update'
        [string "boot.lua"]:612: in function <[string "boot.lua"]:594>
        [C]: in function 'xpcall'

love /usr/share/Blockdrop/blockdrop-mobile-fork-v0.1-3.love

Error: touchControls.lua:123: attempt to compare number with nil
stack traceback:
        [string "boot.lua"]:777: in metamethod '__lt'
        touchControls.lua:123: in function 'checkTouchMovement'
        main.lua:162: in function 'love.update'
        [string "boot.lua"]:612: in function <[string "boot.lua"]:594>
        [C]: in function 'xpcall'

love /usr/share/Starphase/Starphase-mobile-fork-v0.1-2-4b.love

Star Phase 0.11.4-dev by ricky thomson
xkbcommon: ERROR: couldn't find a Compose file for locale "en_GB.utf-8" (mapped to "en_GB.utf-8")
library "libGLESv2_adreno.so" not found
library "eglSubDriverAndroid.so" not found
library "vendor.qti.qspmhal@1.0.so" not found
love: gralloc.c:133: hybris_gralloc_initialize: Assertion `NULL' failed.
Aborted
1 Like

Other observations:

  1. the love binary is very picky about library dependencies. Binaries built against one target may not work on a system of another version. Therefore it would be good to get the love build into chum, where all versions are available individually.
    I can do the “getting into Chum” thing, but I am not able to actually maintain or furher develop the code from @sashikknox and https://github.com/savegame/love/tree/sailfish. Someone else would have to do that and step up as a maintainer.
  2. Are there any apps/games out there that use libmodplug, i.e. .mod files for music? If not I would like to drop the dependency on libmodplug.
1 Like

hi nephros, thanks for the help.
So if I follow your guidelines regarding the desktop files and add the ```

[X-Sailjail]
Permissions=Love2D

along with the internet permissions for those apps who need it and use the love directory for the app, we will have the main problem solved? Sounds great, I may not be able to edit and submit all at once but will do it little by little.

Regarding the other crash problems you mention which I can not reproduce:
I had to add sometimes tens of tweaks to the desktop versions of the game to make them work on my mobile, and all of them work, I would like to add more tweaks if needed but I don’t have other versions of sailfish to test and my sailfish virtual machine fails to start… therefore it is quite difficult for me to find out and solve those issues… I just can assure that on sailfish 3.4 32 bits on my phone all of the apps I submitted work…

I will at least follow your guidelines to solve the main problem.
Thanks!

  • regarding the error on blockdrop “Error: touchControls.lua:123: attempt to compare number with nil” , I initialized that variables and the problem should be gone now…

regarding the question about libmodplug… I don’t think any app need the library and if they do I can simply record the files and save it in a standard .ogg to reduce the complexity and problems with the dependencies.

I hope. Start with the Screensaver one, that seems the easiest/most compatible according to my very brief test.

1 Like

perfect, I may not be able to do it right now but it will be the first one I submit, thanks!

About crashes relating to mouse/joystick/touch etc, it may be related to:

regarding the crashes relating to mouse/joystick/touch I have a possible solution that I will test later, basically I can assign a value when is nil to avoid it from crashing, I will test that later.
Regarding the screen saver, could you tell me if this is correct before I submit the app?

[Desktop Entry]
Type=Application
Name=Springscreensaver
Comment=Springscreensaver
Icon=/usr/share/games/love/SpringScreensaver/springscreensaver.png
Exec=/usr/bin/love /usr/share/games/love/SpringScreensaver/springScreensaver-mobile-0.1.love
Terminal=false
Categories=Games;
Name[de_DE]=springscreensaver.desktop

[X-Sailjail]
Permissions=Love2D;Internet

this is my spec file to build the rpm:

%prep

%build

%install
mkdir -p %{buildroot}/usr/share/games/love/applications
mkdir -p %{buildroot}/usr/share/games/love/SpringScreensaver
install -m 0755 %{_sourcedir}/Spiele/Sailfish/desktopFiles/SpringScreensaver/springscreensaver.desktop %{buildroot}/usr/share/games/love/applications/springscreensaver.desktop
install -m 0644 %{_sourcedir}/Spiele/Sailfish/desktopFiles/SpringScreensaver/springScreensaver-mobile-0.1.love %{buildroot}/usr/share/games/love/SpringScreensaver/springScreensaver-mobile-0.1.love
install -m 0644 %{_sourcedir}/Spiele/Sailfish/desktopFiles/SpringScreensaver/springscreensaver.png %{buildroot}/usr/share/games/love/SpringScreensaver/springscreensaver.png

%files
/usr/share/games/love/applications/springscreensaver.desktop
/usr/share/games/love/SpringScreensaver/springScreensaver-mobile-0.1.love
/usr/share/games/love/SpringScreensaver/springscreensaver.png

%changelog

nephros I’ve just rebuilt the rpm and changed the directories to:

/usr/share/applications/springscreensaver.desktop
/usr/share/games/love/SpringScreensaver/springScreensaver-mobile-0.1.love
/usr/share/games/love/SpringScreensaver/springscreensaver.png

and added Permissions=Love2D;Internet
I don’t know if the .desktop file should be too on user/share/games/love/… but I tried that and it does not run on my phone that way. now it runs on my mobile, hopefully yours too.

I’ve just uploaded another build of boxclip with some corrections regarding the issues with inputs and with the same path to install it as I did with the spring screensaver. I hope this time works.

Hi, the .desktop looks fine (although I’d remove the name[de-de] part).

But. All the files were ok in the previous locarion.
Only the .love file needs to go into the new dir.

Maybe I wasn’t clear, sorry.

right, I will then only change the .love files, do I need to reupload boxclip and spring screensaver or do already work?
I made corrections to both and also to blockdrop following your feedback. I can not reproduce the error on starphase and I have no idea what is causing it.

Screensaver is fine, Boxclip misses the sailjail/permissions section.