Issues with porting a SDL2 game regarding sound and landscape rotation

I’m trying to port a game built using SDL2 to Sailfish OS. So far, most things are working, but I’m having a few issues so I thought I’d post them over here, maybe other people might know how to solve these.

First of all, the sound is being problematic. The game uses SDL2 to play back sound, but it completely ignores the system volume and plays back on full volume. A port of TuxRacer to SailfishOS has exactly the same problem. When the application runs on a Linux desktop, it respects the system volume as it should. Is there some additional code needed for Sailfish OS?

Another issue I have is with the screen rotation. The game I’m porting is best played in landscape mode, is there a nice way to have SDL or the compositor to render the window in a landscape orientation or should I modify the game itself to render with an angle of 90 degrees? All I could find is SDL_SetHint(SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION, "landscape");, which tells the compositor the window is in landscape and it will move the top menu and swipe gestures to the right locations, but it does not rotate the window.

Touch input is broken as well, but I suspect that probably is due to the game not handling touch input properly in general. Edit: it seems that the touch coordinates are not ranging from 0.0 to 1.0 on both the X-axis and Y-axis as the game seems to expect.

1 Like

For audio-related software, it seems that there is some Nemo-middleware that somehow needs to be integrated correctly: https://wiki.merproject.org/wiki/Nemo/Audio. I’m still trying to figure out how exactly how it works, but I don’t really know what I should implement. Shoud I bother with libresource? Is just setting the pulseaudio media role to “game” enough (it seems it isn’t)?

And there are some nemo pulseaudio modules like “mainvolume” and “stream-restore-nemo”. I suppose one of the is responsible for correctly setting the audio or so, but they do not seem to pick up my SDL application.

Regarding the touch input: this apparently was an issue within SDL. I’ve submitted a pull request to fix the issue, which got merged in!

As for the rotation, I found out that the game I’m porting first renders to an offscreen SDL texture which later gets copied to the window. Simply setting the correct sizes and rotating that texture when copying it to the window, as well as applying the rotation to touch input should solve it for the most part. For now, it works if your window is exactly a square :slight_smile:, but I should get it working quite soon, I expect.

3 Likes

For the audio part: manually setting the stream role with the environment variable PULSE_PROP_media.role=x-maemo seems to solve the issue.

1 Like

Does this also deal with muting on incoming calls? That’d be nice :slight_smile: