Godot Engine port for SailfishOS

strange thing with built in SDL2 … now, it wont send SDL_DISPLAYEVENT to application ( to Godot port ) , i cant now rotate device screen…
butold build of SDL2, which is linked statically yo Quake 2 works fine with this event, but now not work Application orientation hint ( its works on 3.x versions fine, not 4.x )

what happens with SialishOS SDL2 version& and where old SDL2 repo?

I have to pipe up and ask to. I haven’t had time to work on it, and so far my SDL2 prototypes still work (started with 3.4, not at 4.3.0.15) BUT I’m only using audio to this point … where can we track changes? I looked on github …

old sailfishos sdl2 repo was disappear some time ago, dont know what SDL version is used now (i think it main stream SDL2, without ay special SailfishOS patches), because mine old SDL2 with all sailfish patcher work better in quake2 port )

Source code for the SDL used in Sailfish OS is at https://github.com/sailfishos/libsdl the latest public release 4.3.0 has version 2.0.16 and next release will still have that version also. I will then update it latest version in the Sailfish OS release after that. There is one patch in the repo (in rpm folder) for Sailfish OS to bring back wl_shell support we still need.

2 Likes

@mal
but

sfdk engine exec sb2 -t SailfishOS-4.3.0.12-armv7hl -R zypper search GLES
[D] SOFT ASSERT: "!targetHasSnapshots" in file ../../../../sailfish-qtcreator/src/libs/sfdk/buildengine.cpp, line 722
Loading repository data...
Reading installed packages...

S  | Name                          | Summary                            | Type
---+-------------------------------+------------------------------------+--------
   | glesplash                     | GL splash screen                   | package
i  | mesa-llvmpipe-libGLESv1       | Mesa libGLESv1 runtime libraries   | package
i+ | mesa-llvmpipe-libGLESv1-devel | Mesa libGLESv1 development package | package
i  | mesa-llvmpipe-libGLESv2       | Mesa libGLESv2 runtime libraries   | package
i  | mesa-llvmpipe-libGLESv2-devel | Mesa libGLESv2 development package | package

no GLESv3 package in SDK …
EDIT:
hm… in /usr/include it has GLES3 folder
and

sfdk engine exec sb2 -t SailfishOS-4.3.0.12-armv7hl -R rpm -ql  mesa-llvmpipe-libGLESv2-devel
/usr/include/GLES2/gl2.h
/usr/include/GLES2/gl2ext.h
/usr/include/GLES2/gl2platform.h
/usr/include/GLES3/gl3.h
/usr/include/GLES3/gl31.h
/usr/include/GLES3/gl32.h
/usr/include/GLES3/gl3ext.h
/usr/include/GLES3/gl3platform.h
/usr/lib/libGLESv2.so
/usr/lib/pkgconfig/glesv2.pc

that mean in GLESv2 library it has GLESv3 too?

strange situation. i was built SDL2 using script from spec, link it as static, and it send SDL_DISPLAYEVENT_ORIENTATION as should, but if i link SDL2 as dynamic lib from repo, its not send orientation events ( and orientation of screen in Godot not change! )
i share my simple SDL2 application for testing this
to build test application binary:

# for static link (SDL2 folder are in same directory as main.cpp
sfdk sfdk engine exec sb2 -t SailfishOS-4.3.0.12-armv7hl g++ -I`pwd`/SDL2/include -lpthread -lwayland-client -ldl -lpulse -lGLESv2 -o sdl2bug main.cpp `pwd`/SDL2/build/libSDL2d.a
# for dynamic link
sfdk sfdk engine exec sb2 -t SailfishOS-4.3.0.12-armv7hl g++ -I/usr/include -lpthread -lwayland-client -ldl -lpulse -lGLESv2 -llibSDL2-2.0 -o sdl2bug main.cpp 

UPD: sample updatedm now screen clear color changed when we rotate phone

1 Like

In most cases, like in Sailfish OS, OpenGL ES 3 support is included together with OpenGL ES 2 support because version 3 is backwards compatible with version 2 so there is no need to have two separate libraries and mesa only has one pkgconfig file for both versions 2 and 3 so development package is also the same for both.

