参考文章:https://www.codetd.com/article/5651388
1.查看触摸屏驱动
xinput list
//情况如下,驱动为ILITEK Multi-Touch-V3000
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ILITEK Multi-Touch-V3000 id=9 [slave pointer (2)]
⎜ ↳ ILITEK Multi-Touch-V3000 id=10 [slave pointer (2)]
⎜ ↳ A4Tech USB Mouse id=8 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]↳ gpio-keys id=11 [slave keyboard (3)]↳ Logitech USB Keyboard id=6 [slave keyboard (3)]↳ Logitech USB Keyboard id=7 [slave keyboard (3)]
我们再查一下它支持的属性,这里可以用它后面的id号9来查询
Device 'ILITEK Multi-Touch-V3000':Device Enabled (152): 1Coordinate Transformation Matrix (153): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000libinput Calibration Matrix (306): 0.000000, -1.000000, 1.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000libinput Calibration Matrix Default (307): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000libinput Send Events Modes Available (271): 1, 0libinput Send Events Mode Enabled (272): 0, 0libinput Send Events Mode Enabled Default (273): 0, 0Device Node (274): "/dev/input/event2"Device Product ID (275): 8746, 1
可以看到,这里的输入是使用libinput进行管理的,所以当我们需要进行校正时,要进行其配置文件的修改
2.配置文件
2.1.查看/usr/share/X11/xorg.conf.d/目录下是否有40-libinput.conf这个文件。
opt: 没有这个文件, 则需要安装
sudo apt-get install xserver-xorg-input-libinput
安装完成后ls一下,就可以看到在/usr/share/X11/xorg.conf.d/目录下存在该文件
2.2.复制该文件到/etc/X11/xorg.conf.d/目录下。
opt: 一开始xorg.conf.d这个目录在/etc/X11可能没有,需要自己创建。
cd /etc/X11
sudo mkdir xorg.conf.d
sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/
sudo gedit /etc/X11/xorg.conf.d/40-libinput.conf
2.3.进入/etc/X11/xorg.conf.d/目录下修改40-libinput.conf 文件
找到touchscreen section
在Identifier下添加一行 Option “CalibrationMatrix” “你的校准矩阵”
我这里板子上需要旋转270度,所以写 Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"
90度 "0 -1 1 1 0 0 0 0 1"
180度 "-1 0 1 0 -1 1 0 0 1"
x ,y对调 "-1 0 1 1 0 0 0 0 1"
添加完成后
# Match on all types of devices but joysticks
Section "InputClass"Identifier "libinput pointer catchall"MatchIsPointer "on"MatchDevicePath "/dev/input/event*"Driver "libinput"
EndSectionSection "InputClass"Identifier "libinput keyboard catchall"MatchIsKeyboard "on"MatchDevicePath "/dev/input/event*"Driver "libinput"
EndSectionSection "InputClass"Identifier "libinput touchpad catchall"MatchIsTouchpad "on"MatchDevicePath "/dev/input/event*"Driver "libinput"
EndSectionSection "InputClass"Identifier "libinput touchscreen catchall"Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"MatchIsTouchscreen "on"MatchDevicePath "/dev/input/event*"Driver "libinput"
EndSectionSection "InputClass"Identifier "libinput tablet catchall"MatchIsTablet "on"MatchDevicePath "/dev/input/event*"Driver "libinput"
EndSection
这里你的校准矩阵里面,需要根据实际情况进行校准矩阵的编写,可以参考
https://wayland.freedesktop.org/libinput/doc/latest/absolute-axes.html (打不开的可以看文末的网页截图)
来写校准矩阵。