螢幕旋轉的矩陣結構

螢幕旋轉的矩陣結構

我可以將螢幕旋轉設定為反轉:

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

並恢復正常:

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

我在這裡找到了一個操作方法:https://wiki.ubuntu.com/X/InputCooperativeTransformation
所以我猜(向右 90°)它將是:

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

但是左邊右邊的「座標變換矩陣」是什麼?

答案1

從問題來看它是一個標準的座標變換矩陣。

所以:

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

z_out= z_in= 1。

IE

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

您給出的右旋轉範例矩陣

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

因此意味著

x_out = 1 - y_in
y_out = x_in

對於向左旋轉,則相反,即:

x_out = y_in
y_out = 1 - x_in

給出矩陣

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

答案2

最後缺失的矩陣將是

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

我設法編寫了一個腳本,每次調用它時都會輪換腳本:

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

答案3

因此,我在筆記型電腦上完成了觸控螢幕和觸控板的所有轉換…假定觸控板物理方向位於使用者前面,位於使用者鍵盤和 eDP1 之間。無論我以哪種方式旋轉 x 顯示,滑鼠遊標都會與觸控板上的手指一致移動。我很久以前就這樣做了,忘了邏輯。現在,我使用xrandr -x和添加了 x 上的鏡像和 y 上的鏡像變換xrandr -y,但我找不到觸控板的矩陣座標,因此螢幕上的遊標移動與觸控板上的手指移動相同。

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

相關內容