多显示器单触摸屏屏幕校准

0、触摸屏重定向

sudo xinput map-to-output 13 DP1  #将触摸屏映射到指定的显示器

  其中:13为触摸屏设备id,可通过 xinput命令查看  ILITEK ILITEK-TP id=13 [slave pointer (2)];

     DP1为指定的显示设备名,可通过$ xrandr命令查看,见最下面附件。

1、安装屏幕校准器
$ sudo apt-get install xinput-calibrator

2、查看屏幕分辨率
在 System settings –> Display 查看屏幕分辨率

3、手动设置校准窗口的大小(有多个显示器而只有一个触摸屏时用的,用于设置只指定窗口)

  我的电脑有两个显示器,一个 1920×1080, 一个 1024×768,我只校准左边的显示器,如
Usage:xinput_calibrator –geometry <w>x<h>
–geometry: manually provide the geometry (width and height) for the calibration window

$ sudo xinput_calibrator –geometry 1920×1080    注意:1920×1080 此处是字母x 

Warning: multiple calibratable devices found, calibrating last one (ILITEK ILITEK-TP)
use –device to select another one.
Setting calibration data: 0, 16384, 0, 9600
Calibrating EVDEV driver for “ILITEK ILITEK-TP” id=14
current calibration values (from XInput): min_x=0, max_x=16384 and min_y=0, max_y=9600

Doing dynamic recalibration:
Setting calibration data: 82, 32942, 155, 9796
–> Making the calibration permanent <–
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 “ILITEK ILITEK-TP”
Option “Calibration” “82 32942 155 9796”
Option “SwapAxes” “0”
EndSection

我的电脑是在/usr/share/X11/xorg.conf.d/目录下

4、按提示说明 拷贝校正信息到下面的文件中:
sudo gedit /usr/share/X11/xorg.conf.d/99-calibration.conf
将 下面的内容拷贝进去
Section “InputClass”
Identifier “calibration”
MatchProduct “ILITEK ILITEK-TP”
Option “Calibration” “82 32942 155 9796”
Option “SwapAxes” “0”
EndSection

5、完成。

附录:---相关的常用命令-------------------

1、查看 xinput_calibrator 使用方法
$ xinput_calibrator -h
xinput_calibrator, v0.7.5

Usage: xinput_calibrator [-h|–help] [-v|–verbose] [–list] [–device <device name or XID or sysfs path>] [–precalib <minx> <maxx> <miny> <maxy>] [–misclick <nr of pixels>] [–output-type <auto|xorg.conf.d|hal|xinput>] [–fake] [–geometry <w>x<h>] [–no-timeout]
-h, –help: print this help message
-v, –verbose: print debug messages during the process
–list: list calibratable input devices and quit
–device <device name or XID or sysfs event name (e.g event5)>: select a specific device to calibrate
–precalib: manually provide the current calibration setting (eg. the values in xorg.conf)
–misclick: set the misclick threshold (0=off, default: 15 pixels)
–output-type <auto|xorg.conf.d|hal|xinput>: type of config to output (auto=automatically detect, default: auto)
–fake: emulate a fake device (for testing purposes)
–geometry: manually provide the geometry (width and height) for the calibration window
–no-timeout: turns off the timeout
–output-filename: write calibration data to file (USB: override default /etc/modprobe.conf.local

2、查看输入设备
$ xinput

⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver id=11 [slave pointer (2)]
⎜ ↳ ILITEK ILITEK-TP id=13 [slave pointer (2)]
⎜ ↳ ILITEK ILITEK-TP id=14 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Logitech USB Receiver id=10 [slave keyboard (3)]
↳ USB2.0 Camera
id=12 [slave keyboard (3)]

3、查看输出设备
$ xrandr
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
DP1 connected primary 1920×1080+0+0 (normal left inverted right x axis y axis) 521mm x 293mm
1920×1080 60.0*+
1680×1050 60.0
1280×1024 75.0 60.0
1440×900 59.9
1280×960 60.0
1280×720 60.0
1024×768 75.1 70.1 60.0
832×624 74.6
800×600 72.2 75.0 60.3 56.2
640×480 75.0 72.8 66.7 60.0
720×400 70.1
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)