I have Raspberry Pi 3 Model B+ with 5 inches Display with touchscreen for my challenge [Display works successful!]. I am using Debian Raspberry OS. I am on the file in /home/pi/mcpi/api/python/mcpi/touchControl.py to add only up, down, left and right movement as well as the camera too to support the TFT display touchscreen. This is part of my project in my college education. I am only familiar with basic Python to build calculator, structures, and file io, but definitely not to edit with existing file like Minecraft Pi or Firefox. I hope this one I can learn more interesting case to build for a game movement controller on touchscreen.

I am currently working on Minecraft Pi which it is already installed on the system, and I brought the touchscreen display from amazon to installed on Raspberry Pi, but the hardest part when I play on Minecraft is without keyboard.

Is there a possibility that I can open the Python or create new file to add Touchscreen mode for Minecraft Pi?

For example, LEFT, RIGHT, UP and DOWN movement should be add to the screen on Minecraft Pi where I can use my finger to move/walking/running the minecraft character. SO I AM STUCK ON HOW TO CREATE “LEFT, RIGHT, UP, OR DOWN” BUTTONS THAT ALLOWS TO USE FOR KEYBOARD WHICH IT IS WASD (W = UP, A = LEFT, S = DOWN, AND D = RIGHT). Currently, Minecraft Pi hasn't added yet because I am not familiar with Raspberry Pi Games Python. I hope this make sense.

Here is also both helpful images I am expected for after:

Before Minecraft Pi Before EXPECTED This is after I am expecting (You can see what I just added 4 buttons, in middle button is just a regular press button for maybe A or left click button (Don't have to add)).

  • 3
    your question is not related to the RPi ...... it is either a linux question or a minecraft question ...... in linux, it may be possible to have a GUI overlay that would send keystrokes to the underlying program ...... in minecraft, it may be possible to modify the HUD so that it includes the cursor buttons
    – jsotola
    Apr 28, 2019 at 0:30
  • Minecraft Pi is already built in on the RPi.
    – Ved
    Apr 28, 2019 at 4:41
  • @jsotola it maybe Raspberry Pi specific because with mouse input methods things like xwit and similar tools will cause the view to go screwy... only solid lead for getting custom inputs I've found so far was on instructables, which maybe enough of an inspiration for the OP to get it sorted.
    – S0AndS0
    Aug 24, 2019 at 9:04

1 Answer 1


This is do-able but would likely require a good amount of non-Python glue code.

For sending WASD keyboard events, you can modify SDL to send the appropriate key-down/key-up SDL_KeyboardEvent events at the right times. See a related question on input modding for how to inject a modified SDL library.

Reading touch events can normally be done by SDL, but SDL_TouchFingerEvent is broken in SDL1.2 on Raspbian Jessie and above1. As you'd be building SDL from source, make sure to sudo apt install -y libts-dev to resolve this. Alternatively, if you write your touch detection in Python using the better-supported python-multitouch library you'll need to communicate with your SDL library using a domain socket or other inter-process communication mechanism.

Lastly for the button graphics, DispmanX has a straightforward interface for overlays. See mcrpi-wrapper for a broad example of intercepting DispmanX and other calls. In your case the implementation would be less drastic as you'd pass most calls through while introducing one more overlay.

The above three steps would carry out the WASD part of your project, but a key element of Minecraft with touch is replacing mouse-look. For this you'd also emulate SDL_MouseMotionEvent calls.

That all may be a lot to swallow, considering:

definitely not to edit with existing file like Minecraft Pi or Firefox.

Alas, in that case intercepting SDL or DispmanX may be beyond your intended scope for this project.

I hope this one I can learn more interesting case to build for a game movement controller on touchscreen.

For your learning goals, PyGame (with SDL2) may be a better starting exercise. You could keep everything in Python, albeit your initial game would not be Minecraft.

It's also worth pointing out that Minecraft Pi Edition was developed from a codebase that already contained touchscreen support as you've described. That's Minecraft Pocket Edition 0.6.1. In fact, if you install MCPE 0.6.1 on an Android device today, you can use a touchscreen in a multiplayer session connected to MCPI.

1 "pygame problem with adafruit-pitft on raspbian jessie " on archive.org

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.