少于 1 分钟阅读 次阅读

查看触摸设备

xinput list

通过 X11 配置文件实现

直接在 X Window 系统的配置目录中添加一个针对该设备的规则文件。这种方法最底层,不仅登录后生效,在登录界面(如 LightDM/GDM)也能生效。

  • 打开终端,使用 root 权限创建一个新的配置文件:
sudo mkdir -p /etc/X11/xorg.conf.d/

sudo nano /etc/X11/xorg.conf.d/99-touchscreen-calibration.conf
  • 在文件中填入以下内容: 注意:Xorg 的 MatchProduct 支持子字符串匹配。为了避免空格导致的匹配错误,建议直接抓取最核心、唯一性最强的关键词。改为xinput list看到的触摸设备。
    Section "InputClass"
      Identifier "Rotate Touchscreen"
      MatchProduct "ILITEK ILITEK-TP Mouse"
      Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
    EndSection
    
  • 保存并退出(在 nano 中按 Ctrl+O,回车,然后 Ctrl+X)。
  • 重启系统。X Server 启动时会自动加载这个矩阵设置。

矩阵配置

屏幕旋转方向 坐标变换矩阵 (Coordinate Transformation Matrix)
正常 (0° / Normal) 1 0 0 0 1 0 0 0 1
向左旋转 (90° / 270° / Left) 0 1 0 -1 0 1 0 0 1
向右旋转 (90° / Right) 0 -1 1 1 0 0 0 0 1
倒转 (180° / Inverted) -1 0 1 0 -1 1 0 0 1

留下评论