How to help the Linux mobile community? Pt. 1: Minetest

Minetest on phones


Gaming is important. When I was 15 years old, the ability to play games on Linux was one factor that accelerated my transition from Windows to Linux, and I believe this holds true for many of you.

Two years ago, I successfully compiled and run the re3 engine, specifically reVC, which is designed to work with GTA Vice City game data, on my Linux phone. However, due to the absence of touchscreen controls, playing the game required a connected keyboard. While a touchscreen could still be utilized for aiming, the experience was less than optimal.

reVC running on OnePlus 6

Let me say ‒ these days I'm no Minetest, Minecraft, or MineClone2 daily player. I installed Minetest on Android phone approximately a year ago. I played it for a bit, and, certainly, I liked it.

What I also did was creating an issue to bring attention to the existence of Linux phones and express my desire for their support.

First peak

A few weeks ago, an idea crossed my mind that gaming on Linux phones isn't 'on fire.' While the Linux world offers numerous games, not many come equipped with on-screen controls.

Being aware that the Android game and other platforms' codebases are the same, I began exploring options to enable touchscreen functionality.

$ cmake ... -DENABLE_TOUCH=true

What I did was a quick recompilation of Minetest 5.7.0 with this option enabled. For this, I utilized the Alpine APKBUILD file and Continuous Integration (CI) provided by postmarketOS. After the GitLab CI artifacts were built, I sideloaded the .apk files onto my phone, and voila! It worked; however, it had side effects. The UI ceased to function on desktops with keyboard and mouse-driven workflows.

Quick, inefficient, and ugly way.. do the local distribution hack

My first thought was, let's patch the game for postmarketOS so people can use it. postmarketOS is distribution primarily aimed at phones and tablets, so the number of people playing Minetest and also using the machines with keyboard and mouse will be close to zero.

There is of course the cost, and that's the difference between Alpine and postmarketOS, and someone has to maintain the additional package and take care of potential problems.

We have to go deeper... Alpine.

Then for sure, I could send a patch to the Alpine which will change the default behavior, but that would mean many users on a desktop will get affected. We don't want that.

An option arose to distribute two binaries. One minetest with default desktop settings and minetest-touch which will provide the necessary build for touch-based devices.

At that point I started looking at upstream minetest code and how to make touchscreen enabled and disabled by runtime option.

The (very often) right way to make a contribution

Looking first time in my life at Minetest codebase isn't promising very fast progress, as I never worked with game code (except writing simple GUI Chess in Java at University when I was 20).

The options were hardcoded by #ifdefs and within LUA code by variable hardcoded at LUA initialization.

At the end of one very sunny Saturday, my rewrite was complete, but what bugged me, was that the touchscreen still didn't work on Minetest 5.8.0 with my patch.

My way of testing was picking APKBUILD from aports supplying patch generated from my upstream minetest PR and uploading packages into my phone.

Did I make a mistake somewhere?


After spending a long time going through my code and fixing some small issues, I started to feel like the issue wasn't on my side.

I recompiled the 5.8.0 without mine patch with -DENABLE_TOUCH=true but still didn't work. That's weird, it should.

But wait, the first trial was around one month ago and meanwhile 5.8.0 was released. Let me pick the original binary package from 5.7.0 from CI... Yes, the touch stopped working between the 5.7 and 5.8 versions.

Time to report a bug. We want to be good team players and provide feedback ASAP on our favorite projects.

Bisecting a long way to victory

Many of you are familiar with the bisection process, which takes some time, but not as much as building, uploading, and testing 1000 revisions of code.

I'm a lazy person. Bisecting is useful, but guessing with some knowledge can work too. In my case, I used git log -p 5.7.0..5.8.0 and searched for any occurrences related to touchscreens.

Formspec: Pass the second-touch event as is (#13872)

was only adept and also touching code which processes press and release. This was exactly what stopped working.

Reverting the patch immediately resolved my issue. Time to report this finding into the GitHub issue we created in the previous step.

Are Ya Winning, Son?

Now we know where the problem lies, we have a contribution that allows runtime alternation of input modes between touchscreen and mouse+keyboard.

My work is not finished yet; I need to wait for reviews, address comments, and implement proposed changes.

Are we there yet?

The Minetest project decided to switch input handling to the SDL2 layer, which is a step in the right direction. This means the bug I encountered will not exist in future code. The fix that has been published is most likely useful for 5.8.x series, but not 5.9.x. Does the effort put into fixing the bug make sense then?

Yes, many developers who create for fun sometimes forget (Hello OpenAGE!) that what they do is also a product that should reach its customers. Creating the most beautiful masterpiece is a loss to the world if no one sees it.


The Minetest 5.8 series has been released this month. That means, we need to ship the patch to the mobile distributions anyway, so users can benefit from it ASAP.

We're kinda back at the beginning of our journey, but the difference here is

  • one reported bug and
  • patch which leads to not having to do this again for other releases.

This is the value of FOSS (Free and open-source software).

I have postmarketOS, can I play the Minetest now?

After reading Alpine MR description, run

# apk add mrtest
# mrtest add -a 55520

(thanks to Frank sharing the simplified process)

Thank you for reading!

... and hoping to see one day your contribution to the FOSS world too!