Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

tslib vs. evdevtouch



  • I have a problem getting my very simple Qt test app working with an eGalax touchscreen.

    I am able to see & use the device via evtest.

    root@petalinux:/tmp# evtest
    No device specified, trying to scan all of /dev/input/event*
    Available devices:
    /dev/input/event0:      eGalax Inc. USB TouchController Pen
    /dev/input/event1:      eGalax Inc. USB TouchController
    Select the device event number [0-1]: 
    root@petalinux:/tmp#
    

    Yet, when I start my app I get no touch events..

    Here is what the debug output from my Qt test app show. It has been edited for brevity.

    
    root@petalinux:/tmp#
    root@petalinux:/tmp#
    root@petalinux:/tmp#
    root@petalinux:/tmp#
    root@petalinux:/tmp#
    root@petalinux:/tmp# /tmp/qt-test-app
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqlinuxfb.so"
    Found metadata in lib /usr/lib/plugins/platforms/libqlinuxfb.so, metadata=
    
    <stuff deleted>
    
    Got keys from plugin meta data ("linuxfb")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqminimal.so"
    Found metadata in lib /usr/lib/plugins/platforms/libqminimal.so, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "minimal"
            ]
        },
        "className": "QMinimalIntegrationPlugin",
        "debug": false,
        "version": 329219
    }
    
    
    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqoffscreen.so"
    Found metadata in lib /usr/lib/plugins/platforms/libqoffscreen.so, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "offscreen"
            ]
        },
        "className": "QOffscreenIntegrationPlugin",
        "debug": false,
        "version": 329219
    }
    
    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/var/volatile/tmp" ...
    loaded library "/usr/lib/plugins/platforms/libqlinuxfb.so"
    qt.qpa.input: evdevtouch: Adding device at "/dev/input/event1"
    qt.qpa.input: evdevtouch: Using device /dev/input/event1
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/platforms/generic" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/generic" ...
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/generic/libqevdevkeyboardplugin.so"
    Found metadata in lib /usr/lib/plugins/generic/libqevdevkeyboardplugin.so, metadata=
    {
        "IID": "org.qt-project.Qt.QGenericPluginFactoryInterface",
        "MetaData": {
            "Keys": [
                "EvdevKeyboard"
            ]
        },
        "className": "QEvdevKeyboardPlugin",
        "debug": false,
        "version": 329219
    }
    
    
    Got keys from plugin meta data ("evdevkeyboard")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/generic/libqevdevmouseplugin.so"
    Found metadata in lib /usr/lib/plugins/generic/libqevdevmouseplugin.so, metadata=
    {
        "IID": "org.qt-project.Qt.QGenericPluginFactoryInterface",
        "MetaData": {
            "Keys": [
                "EvdevMouse"
            ]
        },
        "className": "QEvdevMousePlugin",
        "debug": false,
        "version": 329219
    }
    
    
    Got keys from plugin meta data ("evdevmouse")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/generic/libqevdevtabletplugin.so"
    Found metadata in lib /usr/lib/plugins/generic/libqevdevtabletplugin.so, metadata=
    {
        "IID": "org.qt-project.Qt.QGenericPluginFactoryInterface",
        "MetaData": {
            "Keys": [
                "EvdevTablet"
            ]
        },
        "className": "QEvdevTabletPlugin",
        "debug": false,
        "version": 329219
    }
    
    
    Got keys from plugin meta data ("evdevtablet")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/generic/libqevdevtouchplugin.so"
    Found metadata in lib /usr/lib/plugins/generic/libqevdevtouchplugin.so, metadata=
    {
        "IID": "org.qt-project.Qt.QGenericPluginFactoryInterface",
        "MetaData": {
            "Keys": [
                "EvdevTouch"
            ]
        },
        "className": "QEvdevTouchScreenPlugin",
        "debug": false,
        "version": 329219
    }
    
    
    Got keys from plugin meta data ("evdevtouch")
    QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/generic/libqtuiotouchplugin.so"
    Found metadata in lib /usr/lib/plugins/generic/libqtuiotouchplugin.so, metadata=
    {
        "IID": "org.qt-project.Qt.QGenericPluginFactoryInterface",
        "MetaData": {
            "Keys": [
                "TuioTouch"
            ]
        },
        "className": "QTuioTouchPlugin",
        "debug": false,
        "version": 329219
    }
    
    
    Got keys from plugin meta data ("tuiotouch")
    QFactoryLoader::QFactoryLoader() checking directory path "/var/volatile/tmp/generic" 
     ...
    loaded library "/usr/lib/plugins/generic/libqevdevtouchplugin.so"
    qt.qpa.input: evdevtouch: Adding device at "/dev/input/event1"
    qt.qpa.input: evdevtouch: Using device /dev/input/event1
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/platforms/styles" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/styles" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/var/volatile/tmp/styles" ...
    qt.qpa.input: evdevtouch: /dev/input/event1: Protocol type B  (multi)
    qt.qpa.input: evdevtouch: /dev/input/event1: min X: 0 max X: 4095
    qt.qpa.input: evdevtouch: /dev/input/event1: min Y: 0 max Y: 4095
    qt.qpa.input: evdevtouch: /dev/input/event1: min pressure: 0 max pressure: 0
    qt.qpa.input: evdevtouch: /dev/input/event1: device name: eGalax Inc. USB TouchController
    qt.qpa.input: evdevtouch: /dev/input/event1: Protocol type B  (multi)
    qt.qpa.input: evdevtouch: /dev/input/event1: min X: 0 max X: 4095
    qt.qpa.input: evdevtouch: /dev/input/event1: min Y: 0 max Y: 4095
    qt.qpa.input: evdevtouch: /dev/input/event1: min pressure: 0 max pressure: 0
    qt.qpa.input: evdevtouch: /dev/input/event1: device name: eGalax Inc. USB TouchController
    QPainter::begin(), device=0x2d5e0, type=3
    QPainter::end()
    QPainter::begin(), device=0x2d5e0, type=3
    QPainter::end()
    QPainter::begin(), device=0x2d5e0, type=3
    QPainter::setPen(), color=ffffffff
    
    <bunch of Qt drawing primitives deleted>
    
    QPainter::setPen(), color=ff000000, (brushStyle=1) style=1, cap=16, join=64
    QPainter::end()
    QPainter::begin(), device=0x254d0, type=3
    QPainter::begin(), device=0x26938, type=3
    qt.qpa.input: evdevtouch: Updating QInputDeviceManager device count: 1  touch devices, 0 pending handler(s)
    qt.qpa.input: evdevtouch: Updating QInputDeviceManager device count: 1  touch devices, 0 pending handler(s)
    QPainter::begin(), device=0x2d5e0, type=3
    QPainter::end()
    QPainter::begin(), device=0x2d5e0, type=3
    QPainter::end()
    QPainter::begin(), device=0x2d5e0, type=3
    QPainter::setPen(), color=ffffffff
    QPainter::drawPolyline(), count=3
    QPainter::setPen(), color=ff767472
    QPainter::drawPolyline(), count=3
    
    <bunch of Qt drawing primitives deleted>
    
    QPainter::setBrush(), color=ff101418, style=5
    QPainter::setBrushOrigin(), (3.00,3.00)
    QPainter::drawRects(), count=1
    QPainter::drawRects(), count=1
    QPainter::drawRects(), count=1
    QPainter::drawRects(), count=1
    QPainter::restore()
    QPainter::end()
    ^C
    root@petalinux:/tmp#
    
    

    Any ideas/suggestions are most appreciated.

    Also, is tslib preferred over evdev for Qt use? If so, why is that?

    Thanks.

    -brad w.



  • @BradWalker

    Turned out my solution was to add the following options to the app when executing..

    -platform linuxfb -plugin evdevtouch
    

    All is finally good in my embedded Qt world.. 8-)


  • Lifetime Qt Champion

    Hi,

    Might be a silly question but are you sure that the plugin is using the right input device ?



  • @SGaist

    Not a silly question at all..

    But, I'm not sure how to check without grokking through the code..

    Suggestions are appreciated.



  • @BradWalker

    Turned out my solution was to add the following options to the app when executing..

    -platform linuxfb -plugin evdevtouch
    

    All is finally good in my embedded Qt world.. 8-)



  • Hello,
    I am going crazy to find out what the hell my resistive touch screen is not working in EGLFS but works in Xorg. I suppose because the Xorg configuration is going to use evdev and its calibration value in the Xorg.conf section:

    Section "InputClass"
    Identifier "calibration"
    MatchProduct "stmpe-ts"
    Option "Calibration" "77 4007 3796 107"
    Option "SwapAxes" "0"
    Option "InvertX" "true"
    Option "InvertY" "true"
    Driver "evdev"
    EndSection

    The touchscreen is mounted upside down due to constraints on lcd frame, that's why I inverted X and Y axis.
    Nevertheless it works great with Qt and Xorg using platform xcb. But is painfully slow.
    The CPU is a SystemOnChip iMX6 Dual running @ 800Mhz with a LVDS display of 1024x600 pixels. The touchscreen is a resistive touchscreen using driver stmpe-ts over i2c bus and its registered kernel driver is /dev/input/event0.

    evtest gives me the following data:

    Input driver version is 1.0.1
    Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
    Input device name: "stmpe-ts"
    Supported events:
    Event type 0 (EV_SYN)
    Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
    Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
    Value 1561
    Min 0
    Max 4095
    Event code 1 (ABS_Y)
    Value 972
    Min 0
    Max 4095
    Event code 24 (ABS_PRESSURE)
    Value 0
    Min 0
    Max 255
    Properties:
    Testing ... (interrupt to exit)
    Event: time 1593699540.159050, type 3 (EV_ABS), code 0 (ABS_X), value 2807
    Event: time 1593699540.159050, type 3 (EV_ABS), code 1 (ABS_Y), value 1834
    Event: time 1593699540.159050, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 54
    Event: time 1593699540.159050, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
    Event: time 1593699540.159050, -------------- SYN_REPORT ------------
    Event: time 1593699540.273889, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 0
    Event: time 1593699540.273889, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0

    So it is working for sure (in Xorg it works good).

    When using ELGFS it does not work at all.

    I am using a plain vanilla Debian Buster 10 with the official packages from Debian repositories.

    My environment variables are:
    CONSOLE="/dev/console"
    HOME="/root"
    LANG="en_US"
    LANGUAGE="en_US.UTF8"
    TZ=":Europe/Rome"
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    PWD="/root/QtApp"
    QT_LOGGING_RULES="qt.qpa.*=true"
    QT_QPA_EGLFS_ALWAYS_SET_MODE="1"
    QT_QPA_EGLFS_FB_TSLIB="0"
    QT_QPA_EGLFS_INTEGRATION="eglfs_kms"
    QT_QPA_EGLFS_KMS_CONFIG="kms.json"
    QT_QPA_EGLFS_NO_LIBINPUT="1"
    QT_QPA_EGLFS_PHYSICAL_HEIGHT="88"
    QT_QPA_EGLFS_PHYSICAL_WIDTH="156"
    QT_QPA_EGLFS_TSLIB="0"
    QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS="/dev/input/event0:rotate=180"
    QT_QPA_GENERIC_PLUGINS="evdevtouch:/dev/input/event0"
    QT_QPA_PLATFORM="eglfs"
    TSLIB_CALIBFILE="/etc/pointercal"
    TSLIB_CONFFILE="/etc/ts.conf"
    TSLIB_CONSOLEDEVICE="/dev/console"
    TSLIB_FBDEVICE="/dev/fb0"
    TSLIB_PLUGINDIR="/usr/lib/arm-linux-gnueabihf/ts0"
    TSLIB_TSDEVICE="/dev/input/event0"

    I have a very basic kms JSon file too as:
    {
    "device": "/dev/dri/card1",
    "pbuffers": true,
    "hwcursor": false,
    "outputs": [
    {
    "name" : "LVDS-1",
    "mode" : "auto"
    }
    ]
    }

    When launching my QML based QtApp here is the logs:

    qt.qpa.egldeviceintegration: EGL device integration plugin keys: ("eglfs_emu", "eglfs_kms_egldevice", "eglfs_kms", "eglfs_x11")
    qt.qpa.egldeviceintegration: EGL device integration plugin keys (sorted): ("eglfs_kms", "eglfs_emu", "eglfs_kms_egldevice", "eglfs_x11")
    qt.qpa.egldeviceintegration: Trying to load device EGL integration "eglfs_kms"
    qt.qpa.eglfs.kms: Loading KMS setup from "kms.json"
    qt.qpa.eglfs.kms: Requested configuration (some settings may be ignored):
    headless: false
    hwcursor: false
    pbuffers: true
    separateScreens: false
    virtualDesktopLayout: 0
    outputs: QMap(("LVDS-1", QMap(("mode", QVariant(QString, "auto"))("name", QVariant(QString, "LVDS-1")))))
    qt.qpa.eglfs.kms: New DRM/KMS via GBM integration created
    qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_kms"
    qt.qpa.eglfs.kms: platformInit: Opening DRM device
    qt.qpa.eglfs.kms: GBM: Using DRM device "/dev/dri/card1" specified in config file
    qt.qpa.eglfs.kms: Using backend-provided DRM device /dev/dri/card1
    qt.qpa.eglfs.kms: Creating GBM device for file descriptor 4 obtained from "/dev/dri/card1"
    qt.qpa.eglfs.kms: Querying EGLDisplay
    qt.qpa.eglfs.kms: Found 3 planes
    qt.qpa.eglfs.kms: plane 0: id = 28 countFormats = 34 possibleCrtcs = 0x1 supported formats = AR15 XR15 AB15 XB15 RA15 BA15 AR12 AR24 XR24 AB24 XB24 RA24 RX24 BA24 BX24 UYVY VYUY YUYV YVYU YU12 YV12 YU16 YV16 YU24 YV24 NV12 NV16 RG16 R5A8 B5A8 R8A8 B8A8 RXA8 BXA8
    qt.qpa.eglfs.kms: property 0: id = 7 name = 'type'
    qt.qpa.eglfs.kms: type is ENUM, value is 1, possible values are:
    qt.qpa.eglfs.kms: enum 0: Overlay - 0
    qt.qpa.eglfs.kms: enum 1: Primary - 1
    qt.qpa.eglfs.kms: enum 2: Cursor - 2
    qt.qpa.eglfs.kms: property 1: id = 27 name = 'IN_FORMATS'
    qt.qpa.eglfs.kms: type is BLOB
    qt.qpa.eglfs.kms: plane 1: id = 31 countFormats = 34 possibleCrtcs = 0x1 supported formats = AR15 XR15 AB15 XB15 RA15 BA15 AR12 AR24 XR24 AB24 XB24 RA24 RX24 BA24 BX24 UYVY VYUY YUYV YVYU YU12 YV12 YU16 YV16 YU24 YV24 NV12 NV16 RG16 R5A8 B5A8 R8A8 B8A8 RXA8 BXA8
    qt.qpa.eglfs.kms: property 0: id = 7 name = 'type'
    qt.qpa.eglfs.kms: type is ENUM, value is 0, possible values are:
    qt.qpa.eglfs.kms: enum 0: Overlay - 0
    qt.qpa.eglfs.kms: enum 1: Primary - 1
    qt.qpa.eglfs.kms: enum 2: Cursor - 2
    qt.qpa.eglfs.kms: property 1: id = 27 name = 'IN_FORMATS'
    qt.qpa.eglfs.kms: type is BLOB
    qt.qpa.eglfs.kms: plane 2: id = 33 countFormats = 34 possibleCrtcs = 0x2 supported formats = AR15 XR15 AB15 XB15 RA15 BA15 AR12 AR24 XR24 AB24 XB24 RA24 RX24 BA24 BX24 UYVY VYUY YUYV YVYU YU12 YV12 YU16 YV16 YU24 YV24 NV12 NV16 RG16 R5A8 B5A8 R8A8 B8A8 RXA8 BXA8
    qt.qpa.eglfs.kms: property 0: id = 7 name = 'type'
    qt.qpa.eglfs.kms: type is ENUM, value is 1, possible values are:
    qt.qpa.eglfs.kms: enum 0: Overlay - 0
    qt.qpa.eglfs.kms: enum 1: Primary - 1
    qt.qpa.eglfs.kms: enum 2: Cursor - 2
    qt.qpa.eglfs.kms: property 1: id = 27 name = 'IN_FORMATS'
    qt.qpa.eglfs.kms: type is BLOB
    qt.qpa.eglfs.kms: "LVDS1" mode count: 1 crtc index: 0 crtc id: 30
    qt.qpa.eglfs.kms: mode 0 1024 x 600 @ 57 hz
    qt.qpa.eglfs.kms: Selected mode 0 : 1024 x 600 @ 57 hz for output "LVDS1"
    qt.qpa.eglfs.kms: Physical size is QSizeF(156, 88) mm for output "LVDS1"
    qt.qpa.eglfs.kms: Output LVDS1 can use 2 planes: 28 31
    qt.qpa.eglfs.kms: Using plain OpenGL mouse cursor
    qt.qpa.eglfs.kms: No EDID data for output "LVDS1"
    qt.qpa.eglfs.kms: Sorted screen list: QVector(OrderedScreen(QPlatformScreen=0xe3e598 ("LVDS1") : 2147483647 / QPoint(0,0) / primary: false))
    qt.qpa.eglfs.kms: Adding QPlatformScreen 0xe3e598 ( "LVDS1" ) to QPA with geometry QRect(0,0 1024x600) and isPrimary= false
    qt.qpa.input: evdevkeyboard: Using device discovery
    qt.qpa.input: udev device discovery for type QFlagsQDeviceDiscovery::QDeviceType(Device_Keyboard)
    qt.qpa.input: Found matching devices ()
    qt.qpa.input: evdevmouse: Using device discovery
    qt.qpa.input: udev device discovery for type QFlagsQDeviceDiscovery::QDeviceType(Device_Mouse|Device_Touchpad)
    qt.qpa.input: Found matching devices ()
    qt.qpa.input: evdevtouch: Adding device at "/dev/input/event0"
    qt.qpa.input: evdevtouch: Using device /dev/input/event0
    qt.qpa.input: evdevtouch: /dev/input/event0: Protocol type B (mtdev) (multi), filtered=no
    qt.qpa.input: evdevtouch: /dev/input/event0: min X: 0 max X: 0
    qt.qpa.input: evdevtouch: /dev/input/event0: min Y: 0 max Y: 0
    qt.qpa.input: evdevtouch: /dev/input/event0: min pressure: 0 max pressure: 255
    qt.qpa.input: evdevtouch: /dev/input/event0: device name: stmpe-ts
    qt.qpa.input: evdevtouch: Adding device at "/dev/input/event0"
    qt.qpa.input: evdevtouch: Using device /dev/input/event0
    qt.qpa.input: evdevtouch: /dev/input/event0: Protocol type B (mtdev) (multi), filtered=no
    qt.qpa.input: evdevtouch: /dev/input/event0: min X: 0 max X: 0
    qt.qpa.input: evdevtouch: /dev/input/event0: min Y: 0 max Y: 0
    qt.qpa.input: evdevtouch: /dev/input/event0: min pressure: 0 max pressure: 255
    qt.qpa.input: evdevtouch: /dev/input/event0: device name: stmpe-ts
    ...
    qt.qpa.eglfs.kms: Creating gbm_surface for screen LVDS1
    qt.qpa.eglfs.kms: Got native format 34325258 from eglGetConfigAttrib() with return code true
    Cannot find EGLConfig, returning null config
    Cannot find EGLConfig, returning null config
    Cannot find EGLConfig, returning null config
    Cannot find EGLConfig, returning null config
    Cannot find EGLConfig, returning null config
    Cannot find EGLConfig, returning null config
    qt.qpa.eglfs.kms: Adding FB, size 1024x600, DRM format 0x34325258
    qt.qpa.eglfs.kms: Setting mode for screen LVDS1
    qt.qpa.input: evdevtouch: Updating QInputDeviceManager device count: 1 touch devices, 0 pending handler(s)
    qt.qpa.input: evdevtouch: Updating QInputDeviceManager device count: 1 touch devices, 0 pending handler(s)
    qt.qpa.eglfs.kms: Adding FB, size 1024x600, DRM format 0x34325258
    qt.qpa.eglfs.kms: Adding FB, size 1024x600, DRM format 0x34325258

    So why the evdev is looking two times for the touchscreen driver?

    Or why those lines:
    ...
    qt.qpa.input: evdevtouch: Updating QInputDeviceManager device count: 1 touch devices, 0 pending handler(s)
    qt.qpa.input: evdevtouch: Updating QInputDeviceManager device count: 1 touch devices, 0 pending handler(s)
    ...

    They look like a non good registered event handler, because of the "0 pending handler(s)"

    Or, why evdev driver gives me:
    qt.qpa.input: evdevtouch: /dev/input/event0: Protocol type B (mtdev) (multi), filtered=no
    qt.qpa.input: evdevtouch: /dev/input/event0: min X: 0 max X: 0
    qt.qpa.input: evdevtouch: /dev/input/event0: min Y: 0 max Y: 0
    qt.qpa.input: evdevtouch: /dev/input/event0: min pressure: 0 max pressure: 255

    here the evdevtouch drivers is giving me wrong max X and max Y values (both at 0), meanwhile the evtest gives me:

    Supported events:
    Event type 0 (EV_SYN)
    Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
    Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
    Value 2807
    Min 0
    Max 4095
    Event code 1 (ABS_Y)
    Value 1834
    Min 0
    Max 4095
    Event code 24 (ABS_PRESSURE)
    Value 0
    Min 0
    Max 255

    here the Min and Max values are 12bit wides (0-4095).

    Can you help me to workaround this so I can have my touch screen working on the EGLFS platform???

    Regards,
    Gianluca


Log in to reply