zoukankan      html  css  js  c++  java
  • I.MX6 linux Qt 同时支持Touch、mouse

    /*****************************************************************************
     *                  I.MX6 linux Qt 同时支持Touch、mouse
     * 声明:
     *     在Qt上,有时候当没有Touch的时候,我们会希望鼠标还是能够使用的,于是乎
     * 这又变成了一个看上去必须的需求了,所以这也就变成了一个需要解决的问题,当然
     * 这又解决Touch存在还是不存在的问题,以及如何跟mouse共存的问题。
     *
     *                                          2016-1-13 深圳 南山平山村 曾剑锋
     ****************************************************************************/
    
    
    一、参考文档:
        1. Qt移植对USB鼠标键盘、触摸屏的支持
            http://blog.csdn.net/sno_guo/article/details/16897577
        2. QT 同时支持鼠标和触摸屏
            http://www.cnblogs.com/leaven/archive/2010/11/24/1886774.html
    
    二、/etc/profile修改:
        ......
        # 计数值的上限,仅仅是为了方便修改,不用到代码里去修改这个值
        limitForWaitTime=80
        # 循环计数
        waitTimeCount=0
        while [ -z $touchEvent ]
        do
            inputCheckLine=`cat /proc/bus/input/devices | grep -n "Vendor=0eef" | grep "Product=0020 Version=0001"| awk -F: '{print $1}'`
            touchEvent=`sed -n "$((${inputCheckLine}+5))p" /proc/bus/input/devices | grep -o "event."`
            echo "please hang up USB TOUCH !"
            waitTimeCount=$((waitTimeCount+1))
            if [ $waitTimeCount -gt $limitForWaitTime ]; then
                break
            fi
            usleep 1000
        done
        
        ......
        
        export TSLIB_ROOT=/usr/local/tslib-instal
        export TSLIB_CALIBFILE=/etc/pointercal   
        export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf    
        export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts 
        export TSLIB_FBDEVICE=/dev/fb0   
        export PATH=/usr/local/tslib-instal:$PATH
        export LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.8.5-arm/lib
        export QT_QWS_FONTDIR=/usr/local/Trolltech/QtEmbedded-4.8.5-arm/lib/fonts
        
        # 注释掉的内容,会导致如下错误:
        #     -sh: [: argument expected
        #if [ -f /etc/pointercal -o -z $touchEvent ];then
        if [ -f /etc/pointercal ] || [ -z $touchEvent ];then
            echo "MXS touchscreen have calibrate!"
        else 
            # 这里一定不能用注释的这两行,否则会导致ts_calibrate闪退
            #export TSLIB_TSDEVICE="tslib:/dev/input/${touchEvent}"
            #export QWS_MOUSE_PROTO="tslib:/dev/input/${touchEvent}"
            export TSLIB_TSDEVICE=/dev/input/${touchEvent}
            export QWS_MOUSE_PROTO=/dev/input/${touchEvent}
            /usr/local/tslib-instal/bin/ts_calibrate
            sync
        fi
        
        # 注释掉的内容,如果系统运行起来之后,还没有插入鼠标,会导致如下错误:
        #     Error opening mouse device '/dev/input/mouse0': No such file or directory
        # ts_devices="mouseman:/dev/input/mouse0"
        ts_devices="mouseman:/dev/input/mice"
        if [ ! -z $touchEvent ]; then
    
            export TSLIB_TSDEVICE=/dev/input/${touchEvent}
    
            # 注释掉的内容写法会导致如下错误:
            #     -sh: ts_devices+= tslib:/dev/input/event4: No such file or directory
            #ts_devices+=" tslib:/dev/input/${touchEvent}"
    
            # 注释掉的内容,如果系统运行起来之后,还没有插入鼠标,会导致如下错误:
            #     Error opening mouse device '/dev/input/mouse0': No such file or directory
    # 看到有些地方写:MouseMan
    # 有些地方写:tslib MouseMan #ts_devices
    ="mouseman:/dev/input/mouse0 tslib:/dev/input/${touchEvent}" ts_devices="mouseman:/dev/input/mice tslib:/dev/input/${touchEvent}" fi export QWS_MOUSE_PROTO=$ts_devices ......
  • 相关阅读:
    云图小助理
    ping包的checksum校验和
    ftp相关
    初始化字符串
    安全的域名解析
    10进制转62进制
    centos6一键安装WordPress
    CEF3编译
    一次性生产KEY
    linux系统问题排查
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/5128347.html
Copyright © 2011-2022 走看看