有些设备的触摸屏不准,需要校正后才能正常使用。校正实际上就是配置设备在 Xorg 中的属性,具体属性名与驱动相关,后文描述。

注意: 本文所有的操作都是在 deepin 上完成,包名不同的请自行查找。

下面开始介绍校正方法:

准备

安装需要用到的工具:

xinput-calibrator : 触摸屏校正工具

xinput : 屏幕映射工具,多屏时使用

校正

执行 xinput_calibrator --list 查看触摸设备列表

校正设备 xinput_calibrator -v --device

device name or id 从上面的 list 中得到

此时会出现校正界面,按照提示点击,成功后程序会输出校正后的数据。

接着根据驱动的不同选择不同的设置方法,查看设备使用的驱动可通过 /var/log/Xorg.0.log 文件得到。

evdev

使用 evedev 驱动时可直接使用 xinput_calibrator 输出的数据,无需其它设置。

测试时使用 xinput 设置 Evdev Axis Calibration 属性。

libinput

使用 libinput 驱动时需要将 xinput_calibrator 输出的数据进行计算才可使用,计算方法参见: Libinput breaks xinput_calibrator

在此将计算方法写成了一个脚本,内容如下:

#!/usr/bin/env python3

# -*- coding: UTF-8 -*-

import sys

def usage():

info = "Usage: " + sys.argv[0]

info += " "

info += " "

info += " "

print(info)

print("\tScreen width/hight by the command 'xrandr|grep screen' got")

print("\tClick x/y by the command 'xinput_calibrator -v' got")

sys.exit(0)

def convert(screen_x, screen_y, c0_x, c0_y, c3_x, c3_y):

a = (screen_x * 6 / 8) / (c3_x - c0_x)

c = ((screen_x / 8) - (a * c0_x)) / screen_x

e = (screen_y * 6 / 8) / (c3_y - c0_y)

f = ((screen_y / 8) - (e * c0_y)) / screen_y

print("Try set 'libinput Calibration Matrix' to '%.1f, 0.0, %.1f, 0.0, %.1f, %.1f, 0.0, 0.0, 1.0'" % (a,c,e, f))

if __name__ == "__main__":

if len(sys.argv) != 7:

usage()

convert(int(sys.argv[1]), int(sys.argv[2]), int(sys.argv[3]),

int(sys.argv[4]),int(sys.argv[5]),int(sys.argv[6]))

测试时使用 xinput 设置 libinput Calibration Matrix 属性。

如若都不行切换到 evdev 驱动,即安装 xserver-xorg-input-evdev 然后添加 99-touchscreen-evdev.conf 到 /etc/X11/xorg.conf.d 目录, 内容如下:

Section "InputClass"

Identifier "calibration"

Driver "evdev"

MatchProduct ""

EndSection

其中的 touchscreen product 可以从 /var/log/Xorg.0.log 得到。

示例

如在 Huawei 上执行校正操作的输出如下:

deepin@deepin-PC:~$ xinput_calibrator -v

DEBUG: XInputExtension version is 2.3

DEBUG: Skipping virtual master devices and devices without axis valuators.

DEBUG: Skipping device 'Virtual core XTEST pointer' id=4, does not report Absolute events.

DEBUG: Skipping device 'SYNA1D31:00 06CB:CD48 Touchpad' id=12, does not report Absolute events.

DEBUG: Selected device: SYNA2393:00 06CB:19AC

DEBUG: Not usbtouchscreen calibrator: Not a usbtouchscreen device

DEBUG: Evdev Axis Calibration not set, setting to axis valuators to be sure.

Setting calibration data: 0, 3000, 0, 2000

DEBUG: Successfully applied axis calibration.

DEBUG: Read axes swap value of 0.

DEBUG: Read InvertX=0, InvertY=0.

Calibrating EVDEV driver for "SYNA2393:00 06CB:19AC" id=11

current calibration values (from XInput): min_x=0, max_x=3000 and min_y=0, max_y=2000

DEBUG: Found that 'SYNA2393:00 06CB:19AC' is a sysfs name.

DEBUG: Adding click 0 (X=382, Y=246)

DEBUG: Adding click 1 (X=2647, Y=246)

DEBUG: Adding click 2 (X=376, Y=1761)

DEBUG: Adding click 3 (X=2640, Y=1764)

Doing dynamic recalibration:

Setting calibration data: 2, 3021, -7, 2015

DEBUG: Successfully applied axis calibration.

--> Making the calibration permanent

DEBUG: Found that 'SYNA2393:00 06CB:19AC' is a sysfs name.

copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)

Section "InputClass"

Identifier "calibration"

