linux系统屏幕触摸校准

1、安装工具

xinput-calibrator工具:sudo apt-get install xinput-calibrator

xinput工具:sudo apt-get install xinput

2、校准实例

(1)查看触摸设备id:xinput_calibrator --list

上面可知:device name:ILITEK ILITEK-TP,device id:11

(2)校准触摸设备:xinput_calibrator -v --device <device name or id>

        此处为xinput_calibrator -v --device 11

(3)在显示的屏幕触摸校准页面进行页面校准,终端会输出屏幕校准后的数据

(4)将屏幕校准数据根据提示复制至/etc/X11/xorg.conf.d/目录下的99-touchscreen-evdev.conf文件中,部分发行版系统下的路径为/usr/share/X11/xorg.conf.d/。如果没有99-touchscreen-evdev.conf文件可手动创建一个。

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ILITEK ILITEK-TP"
        Option  "MinX"  "20207"
        Option  "MaxX"  "20343"
        Option  "MinY"  "52844"
        Option  "MaxY"  "54101"
        Option  "SwapXY"        "1" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
EndSection

(5)重启系统校准生效

3、相关问题

(1)屏幕旋转后校准未跟着旋转的问题

  • 屏幕顺时针旋转270度时,添加Option  "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"至99-touchscreen-evdev.conf,文件内容如下
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ILITEK ILITEK-TP"
        Option  "MinX"  "20207"
        Option  "MaxX"  "20343"
        Option  "MinY"  "52844"
        Option  "MaxY"  "54101"
        Option  "SwapXY"        "1" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
        Option  "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
EndSection
  • 屏幕顺时针旋转180度时,添加Option  "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"至99-touchscreen-evdev.conf
  • 屏幕顺时针旋转270度时,添加Option  "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"至99-touchscreen-evdev.conf

(2)校准不准的问题

  • 上下相反,比如点击左上角,反馈至左下角,类似于Y轴方向改变

        99-touchscreen-evdev.conf文件中Option的InvertY值:"0"改为"1"

  • 左右相反,比如点击左上角,反馈至右上角,类似于X轴方向改变

        99-touchscreen-evdev.conf文件中Option的InvertX值:"0"改为"1"

  • XY相反,比如点击左上角,反馈至右下角,类似于X、Y轴方向改变

        99-touchscreen-evdev.conf文件中Option的SwapXY值:"0"改为"1"

  • 边缘偏移,比如点击最外侧,反馈却在旁边,说明位置点未设置准确

        修改99-touchscreen-evdev.conf文件中Option的MinX、MaxX、MinY、MaxY值,修改尝试一下

  • 6
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
以下是两种Linux触摸校准的方法: 1. 使用tslib编写触摸校准程序 如果你使用的是嵌入式Linux系统,并且已经安装了QT5.6版本和tslib库,你可以编写一个触摸校准程序。以下是一个示例程序: ```c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <linux/input.h> #include <tslib.h> #define DEVICE_NAME "/dev/input/event0" #define CALIBRATION_FILE "/etc/pointercal" int main(int argc, char *argv[]) { struct tsdev *ts; struct ts_sample samp[5]; int fd, i; struct ts_sample *calib; struct ts_sample *calib_result; int xres, yres; ts = ts_open(DEVICE_NAME, 0); if (!ts) { perror("ts_open"); exit(1); } if (ts_config(ts)) { perror("ts_config"); exit(1); } calib = malloc(sizeof(struct ts_sample) * 5); calib_result = malloc(sizeof(struct ts_sample) * 5); printf("Please touch the screen at the center of the cross.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i] = samp[i]; } calib_result[2].x = xres / 2; calib_result[2].y = yres / 2; printf("Please touch the screen at the top-left corner of the screen.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i].x = samp[i].x; calib[i].y = samp[i].y; } calib_result[0].x = 0; calib_result[0].y = 0; printf("Please touch the screen at the bottom-right corner of the screen.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i].x = samp[i].x; calib[i].y = samp[i].y; } calib_result[4].x = xres - 1; calib_result[4].y = yres - 1; printf("Please touch the screen at the top-right corner of the screen.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i].x = samp[i].x; calib[i].y = samp[i].y; } calib_result[1].x = xres - 1; calib_result[1].y = 0; printf("Please touch the screen at the bottom-left corner of the screen.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i].x = samp[i].x; calib[i].y = samp[i].y; } calib_result[3].x = 0; calib_result[3].y = yres - 1; ts_close(ts); fd = open(CALIBRATION_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) { perror("open"); exit(1); } dprintf(fd, "%d %d %d %d %d %d %d %d %d\n", calib_result[0].x, calib_result[0].y, calib_result[1].x, calib_result[1].y, calib_result[2].x, calib_result[2].y, calib_result[3].x, calib_result[3].y, calib_result[4].x, calib_result[4].y); close(fd); printf("Calibration data saved to %s.\n", CALIBRATION_FILE); return 0; } ``` 2. 使用xinput_calibrator命令行工具校准触摸设备 如果你使用的是Linux桌面系统,你可以使用xinput_calibrator命令行工具校准触摸设备。以下是一个示例命令: ``` xinput_calibrator -v --device <device name or id> ``` 其中,`<device name or id>`是你要校准触摸设备的名称或ID。你可以使用`xinput list`命令查看所有输入设备的列表。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林中云雾

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值