将触控笔(笔)与 Acer Travelmate Spin B1 上旋转屏幕的触摸屏对齐

将触控笔(笔)与 Acer Travelmate Spin B1 上旋转屏幕的触摸屏对齐

我找到了一个脚本,可以将我的屏幕和触摸板向左旋转并恢复正常:

#!/bin/sh 

# Find the line in "xrandr -q --verbose" output that contains current screen orientation and "strip" out current orientation. 

rotation="$(xrandr -q --verbose | grep 'connected' | egrep -o  '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')" 

# Using current screen orientation proceed to rotate screen and input tools. 

case "$rotation" in 
normal) 
#    -rotate to the left 
xrandr -o left 
xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axes Swap" 1
xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axis Inversion" 1 0
xinput set-prop --type=int --format=8 4 "Evdev Axis Inversion" 1 0
;;
left) 
#    -rotate to normal 
xrandr -o normal 
xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axes Swap" 0
xinput set-prop --type=int --format=8 "ELAN Touchscreen" "Evdev Axis Inversion" 0 0
xinput set-prop --type=int --format=8 4 "Evdev Axis Inversion" 0 0
;; 
esac

工作正常。但如果屏幕旋转,触控笔就会无法工作。我找到了一个潜在的解决方案,即通过以下方式更改触控笔的坐标变换矩阵:

xinput set-prop 'ELAN Touchscreen Pen Pen (0)' "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1

这很好用,意味着如果屏幕方向正常,我运行这个命令

xinput list-props 'ELAN Touchscreen Pen Pen (0)' | grep "Coordinate Transformation Matrix"

导致

Coordinate Transformation Matrix (144): 0.000000, 1.000000, 0.000000, -1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000

但是每次我在脚本中使用它或者在屏幕以纵向模式运行它时它都会被重置,这意味着如果我运行

xinput list-props 'ELAN Touchscreen Pen Pen (0)' | grep "Coordinate Transformation Matrix"

运行脚本后或在“左”方向我得到

Coordinate Transformation Matrix (144): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

并且触控笔在改变方向后无法正常工作(向上是向左等等)

答案1

似乎在屏幕旋转时,笔的坐标变换矩阵会“重置”,从而覆盖命令。因此,我在执行这些命令之间添加了一个休眠时间,现在它工作正常。2 秒没有影响,因为在屏幕最终旋转之前需要这段时间

新脚本:

#!/bin/sh 

# Find the line in "xrandr -q --verbose" output that contains current screen orientation and "strip" out current orientation. 

rotation="$(xrandr -q --verbose | grep 'connected' | egrep -o  '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')" 

# Using current screen orientation proceed to rotate screen and input tools. 

case "$rotation" in 
normal) 
#    -rotate to the left 
xrandr -o left 
xinput set-prop "ELAN Touchscreen" --type=float "Coordinate Transformation Matrix" 0 1 0 -1 0 1 0 0 1
sleep 2
xinput set-prop "ELAN Touchscreen Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 0 -1 1 1 0 0 0 0 1
;;
left) 
#    -rotate to normal 
xrandr -o normal 
xinput set-prop "ELAN Touchscreen" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
sleep 2
xinput set-prop "ELAN Touchscreen Pen Pen (0)" --type=float "Coordinate Transformation Matrix" 1 0 0 0 1 0 0 0 1
;; 
esac

相关内容