MatchProduct "SYNA2393:00 06CB:19AC"

Option "Calibration" "2 3021 -7 2015"

Option "SwapAxes" "0"

EndSection

Xorg.0.log 中设备驱动相关的日志如下:

[ 7221.421] (II) config/udev: Adding input device SYNA2393:00 06CB:19AC (/dev/input/event7)

[ 7221.421] (**) SYNA2393:00 06CB:19AC: Applying InputClass "evdev touchscreen catchall"

[ 7221.421] (**) SYNA2393:00 06CB:19AC: Applying InputClass "libinput touchscreen catchall"

[ 7221.421] (**) SYNA2393:00 06CB:19AC: Applying InputClass "calibration"

[ 7221.421] (II) LoadModule: "evdev"

[ 7221.421] (II) Loading /usr/lib/xorg/modules/input/evdev_drv.so

[ 7221.421] (II) Module evdev: vendor="X.Org Foundation"

[ 7221.421] compiled for 1.19.1, module version = 2.10.5

[ 7221.421] Module class: X.Org XInput Driver

[ 7221.421] ABI class: X.Org XInput driver, version 24.1

[ 7221.421] (II) Using input driver 'evdev' for 'SYNA2393:00 06CB:19AC'

evdev

执行命令 xinput set-prop 11 Evdev Axis Calibration 2 3021 -7 2015 测试效果

libinput

使用上面的 click 0 和 click 3 的值以及 xrandr 得到的 screen width/height 计算,得到的值如下:

$ python3 ./touchscreen_calibration_convert.py 344 193 382 246 376 1761

Try set 'libinput Calibration Matrix' to '-43.0, 0.0, 47.9, 0.0, 0.1, 0.0, 0.0, 0.0, 1.0'

执行命令 xinput set-prop 11 libinput Calibration Matrix -43.0 0.0 47.9 0.0 0.1 0.0 0.0 0.0 1.0 测试效果。

额外问题

某些设备按照上述步骤设置后仍然有一些问题,这里列出一些遇到过的,一旦出现下面这些情况,请先切换驱动到 evdev 然后进行设置。

上下相反

如点击 左上角 却反馈在 左下角 ,在 90-touchscreen-calibrator.conf 中加上 Option InvertY "true" 。

左右相反

如点击 左上角 却反馈在 右下角 ,在 90-touchscreen-calibrator.conf 中加上 Option InvertX "true" 。

边缘偏移

如点击最右边却反馈在旁边的区域,此时可调整 Option Calibration 的值,其值的含有为: "min-x max-x min-y max-y" 。在四个边缘都试下,然后调整对应的值。

XY 相反

如点击 左上角 却反馈在 右上角 ,在 90-touchscreen-calibrator.conf 中加上 Option SwapAxes "true" 。

持久化

上面的测试无误后,就开始集成到系统中,每次启动时都自动执行。

自动执行通过 xorg.conf.d 钩子执行,添加 90-touchscreen-calibrator.conf 到 /etc/X11/xorg.conf.d/ 目录中。

evdev

示例内容如下:

Section "InputClass"

Identifier "calibration"

MatchProduct "SYNA2393:00 06CB:19AC"

Option "Calibration" "2 3021 -7 2015"

Option "SwapAxes" "0"

EndSection

libinput

示例内容如下:

Section "InputClass"

Identifier "calibration"

MatchProduct "SYNA2393:00 06CB:19AC"

Option "CalibrationMatrix" "-43.0 0.0 47.9 0.0 0.1 0.0 0.0 0.0 1.0"

EndSection

设备映射

若存在多块屏幕,这时就需要指定触摸屏对应的设备,使用 xinput --map-output-to 。

device name 就是上文中得到的 id , output name 可通过 xrandr 命令得到。

持久化

可添加 90-touchscreen-map 到 /etc/X11/xinit/xinitrc.d 目录,内容就是上面的命令。

参考文档

man 4 evdev : 需要安装 xserver-xorg-input-evdev

man 4 libinput : 需要安装 xserver-xorg-input-libinput

