How to rotate the touchscreen on a PiScreen

If you rotate the display on the TFT, you will also need to rotate the touchscreen.

If you haven't already done so, install xinput.

pi@raspberrypi ~ $ sudo apt-get install xinput -y

Open up the X init script

pi@raspberrypi ~ $ sudo nano /etc/X11/xinit/xinitrc

And add these lines;

DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axes Swap' 1
DISPLAY=:0 xinput --set-prop 'ADS7846 Touchscreen' 'Evdev Axis Inversion' 1 1

before;

. /etc/X11/Xsession

You may need to change the values at the end of the each line;

Evdev Axes Swap
Swap X & Y
1 for yes and 0 for no
Evdev Axis Inversion
Swap the direction on the X or Y plane.
1 for yes and 0 for no. A number is needed for each plane

You may also need to re-calibrate the touch screen for X windows. This can be done by deleting the file below and then rebooting;

pi@raspberrypi ~ $ sudo rm /etc/pointercal.xinput