Apparently as someone just joining the community, I cannot ask for clarification on answers. There is no way to message a user, so I'm posting a new question relating to the following post.

How can I invert the mouse Y axis in Minecraft PI

The answer lists: "To invert the mouse Y, find the part of the library where it normally sends the deltaY value and invert it!"

and lists code for the instructions, however I'm not sure where the "library" is located. Can anyone help?

Just to be clear, I do not know where the library is that the solution is suggesting to search

Here is the full answer from jdonald https://raspberrypi.stackexchange.com/users/74822/jdonald:

One way to effectively mod this closed-source executable is to intercept SDL function calls with your own modified SDL.

sudo apt install libx11-dev libxext-dev
curl -O https://www.libsdl.org/release/SDL-1.2.15.tar.gz
tar xvf SDL-1.2.15.tar.gz
cd SDL-1.2.15

To invert the mouse Y, find the part of the library where it normally sends the deltaY value and invert it!

--- a/src/events/SDL_mouse.c
+++ b/src/events/SDL_mouse.c
@@ -185,7 +185,7 @@ printf("Mouse event didn't change state - dropped!\n");
                event.motion.x = X;
                event.motion.y = Y;
                event.motion.xrel = Xrel;
-               event.motion.yrel = Yrel;
+               event.motion.yrel = -Yrel;
                if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
                        posted = 1;

then build and inject your modified library to test:

LD_PRELOAD=$(pwd)/build/.libs/libSDL-1.2.so.0 minecraft-pi

Or if you have enabled full OpenGL with KMS, you may have to avoid the script at /usr/bin/minecraft-pi overriding with its own LD_PRELOAD setting. More complicated, but you can inject the Mesa wrapper alongside like so:

(cd /opt/minecraft-pi && \
 LD_PRELOAD="$(cd -)/build/.libs/libSDL-1.2.so.0 libbcm_host.so.1.0" \
 LD_LIBRARY_PATH=lib/mesa \

One cool perk of this approach is that because mouse look uses relative movements while you're leaving the absolute Y position untouched, cursor movement still functions as before.

If you wish to make further modifications or need to debug your changes, add printf() statements, rebuild, and rerun.

  • 2
    @Stettin if you followed the instructions the SDL_mouse.c file will be wherever you unpacked the archive.
    – Milliways
    Commented Dec 24, 2018 at 6:47
  • Asking a new question like you did was the right way. With a comment here on your own question you can address @ Jayster (without space), the asker of the original question.
    – Ingo
    Commented Jul 20, 2019 at 8:20
  • @Ingo You can't use comments to ping users who haven't contributed to the thread.
    – goldilocks
    Commented Jul 30, 2019 at 5:51
  • @goldilocks Ah.. wasn't aware of it. What's the best way to do it? Anyway the OP here can ask on the original question.
    – Ingo
    Commented Jul 30, 2019 at 9:55
  • I think the reason that SE doesn't have messaging of that sort is so that half the world can't ping Jon Skeet, etc. umpteen times a day. It's easy to say, "Well but they can ignore you if they like..." but this equals you being open to having your email inbox overrun by unfilterable spam all the time.
    – goldilocks
    Commented Jul 30, 2019 at 13:16

2 Answers 2


I was not able to get the changes to /usr/bin/minecraft-pi however Milliways pointed me to the right location for the SDL_mouse.c

The location is wherever you extracted SDL, for me it was;


The remainder of jdonald's solution includes a diff of the changes to flip the Y axis. Once I made the change, I had to launch Minecraft from the /opt/minecraft-pi directory

pi@raspberrypi /opt/minecraft-pi $ LD_PRELOAD=/home/pi/sdl/SDL-1.2.15/build/.libs/libSDL-1.2.so.0 minecraft-pi

I was not able to get his code block working for the launch.

LD_PRELOAD=$(pwd)/build/.libs/libSDL-1.2.so.0 minecraft-pi

Hopefully my way will help those that get stuck on the original solution.


Welcome to the community! Indeed it can be a chicken-and-egg problem when you can't comment on existing questions without sufficient reputation. Unfortunately this Stack Exchange has limited participation, which not only makes it hard to build reputation, but your duplicate (followup) question got only 65 views before I stumbled on it six months later.

First things first, it appears you missed the key part at the top of my original answer. The easiest way to get the option to invert the Y-axis:

Update: There's Phirel's patch to enable survival mode. It also happens to enable basic options in the GUI, including "Invert X-axis" (confusing terminology: invert Y direction ~= flip about X axis)

Using bspatch is not trivial, but it's probably easier than modifying SDL if you don't have prior experience with LD_PRELOAD.

Ultimately you identified that "the library" refers to SDL-1.2.15 and its source code. Regarding where things went astray in the LD_PRELOAD route you attempted, it appears it wasn't happy with LD_PRELOAD on the /usr/bin/minecraft-pi wrapper script. When troubleshooting you could ensure that no wrapper is used like so:

(cd /opt/minecraft-pi && \
  LD_PRELOAD="$(cd -)/build/.libs/libSDL-1.2.so.0" \
  LD_LIBRARY_PATH=lib/brcm \

Or if using the open-source graphics driver (mandatory on a Pi 4), the corresponding command for running with Mesa can be found in my original post. Only in this case is there the complication of libbcm_host.so.1.0 also known as mcrpi-wrapper, whereas in the legacy driver case there is only one LD_PRELOAD library.

For future questions of this form, Pi Stack Exchange might not be the best place to start a troubleshooting dialogue on an already-answered question. You could try on other sites like the official Raspberry Pi forums or Minecraft Pi forums which do allow private messaging for new users. Furthermore, even if I disappear there are others on the forums who can help in a format different from Stack Overflow.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.