Friday 5 May 2017

Raspberry Pi Touchscreen Portrait

I recently wanted to turn my Raspberry Pi Official Touchscreen portrait (i.e. sideways!), which turns out is a bit of pain.

Turning the display is relatively easy but making the touch work is more difficult - there was a set of instructions on the Raspberry Pi forum, but a recent update to Jessie meant they no longer worked, so I pulled this set of instructions together:

Install xinput:
sudo apt-get install xinput
Rotate the display by editing config.txt:
sudo nano /boot/config.txt
 .. add this to the buttom of the file:
Use Ctrl X, Yes to Save
Create a script to rotate the touchscreen:
nano /home/pi/
 .. add the following command
xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix'  0 1 0 -1 0 1 0 0 1
Make the script executable:
chmod +x
Make the script run when the GUI starts by editing autostart:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
 .. add this to the bottom to run your script
sudo reboot


  1. Thank you !! I've spent way too many time on this until I found your post !

  2. This comment has been removed by the author.

  3. Interesting... Was this on stretch? I wonder if the structure has changed.

  4. Hell Yeah! Thank you! Works well. / Testet on Raspi3&Raspi 7" Touchmonitor. Only working solution in 2018 sofar.

  5. I found somewhere how to set the matrix for 270degree rotation:
    xinput --set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1

  6. Anyone have a clue why this would work at first and then revert to the previous behavior?

    About to redo my whole install if I can't figure out why it seems to be loading a new instance wiping out these changes.

  7. I cannot get this to work, but the reason may be that I dont have a FT5406 memory based driver, but a real HP USB Mouse.....
    so what do I do to get mouse rotation to work with an Olimex A20 and the same problem, and a normal USB mouse connected to it?


Note: only a member of this blog may post a comment.