Estructura matricial para rotación de pantalla

Estructura matricial para rotación de pantalla

Puedo configurar la rotación de mi pantalla para que esté invertida con:

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

y volver a la normalidad con:

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

Encontré un Cómo hacer aquí:https://wiki.ubuntu.com/X/InputCoordinateTransformation
Supongo que para (90° a la derecha) será:

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

Pero ¿qué es la 'Matriz de Transformación de Coordenadas' de la derecha a la izquierda?

Respuesta1

A juzgar por la pregunta, es una matriz de transformación de coordenadas estándar.

Entonces:

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

con z_out= z_in= 1.

Es decir

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

La matriz de ejemplo que diste para la rotación a la derecha

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

así significa

x_out = 1 - y_in
y_out = x_in

para girar a la izquierda sería al revés, es decir:

x_out = y_in
y_out = 1 - x_in

dando la matriz

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

Respuesta2

La última Matrix que falta será

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

Logré escribir un script que rota el script cada vez que lo llamas:

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

Respuesta3

Entonces tengo todas las transformaciones para la pantalla táctil y el panel táctil en una computadora portátil... se supone que la orientación física del panel táctil está frente al usuario, entre el teclado del usuario y eDP1. No importa en qué dirección gire la pantalla x, el cursor del mouse se mueve al mismo tiempo que el dedo en el trackpad. Hice esto hace mucho tiempo y olvidé la lógica. Ahora agregué transformaciones de espejo en x y espejo en y usando xrandr -xy xrandr -y, pero no puedo encontrar las coordenadas de la matriz para el trackpad, por lo que el movimiento del cursor en la pantalla es el mismo que el movimiento del dedo en el trackpad.

function rotate_left (){
    xrandr --output "$connected" --rotate left
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    xinput set-prop "$pad" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
    xinput set-prop "$touch" "$TRANSFORM" 0 -1 1 1 0 0 0 0 1
    echo "left" >/etc/rotate
    echo "icon:$camino/icons/left.png" >>"$track"/ayp
}; export -f rotate_left

function rotate_right (){
    xrandr --output "$connected" --rotate right
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    xinput set-prop "$pad" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
    xinput set-prop "$touch" "$TRANSFORM" 0 1 0 -1 0 1 0 0 1
    echo "right" >/etc/rotate
    echo "icon:$camino/icons/right.png" >>"$track"/ayp
}; export -f rotate_right

function rotate_inverted (){
    xrandr --output "$connected" --rotate inverted
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    xinput set-prop "$pad" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
    xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
    echo "inverted" >/etc/rotate
    echo "icon:$camino/icons/inverted.png" >>"$track"/ayp
}; export -f rotate_inverted

function rotate_normal (){
    xrandr --output "$connected" --rotate normal
    xinput set-prop "$touch" "Evdev Axis Inversion" 1, 1
    xinput set-prop "$touch" "Evdev Axes Swap" 1
    xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
    xinput set-prop "$touch" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
    echo "normal" >/etc/rotate
    echo "icon:$camino/icons/normal.png" >>"$track"/ayp
}; export -f rotate_normal
function rotate_flipx {
    xrandr -x
    xinput set-prop "$touch" "Evdev Axis Inversion" 0,0
    xinput set-prop "$touch" "Evdev Axes Swap" 0
   xinput set-prop "$pad" "$TRANSFORM" 3 1 1 -1 1 1
    xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
};export -f rotate_flipx
function rotate_flipy {
 xrandr -y
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    xinput set-prop "$pad" "$TRANSFORM" 3 1 1 -1 1 1
    xinput set-prop "$touch" "$TRANSFORM" -1 0 1 0 -1 1 0 0 1
};export -f rotate_flipy
function rotate_flip_normal {
xrandr -o normal
    xinput set-prop "$touch" "Evdev Axis Inversion" 0, 0
    xinput set-prop "$touch" "Evdev Axes Swap" 0
    xinput set-prop "$pad" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
    xinput set-prop "$touch" "$TRANSFORM" 1 0 0 0 1 0 0 0 1
};export rotate_flip_normal

información relacionada