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.

  • 1
    And YOUR question is??? What have YOU done? – Milliways Dec 23 '18 at 4:15
  • You can use the comments to contact the user who answered your question. – Steve Robillard Dec 23 '18 at 8:49
  • Welcome to the Raspberry Pi flavoured corner of the Stack Exchange network. You might want to take the tour to get a better idea of how this place works. Clicking upon the (add a) comment item brings up what you need - as a new user you can only comment on your own question (though you really should consider whether it would be better to edit the question itself in that case) and the answers. When you get to 50 reputation then you can comment on other people's answers and questions. – SlySven Dec 24 '18 at 3:41
  • Possible duplicate of How can I invert the mouse Y axis in Minecraft PI – SlySven Dec 24 '18 at 3:43
  • 1
    @Stettin if you followed the instructions the SDL_mouse.c file will be wherever you unpacked the archive. – Milliways Dec 24 '18 at 6:47

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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