balena-labs-projects / xserver

A simple X11 server block
Apache License 2.0
15 stars 13 forks source link

Xorg Screen rotation backwards #18

Closed rjoffray closed 1 year ago

rjoffray commented 2 years ago

I have researched and the rotate left and right transform matrix coordinates are backwards see: https://gist.github.com/rubo77/daa262e0229f6e398766 in which he shows a good example

nucleardreamer commented 2 years ago

So upon testing, it looks like it is really up to the display manufacturer to position any display into the right orientation. The code is correct from what I see on multiple devices, so it might be a case where the screen has been physically flipped (probably unintentionally). I think this is worth adding to the readme though, incase anyone runs into this in the future.

rjoffray commented 2 years ago

The touch and screen rotation are different ... if you specify: DISPLAY_ROTATE_TOUCH=left then the way it is right now you would need to specify DISPLAY_ORIENTATION=right I did some research and you have the touch TRANSFORM MATRIX for left and right backwards It should be this in the config file

# coordinate matrix transform matrixes
case $DISPLAY_ROTATE_TOUCH in
"normal")
    COORDS="1 0 0 0 1 0 0 0 1"
    ;; 
"right")
    COORDS="0 1 0 -1 0 1 0 0 1"
    ;;
"inverted")
    COORDS="-1 0 1 0 -1 1 0 0 1"
    ;;
"left")
    COORDS="0 -1 1 1 0 0 0 0 1"
    ;;
esac

this is from https://www.gechic.com/en/raspberry-pi-touch-monitor-rotate-touch-screen-rotate-settings/

90° = Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"
180° = Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
270° = Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"

also see: https://wiki.ubuntu.com/X/InputCoordinateTransformation