美文网首页ubuntu16.04
ubuntu 触摸功能相关

ubuntu 触摸功能相关

作者: 沈祥佑 | 来源:发表于2019-04-20 14:48 被阅读21次

    通过xinput先查看一些都有哪些设备

    $xinput     #或者 xinput list
    

    显示结果如下:

    ⎡ Virtual core pointer                          id=2    [master pointer  (3)]
    ⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
    ⎜   ↳ Beijing Qltouch Tech Co.,LtD   USB TouchScreen    id=10   [slave  pointer  (2)]
    ⎜   ↳ Arduino LLC Arduino Leonardo              id=11   [slave  pointer  (2)]
    ⎜   ↳ Logitech USB Receiver                     id=13   [slave  pointer  (2)]
    ⎜   ↳ Beijing Qltouch Tech Co.,LtD   USB TouchScreen    id=9    [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)]
        ↳ Logitech USB Receiver                     id=12   [slave  keyboard (3)]
        ↳ Intel HID events                          id=14   [slave  keyboard (3)]
        ↳ gpio-keys                                 id=15   [slave  keyboard (3)]
        ↳ gpio-keys                                 id=16   [slave  keyboard (3)]
    
    

    查看设备属性,10为我的设备ID,也可直接使用设备名:

    $xinput list-props 10
    
    

    输出如下:

    Device 'Beijing Qltouch Tech Co.,LtD   USB TouchScreen':
            Device Enabled (142):   1
            Coordinate Transformation Matrix (144): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
            Device Accel Profile (271):     0
            Device Accel Constant Deceleration (272):       1.000000
            Device Accel Adaptive Deceleration (273):       1.000000
            Device Accel Velocity Scaling (274):    10.000000
            Device Product ID (260):        6829, 15
            Device Node (261):      "/dev/input/event9"
            Evdev Axis Inversion (275):     0, 1
            Evdev Axis Calibration (276):   <no items>
            Evdev Axes Swap (277):  1
            Axis Labels (278):      "Abs MT Position X" (294), "Abs MT Position Y" (295), "None" (0), "None" (0)
            Button Labels (279):    "Button Unknown" (263), "Button Unknown" (263), "Button Unknown" (263), "Button Wheel Up" (148), "Button Wheel Down" (149)
            Evdev Scrolling Distance (280): 0, 0, 0
            Evdev Middle Button Emulation (281):    0
            Evdev Middle Button Timeout (282):      50
            Evdev Middle Button Button (283):       2
            Evdev Third Button Emulation (284):     0
            Evdev Third Button Emulation Timeout (285):     1000
            Evdev Third Button Emulation Button (286):      3
            Evdev Third Button Emulation Threshold (287):   20
            Evdev Wheel Emulation (288):    0
            Evdev Wheel Emulation Axes (289):       0, 0, 4, 5
            Evdev Wheel Emulation Inertia (290):    10
            Evdev Wheel Emulation Timeout (291):    200
            Evdev Wheel Emulation Button (292):     4
           Evdev Drag Lock Buttons (293):  0
    

    用过set-porp来设置设备的属性。

    禁用触摸板
    xinput set-prop 14 'Device Enabled' 0  #通过设备编号+属性名禁用触摸板
    
    xinput set-prop 'Beijing Qltouch Tech Co.,LtD   USB TouchScreen' 'Device Enabled' 0 #通过设备名+属性名禁用触摸板
    
    启用触摸板
    xinput set-prop 14 132 1 #通过设备编号+属性编号来设置
    
    xinput set-prop 'Beijing Qltouch Tech Co.,LtD   USB TouchScreen' 132 1 #通过设备名+属性编号启用
    

    刚才说了在我的电脑设备“Beijing Qltouch Tech Co.,LtD USB TouchScreen”和14是等价的,Device Enabled和132是等价的,所以两者可以替代,于是敲命令的时候可以偷懒下。不过像这样看着比较直观这个命令到底是干什么。

    xinput set-prop 'Beijing Qltouch Tech Co.,LtD   USB TouchScreen' 'Device Enabled' 0
    

    通过脚本快速启用和禁用触摸板

    每次如果都敲命令也是比较麻烦的,通过脚本就很快的切换了。

    #!/bin/bash
    if [ $1 == 'on' ]
    then
        set-prop ' Beijing Qltouch Tech Co.,LtD   USB TouchScreen ' 1
        echo "触摸板开启成功!"
    elif [ $1 == 'off' ]
    then
        set-prop ' Beijing Qltouch Tech Co.,LtD   USB TouchScreen ' 0
        echo "触摸板关闭成功!"
    else
        echo "请输入参数:on/off"
        echo "开启触摸板:touchpadEnable on"
        echo "禁用触摸板:touchpadEnable off"
    fi
    

    通过禁用触摸板,确实给我解决了不少的麻烦。
    开机自动禁用触摸板

    但是这样在开机重启后又恢复了,对有些同学喜欢关机而不是休眠的同学确实还要改进,就是让开机的时候自动运行禁用触摸板的命令。
    ~/.config/autostart/下创建一个启动器xinput.desktop文件,内容如下

    [Desktop Entry]
    Type=Application
    Exec=xinput set-prop ' Beijing Qltouch Tech Co.,LtD   USB TouchScreen ' 'Device Enabled' 0
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name[zh_CN]=touchpad enable
    Name=touchpad enable
    Comment[zh_CN]=禁用触摸板
    Comment=禁用触摸板
    

    这样在开机的时候就能自动禁用触摸板了。

    触摸屏横屏变竖屏解决

    • 交换x、y轴
      xinput --set-prop '7' 'Evdev Axes Swap' 1           // 7为我当时的端口id,会变化。  用名字代替也可以。
    
    • 反转y轴
      xinput --set-prop '7' 'Evdev Axis Inversion' 0 1
    

    目录: /usr/share/X11/xorg.conf.d/ 10-evdev.conf 界面显示的配置文件,可以通过这个文件调整触摸点。看清楚再改有风险。

    校准命令 : xinput_calibrator 然后开始点击确定触摸屏,完成后输出如下:

    Setting calibration data: 0, 32767, 0, 32767
    Calibrating EVDEV driver for "Touch Touch Device F47WH00U-CT-A1-2P" id=10
    current calibration values (from XInput): min_x=0, max_x=32767 and min_y=0, max_y=32767
    
    
    Doing dynamic recalibration:
    Inverting X and/or Y axis...
    Setting calibration data: -23, 32805, 32710, -11
    --> 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 "Touch Touch Device F47WH00U-CT-A1-2P"
    Option "Calibration" "-23 32805 32710 -11"
    Option "SwapAxes" "1"
    EndSection
    

    如需更改在 Driver "evdev" 下面添加 矫正输出 Option "Calibration" "-23 32805 32710 -11" 。

            Section "InputClass"
            Identifier "evdev touchscreen catchall"
            MatchIsTouchscreen "on"
            MatchDevicePath "/dev/input/event*"
             Driver "evdev"
    
            EndSection
    

    相关文章

      网友评论

        本文标题:ubuntu 触摸功能相关

        本文链接:https://www.haomeiwen.com/subject/ehtlgqtx.html