触摸矫正+android,触摸屏校正相关推荐

  1. android触摸屏坐标转换,(转)android触摸屏校正详解

    最近一段时间在搞android的触摸屏校正,想把心得记下来与大家分享,废话不多说,开始讲解. 注:调试使用的是 一.修改内核驱动 修改触摸屏驱动(kernel/drivers/input/touchs ...

  2. 触摸矫正+android,android触摸矫正解方程

    //修改方程系数 void CTouchDlg::calculate() { //UpdateData(TRUE); int a2=atoi(cs6);//左上 int b2=atoi(cs7); i ...

  3. android 触摸屏部分失灵,触摸屏失灵修复小技巧

    手机触摸屏失灵修复小技巧 1.直接关闭手机,然后静置几分钟后再开机看看,如果手机支持拆卸电池,那么最好将电池也拆下来. 2.使用USB数据线将手机与电脑连接,看看是否可以解决. 3.针对屏幕出现飘逸的 ...

  4. linux内核关闭触摸屏校准,触摸屏校正原理

    1,触摸屏校准通用方法 主要采用以下公式,实现触摸屏校正,其中XL, YL是显示屏坐标,XT, YT是触摸屏坐标, XL = XT*A+YT*B+C; YL = XT*D+YT*E+F;    公式( ...

  5. qt做标定软件_Qt Embedded 4.5.3 的移植和触摸屏校正

    在进行Qt/E的移植和触摸屏校正的实践过程中,不得不感慨一下国内的学术文章真是天下一大抄,想 找点有价值的资料还真得累个精疲力竭.可恶的是,转载的文章也不标明,搞得就像是自己原创的一样,其中有多少人真 ...

  6. Android触摸屏驱动屏幕翻转

    项目中移植了Android触摸屏驱动,后来需要把屏幕翻转180度,此时触摸的坐标是没有适配的,修改以下代码即可: frameworks/native/services/inputflinger/Inp ...

  7. 简述Android触摸屏手势识别

    很多时候,利用触摸屏的Fling.Scroll等Gesture(手势)操作来操作会使得应用程序的用户体验大大提升,比如用Scroll手势在 浏览器中滚屏,用Fling在阅读器中翻页等.在Android ...

  8. StereoRectify()函数定义及用法畸变矫正与立体校正

    畸变矫正是上一篇博文的遗留问题,当畸变系数和内外参数矩阵标定完成后,就应该进行畸变的矫正,以达到消除畸变的目的,此其一. 在该系列第一部分的博文中介绍的立体成像原理中提到,要通过两幅图像估计物点的深度 ...

  9. 双目摄像头立体成像(二)畸变矫正与立体校正

    一.立体校正的原因 **原因一:**当畸变系数和内外参数矩阵标定完成后,就应该进行畸变矫正,以达到消除畸变的目的. **原因二:**在立体成像原理中提到,要通过两幅图像估计物点的深度信息,就必须在两幅 ...

最新文章

  1. 沉思录---Windows Phone软件开发Beta版回首
  2. Linux下动态共享库加载时的搜索路径详解
  3. 如何绕过浏览器的弹窗拦截机制
  4. ARM的存储器映射与存储器重映射【转载】2009-12-14 10:29最近在用LPC2148,看到了一篇文章,感觉很有帮助,就转了过来。
  5. 2020牛客国庆集训派对day4 Arithmetic Progressions
  6. 2010-04-25 搞定aftr
  7. 【数据库系统】数据库体系结构
  8. TypeError at /**/ ** missing 1 required positional argument: '**'
  9. java 正则 关键字_正则表达式关键字
  10. Android开发中使用startActivityForResult()方法从Activity A跳转Activity B出现B退出时A也同时退出的解决办法...
  11. Python操作Redis:键(Key)
  12. spring boot的gradle整合日志
  13. 【Android】 开发即时聊天工具 YQ (仿QQ) 教程:目录
  14. imx6 linux内核定义debug口,IMX6Q 调试串口修改
  15. [IOS APP]婷婷诗教-有声系列
  16. Word中如何删除某一页的页眉与页眉中的横线
  17. 英语语法新思维 总结 问答对形式
  18. 已经开源的阿里云播放器的播放内核
  19. 生成基于STM32f103zet6的宠物自动投食机的代码,实现定时、定量、自动的投食,并可以通过Tlink物联网平台控制投食机投喂食物和查看投食机的投喂状态...
  20. css js html 实现滚动字幕

热门文章

  1. CRUD Operations Using the Generic Repository Pattern and Dependency Injection in MVC
  2. 全国大学生英语竞赛培训:听力、词汇语法、完形填空、阅读理解、翻译、改错、IQ题、大小作文、语法等部分快速得分、备战策略和获奖技巧讲解!
  3. cv2.rectangle()
  4. linux分区Error creating partition
  5. 六西格玛黑带培训找哪家好?-优思学院
  6. 小米pro安装ubuntu18.10 18.04后进入桌面卡住不动
  7. Python - 通过whl文件安装第三方库
  8. 基于Java+SpringBoot+Thymeleaf+Mysql二手交易网站系统设计与实现
  9. jenkins master 通过ThinBackup进行备份和恢复
  10. 扬帆优配|弹性增强 双向波动明显 人民币汇率走势将回归基本面