1

I can set my screen rotation to inverted with:

xrandr -o inverted
xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1

and back to normal with:

xrandr -o normal
xinput set-prop 'ELAN Touchscreen' 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1

I found a HowTo here: https://wiki.ubuntu.com/X/InputCoordinateTransformation
So I guess for (90° to the right) it will be:

# ⎡ 0 -1 1 ⎤
# ⎜ 1  0 0 ⎥
# ⎣ 0  0 1 ⎦
right='0 -1 1 1 0 0 0 0 1'

But What is the right 'Coordinate Transformation Matrix' to the left?

  • 2
    Wouldn't it be [[0 1 0] [-1 0 1] [0 0 1]]. I.e. x and y are still swapped but it changes which of them that is inverted. The inverted coordinate has -1 in the upper-left 2x2 and 1 to the right, while the non-inverted coordinate have 1 in the upper-left 2x2 and 0 to the right. – Johan E Jun 20 '14 at 0:16
  • 1
    Note: by now the wiki page also includes the answer to the left matrix – rubo77 Apr 27 '18 at 23:56
2

Judging from the question it is a standard coordinate transform matrix.

So:

⎡x_out⎤   ⎡ a b c ⎤   ⎡ x_in ⎤
⎜y_out⎥ = ⎜ d e f ⎥ * ⎜ y_in ⎥
⎣z_out⎦   ⎣ 0 0 1 ⎦   ⎣ z_in ⎦

with z_out = z_in = 1.

I.e.

x_out = a * x_in + b * y_in + c
y_out = d * x_in + e * y_in + f

The example matrix you gave for right rotation

⎡ 0 -1 1 ⎤
⎜ 1  0 0 ⎥
⎣ 0  0 1 ⎦

thus means

x_out = 1 - y_in
y_out = x_in

for rotating left it would be the other way around i.e.:

x_out = y_in
y_out = 1 - x_in

giving the matrix

⎡  0 1 0 ⎤
⎜ -1 0 1 ⎥
⎣  0 0 1 ⎦
0

The last missing Matrix will be

left='0 1 0 -1 0 1 0 0 1'

I managed to write a script that rotates the script each time you call it:

https://gist.github.com/rubo77/daa262e0229f6e398766

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.