【图形显示】扩展屏模式,触摸点较准不准确

扩展屏模式,触摸点较准不准确,克隆屏模式,触摸点较准准确。

# 多屏下的设备映射
xinput map-to-output       [触摸屏id(通过 xinput 获取),如 15]        [显示接口(通过 xrandr 获取),如 VGA]

# 持久化问题
# 在 /etc/X11/xinit/xinitrc.d/ 目录中添加 90-touchscreen-map 文件,文件内容就是上述命令。

# 参考文档
# man 4 evdev

使用以上命令将触摸设备映射到正确的显示接口以后,扩展屏模式,触摸点正确,克隆模式触摸点较准不再准确。

查看使用的驱动:/var/log/Xorg.0.log

使用的是 evdev 驱动的话,安装包是:xserver-xorg-input-evdev

 

修正脚本示例:

#! /bin/bash
#------------------------------------------------------------------------------
# Filename:    repairTouchscreen.sh
# Usage:       ./repairTouchscreen.sh
# Version:     1.0
# Date:        2018-03-29
# Author:      vincent
# Email:       N/A
# Description: 此脚本用于修复Ubuntu下,扩展触摸显示器,触摸扩展屏操作主屏的错误
# Notes:       N/A
#-------------------------------------------------------------------------------

outputErrorMsg()
{
    if [ $1 -ne 0 ]
    then
        echo $2
        exit
    fi
}

declare SCREEN_COUNTS          # 当前显示器的总数
declare ACTIVE_SCREEN_COUNTS   # 当前活跃的显示器数量
declare SCREEN_NAME            # 显示器的输出名称
declare TOUCH_DEVICE_ID        # 触摸设备ID号

SCREEN_COUNTS=$(xrandr --listmonitors | wc -l)
outputErrorMsg $? "Get screen counts failed!"
SCREEN_COUNTS=`expr $SCREEN_COUNTS - 1`

ACTIVE_SCREEN_COUNTS=$(xrandr --listactivemonitors | wc -l)
outputErrorMsg $? "Get active screen counts failed!"
ACTIVE_SCREEN_COUNTS=`expr $ACTIVE_SCREEN_COUNTS - 1`

if [ $ACTIVE_SCREEN_COUNTS -ge 3 ] # 如果当前活跃的显示器数量多于2个,退出
then
    outputErrorMsg 1 "There are currently three monitors, please reduce to two monitors!"
fi

if [ $ACTIVE_SCREEN_COUNTS -eq 1 ] # 如果只有一个活跃的显示器,退出
then
    outputErrorMsg 1 "There are only one monitor!"
fi
# 如果是两个屏幕,那么第一个是主屏幕,第二个是辅助屏幕
SCREEN_NAME=($(xrandr --listactivemonitors | awk '{if(NR > 1) {print $4}}'))
outputErrorMsg $? "Get screen name failed!"

TOUCH_DEVICE_ID=$(xinput | grep -iw touch) # 获取可触摸设备

if [ -z "$TOUCH_DEVICE_ID" ]
then
    outputErrorMsg 1 "There is no touch device!"
fi

