我可以将屏幕旋转设置为反转:
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'
我设法编写了一个脚本,每次调用它时都会轮换脚本:
答案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