Raspberry Pi Official touch screen rotation fix

I bought the RaspberryPi Official touch screen and used it as a digital photo frame.

The casing I'm using flipped the screen 180 degree, so I need to manually set the rotation in the screen setting, but somehow this screen rotation will not change the touch matrix, so the touch orientation is completely wrong when the rotate the screen.

Since I used this screen as photo frame, so I was lazy to fix this issue.

Yesterday, when I was updating MagicMirror, some update error out and broke it.

As I was fixing the issue, so I spent some time digging the Pi forum and found the solution.

In order to make the touch screen work after rotating it, I need to manually update the touch matrix as well.

Only one line of code and it is fixed!

DISPLAY=:0 xinput set-prop 'generic ft5x06 (00)' 'Coordinate Transformation Matrix' -1, 0, 1, 0, -1, 1, 0, 0, 1

It's an easy fix actually. :)