TOUCH_DEVICE_ID=$(echo ${TOUCH_DEVICE_ID#*id=})
TOUCH_DEVICE_ID=$(echo ${TOUCH_DEVICE_ID%% *})   # 最终获取id号

if [ -z "$TOUCH_DEVICE_ID" ]
then
    outputErrorMsg 1 "Device id is empty!"
fi

xinput map-to-output $TOUCH_DEVICE_ID ${SCREEN_NAME[1]}
xrandr --listactivemonitors
echo "Setting successful!"

以下是 Xorg 7.x xorg.conf 的示例配置:

Section "InputDevice"
    Identifier "touchscreen"
    Driver    "plpevtch"

    Option "Device" "/dev/input/event3"	# <-- use the evdev name
					# see /proc/bus/input/devices for your eventX
    
#    Option "Calibrate" 	# <-- uncomment this line to calibrate
#    Option "Debug" 		# <-- uncomment this line for debug

#    Option "MinX" "67"
#    Option "MaxX" "1984"

#    Option "MinY" "42"
#    Option "MaxY" "1920"

#    Option "InvX"		# <-- uncomment this line to invert X
#    Option "InvY"		# <-- uncomment this line to invert Y

#    Option "RightClick" 	"False"	# <-- uncomment this line to disable right click
					# right click is enabled by default
#    Option "RightClickMS" 	"5000"	# make right click after 5 seconds without moving the cursor
					# default is 3 seconds
#    Option "RightClickSquare"  "10"	# allow moving in a square of 10x10 pixels when waiting for
					# right click
					
#    Option "TouchFilter" 	"False"	# <-- uncomment this line to disable touch filter
					# touch filter is enabled by default
#    Option "TouchFilterMS" 	"20"	# ignore press/release within 20ms, default is 10ms

#    Option "SwapAxes" 		"True"	# swap X/Y axis

#    Option "GrabDevice"        "True"  # force  a  grab on the event device. Doing so will ensure that no
	                                # other driver can initialise the same device
EndSection    

Xorg 配置文件示例:

Section"ServerLayout"//定义显示屏的关系及显示方式,定义输入设置
Identifier "Layout0"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" RightOf"Screen0"
InputDevice "Keyboard0""CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
InputDevice “Penmount”
Option “AlwaysCore" "1"
Option "Xinerama" "0"//设置为不扩展方式,1为扩展
EndSection

Section"Files"
EndSection

Section “InputDevice"
Identifier "Penmount"
Driver "penmount"
Option "Device” "/dev/input/event5"
Option "ConfigFile” "/etc/penmount.dat"
Option "Protocol" “PM6000USB"
EndSection

Section"InputDevice"//输入设备驱动
# generated from default
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device""/dev/psaux"
Option "Emulate3Buttons""no"
Option "ZAxisMapping" "45"
EndSection

Section"InputDevice"//输入设备定义
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection

Section"Monitor"//显示器0定义
# HorizSync source: edid, VertRefreshsource: edid
Identifier "Monitor0"
VendorName "Unknown"
ModelName "DELL E1909W"
HorizSync 30.0 - 83.0 //行频,与显示屏的属性有关
VertRefresh 56.0 - 75.0 //场频
Option "DPMS"
EndSection

Section"Monitor"//显示器1定义
# HorizSync source: edid, VertRefreshsource: edid
Identifier "Monitor1"
VendorName "Unknown"
ModelName "DELL E2211H"
HorizSync 30.0 - 83.0
VertRefresh 56.0 - 76.0
Option "DPMS"//Display Power Management Signaling,可降低显示器的功耗
EndSection

Section"Device"//显示器0显卡驱动设定
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce 310"
BusID "PCI:1:0:0" //这个跟PCI与电脑的相连的接口有关,不同的接口会不同,这个参数很重要,设置不正确会造成不能指定屏幕输出,但具体怎么用命令得出这个参数还找不到,但可以通过nvidia-setconfigs 上面得出。
Screen 0
EndSection

Section"Device"//显示器1显卡驱动设定
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce 310"
BusID "PCI:1:0:0"
Screen 1
EndSection

Section"Screen"//屏幕0定义
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24 //缺省颜色深度
Option "Stereo" "0"
Option "nvidiaXineramaInfoOrder""DFP-0"
Option "metamodes" "DFP:1152x864_75 +0+0"
SubSection "Display"
Depth 24
EndSubSection
EndSection

Section"Screen"//屏幕1定义
Identifier "Screen1"
Device "Device1"
Monitor "Monitor1"
DefaultDepth 24
Option "Stereo" "0"
Option "nvidiaXineramaInfoOrder""CRT-1"
Option "metamodes" "CRT:1152x864_75 +0+0"//分辨率,刷新率设置,+0+0位置设置
SubSection "Display"
Depth 24
EndSubSection
EndSection

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值