View Full Version : Do SDL apps work on Sailfish without modifications?
If I have a SDL2 app, full screen, that uses no library (other than SDL2), can I just compile/link it and it will run?
moodroid
2018-01-13, 19:55
Hi,
Take this with a pinch of salt, as I don't really know what I'm doing, and I'm not sure if this is relevant...
But when I compiled ffplay (part of ffmpeg), I found that all the graphical stuff worked fine, but I didn't get any audio.
I did manage to get audio working (http://talk.maemo.org/showpost.php?p=1529446&postcount=9).
HTH
Thanks for the reply. I am trying to decide if it's worth it to get a second hand phone, like a Xiaomi mi4 to play with.
Do you, by any chance, care to give this a try? https://github.com/raduprv/1-million-particles
You just have to compile it and link with -lSDL2main -lSDL2
It's an app that I wrote a few years ago for Android, and I just released the source today. The Android app is here:
https://play.google.com/store/apps/details?id=com.purebinary.mparticles
moodroid
2018-01-14, 12:04
Hi Radu,
I've had a quick go, but like I say, I'm just playing, and don't really know what I'm doing...
It didn't seem to like:
#ifndef _WIN32
mkdir(config_path, (S_IRWXU|S_IRWXG|S_IRWXO));
#else
mkdir(config_path);
#endif
and gave
main.c: In function 'get_configh_path':
main.c:287:23: error: 'S_IRWXU' undeclared (first use in this function)
mkdir(config_path, (S_IRWXU|S_IRWXG|S_IRWXO));
^
main.c:287:23: note: each undeclared identifier is reported only once for each function it appears in
main.c:287:31: error: 'S_IRWXG' undeclared (first use in this function)
mkdir(config_path, (S_IRWXU|S_IRWXG|S_IRWXO));
^
main.c:287:39: error: 'S_IRWXO' undeclared (first use in this function)
mkdir(config_path, (S_IRWXU|S_IRWXG|S_IRWXO));
^
So, I changed it to '#ifdef _WIN32' just to see what would happen, and it then compiled with:
gcc main.c -lSDL2 -I/usr/include/SDL2 -lm
When I run it, it brings up an options screen in portrait and because my device is only 540 x 960, a lot of it was cut off the edge of the screen.
But most importantly, I wasn't able to interact with it. Touching the buttons and controls didn't do anything, and I don't know if it has any keyboard options? When I compiled ffplay, it didn't have any touch controls and was controlled by the keyboard, so maybe touch stuff doesn't work? Perhaps someone who knows more about it can advise...
Thanks a lot!
Can you please try to put #define __ANDROID__ somewhere at the very beginning, and just comment out the lines like:
#ifdef __ANDROID__
Android_JNI_GetAccelerometerValues(last_accel_valu es);
last_got_accel=SDL_GetTicks();
#endif
Also, in get_config_path() just change it to:
void get_configh_path()
{
strcpy(config_path,getenv("HOME"));
mkdir(config_path);
}
Maybe if you do that it will be full screen and touch will work.
moodroid
2018-01-14, 13:01
Have done that, but it doesn't seem to have made any difference, sorry. Just did some searching, and it does sound like there may be issues with landscape and touch with sdl on Sailfish?
That sucks.
Was it at least full screen, with the right dimensions (window not being cut)?
When it started, was it in landscape mode?
If there are issues with SDL in landscape mode, I guess there's not a good chance to port many games and apps to Sailfish :/
moodroid
2018-01-14, 13:49
Hi. It was full screen, but it immediately went into portrait mode and won't rotate, so options screen was cut off - it was the same with ffplay.
Maybe there is a solution out there, or maybe someone else will reply.
Sorry it isn't better news.
I wonder if there is any option to make it not do that. I wish I could find a nice SDK with well documented APIs for Sailfish.
You can try my nested compositor qxcompositor from openrepos.
I was able to compile your app but without #define __ANDROID__ so don't know whether touch will works correctly.
Thank you!
I don't have a device that can run Sailfish on, which is why I wanted to know if it is worth getting one. I used to have a N900, and it was easier to develop for it.
Anyway, I have no idea why the input doesn't work. It uses normal SDL calls, normally a tap on the screen should simulate a mouse click. I guess that either this is not implemented yet, or maybe the clicks are sent with the wrong coordinates? Is there any way to get the console output of a program?
Events are generated but there is something wrong with coordinates. For bottom right corner x/y_mouse_pos are 866643/273391 but I didn't check it more.
That's very interesting. I guess it's a bug with Sailfish? Because this works on Windows, Linux and Android just fine.
Can you check if it gets SDL_FINGERMOTION or SDL_FINGERDOWN events? It's around line 2500
It works now, event.tfinger.x is just touch position and can't be multiplied by window width.
Ok, thanks!
That's a bug, that should be a value between 0 to 1 (https://wiki.libsdl.org/SDL_TouchFingerEvent), not an absolute value. Any idea where that should be reported?
The sdl code should be at git.merproject.org/mer-core so maybe there. I don't know, better join to #sailfishos at IRC and ask there.
Well, I posted it here: https://together.jolla.com/questions/
I hope someone will see and fix it.
vBulletin® v3.8.8, Copyright ©2000-2025, vBulletin Solutions, Inc.