About the display orientation events, support for SDL_DISPLAYEVENT_ORIENTATION events was added to wayland backend in SDL 2.0.18 (https://github.com/libsdl-org/SDL/commit/5cc23868ed335b581c5716e8fb8313495a678ba4) and Sailfish OS 4.3.0 still has 2.0.16 as I mentioned earlier (and unfortunately also 4.4.0 will probably have that version) so if you need support for those events you will need to build your own SDL.

2 Likes

that is sad …
ok. now i’ll just build SDL2 from sailfishos repo, and link is statically to godot…

and, another question, i think you should know answer =)
in Quake2 port, i was use SDL_SetHint(SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION,"landscape"); to set orientation of sailfish system (for right gestures) - and it not work any more (with own build SDL2, where it work on previous versions of Sailfish 3.x )
UPD: sorry, wrote strange thig here berfore, removed! MCE dbus names work as should =)

It was decided that SDL 2.0.18 will be in next release (4.4.0) so you’ll only need to build it yourself for 4.3.0.

About that orientation hint, unfortunately that way is now broken (I have been thinking if there is some way to fix that) but there is another way to set content orientation which I have used in one SDL based game

#include <SDL2/SDL_syswm.h>
SDL_SysWMinfo info;
SDL_VERSION(&info.version)
SDL_GetWindowWMInfo(sdl_window, &info);
wl_surface *sdl_wl_surface = info.info.wl.surface;
wl_surface_set_buffer_transform(sdl_wl_surface, WL_OUTPUT_TRANSFORM_270);

where the parameter WL_OUTPUT_TRANSFORM_270 is one of the values shown here wayland-client-protocol.h source code [include/wayland-client-protocol.h] - Woboq Code Browser and used here https://github.com/sailfishos/qtwayland/blob/mer-5.6/src/compositor/wayland_wrapper/qwlsurface.cpp#L526 but I think that as seen from Qt code it might need to take into account the native display orientation (which probably could be obtained getting the display orientation and display mode information and comparing the width and height) when selecting the value but I have only seen such on some tablets but I haven’t yet tested how the above code would behave on such a device.

4 Likes

another question, now i cant find some dependencies in SDK

sfdk engine exec sb2 -t SailfishOS-4.3.0.12-armv7hl -R zypper search libudev
Loading repository data...
Reading installed packages...
No matching items found.

need libudev-devel for using controllers inside Godot engine … dont want to rewrite this to SDL2 =)

In Sailfish OS systemd-devel package provides libudev-devel package and in it the needed development headers and systemd-libs provides libudev. Maybe zypper doesn’t support searching for the provided names of packages or something but it should work if you add to the spec file “BuildRequires: pkgconfig(libudev)”

1 Like

@sashikknox I edited the orientation hint code example in the earlier comment, it was missing one important line. Please update any code you might have made already.

1 Like

Is the orientation hint broken due to changes at the SDL2 side or changes on the Wayland compositor side? This commit

shouldn’t have broken it, right? Because I am the one who suggested it, I believe.

It is broken because one old custom commit was removed from Sailfish OS qtwayland during an update. That commit used to add back support for the already removed set_content_orientation request (replacing the normal behavior, set_orientation_update_mask which was added at some point to qtwayland and then the old set_content_orientation was removed) of qt_extended_surface interface of qtwayland wayland surface_extension. The old request only allowed one value as parameter so the commit you linked fixes SDL to match normal qtwayland behavior, unfortunately the set_content_orientation_mask request of that interface is not working in Sailfish OS.

1 Like

So if I’m not mistaken, SDL2 should now use set_orientation_update_mask on newer Sailfish OS versions to work properly? If not, what should I change in SDL to get it working again?

So SDL2 should be modified to use

if I’m not mistaken.

1 Like

If we want to have the old style behavior then wl_surface_set_buffer_transform is needed at the moment because Sailfish OS compositor is not handling that set_orientation_update_mask, if that would be fixed then allowing only one orientation would achieve the old style behavior. I have been planning on asking SDL developers what they think of that wl_surface_set_buffer_transform and if they would accept adding some new method or hint to their API.

Also the naming in SDL is now a bit inaccurate as the hint is still named QTWAYLAND_CONTENT_ORIENTATION when it’s actually the orientation update mask.

1 Like

wl_surface_set_buffer_transform seems to work indeed, although the application itself still seems to be responsible for rendering its graphics in the correct orientation. Nevertheless, that makes it possible to

Now the only roadblock in the way that I’ve seen for porting a SDL application is that the SDL_StartTextInput(void) and other functions related to the keyboard do not seem to be working with SailfishOS.

Was it backport of SDL code? hints are still there and should work, or at least work on android so maybe should work on hybris (the variable is called something_IOS but works on android, so should work on sfos)

in Quake 2 port, i was use an old SDL2 (builtin statically), which is work on previous SaiflishOS version, but on 4.x its broken, but it has all needed patches…

1 Like

@sashikknox i plan to use the godot, would you mind updating it? thanks