Cannot rotate my touchscreen with QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS, using linuxfb plugin



  • Hello everyone !

    I'm presently working on an I.MX6 device, with a NHD‐4.3‐480272MF display (including a touchscreen).
    I built Qt5.5 in order to make a suitable app for my target, with this configuration:

    ./configure -release -v -directfb -no-xkbcommon-evdev -no-xcb-xlib -no-sse2 -no-glib -no-pulseaudio -no-alsa -gtkstyle -linuxfb -no-iconv -evdev -no-libjpeg -plugin-sql-sqlite -no-dbus -no-libproxy -no-sql-mysql -no-sql-ibase -no-sql-oci -no-sql-odbc -no-sql-tds -no-xkbcommon-evdev -no-icu -no-fontconfig -opensource -confirm-license -no-pch -no-xcb -opengl es2 -make libs -make examples -device imx6 -compile-examples -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /home/swuser/Appli/Prj/_bsp_imx6_linux/buildroot/buildroot-2015.08.1/output/host/usr/arm-buildroot-linux-gnueabihf/sysroot -no-gcc-sysroot -prefix /usr/lib/qt

    (I kept Directfb and Eglfs plugins, because i wanted to try them. They didn't wok for me)

    For now on, I'm having difficulties with the display and touchscreen orientations (both in landscape, and not in portrait as I wished) with linuxfb plugin.
    I found a patch working for display rotation on this site: http://borkedlabs.com/2015/06/01/qt5-linuxfb-rotation-for-lcds/ , but it doesn't apply for touchscreen rotation.
    I tried to set the environment variable QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS with "rotate=angle"
    but it didn't work for me. I'm presently spiking qt source code to understand where my mistake could be.

    here is my environment configuration:
    export QT_DEBUG_PLUGINS=1
    export QT_PLUGIN_PATH=/usr/lib/plugins
    export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/plugins/platforms
    export QT_QPA_PLATFORM=linuxfb
    export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0
    export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/event0:rotate=270
    export TSLIB_TSEVENTTYPE='INPUT'

    and i launch my app sending the command:
    ./myapp -platform linuxfb:fb=/dev/fb0:rotation=angle

    If anyone could give me some insight on what I have done wrong, i would be very pleased.



  • Hi again guys !

    I've resolved my problem:
    Initially, I made a mistake mixing up Tslib and Evdevtouch plugins. Even though Evdevtouch seems more suitable for my application (a rotation plugin is already coded), I just can't make it work: when i used it, events were happening, but actions (such as buttons) were not even triggered.
    So I decided to use Tslib plugin (it already worked for me), and i applied a patch to it, in order to be able to rotate the touchscreen as I wanted. The only thing needed is to export a environment variable with the suitable parameters:

    export TSLIB_PARAMETERS=mode=heightxwidth:rotate=angle
    

    where height and width represent the format of your display, and angle, the rotation for the touchscreen (can only be set to values: 0, 90, 180, 270)

    an example of application could be:

    export TSLIB_PARAMETERS=mode=480x272:rotate=270
    export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0
    export QT_QPA_FB_TSLIB=1
    
    ./name_of_app -platform linuxfb:fb=/dev/fb0:rotation=270
    

    As i cannot join attached files, i post the patch here. But feel free to contact me if you want more info.

    --- qtslib.cpp	2016-06-07 14:39:05.664970271 +0200
    +++ ./qt5/qtbase/src/platformsupport/input/tslib/qtslib.cpp	2016-06-07 14:43:39.899464647 +0200
    @@ -35,6 +35,8 @@
     
     #include <QSocketNotifier>
     #include <QStringList>
    +#include <QString>
    +#include <QPointF>
     #include <QPoint>
     #include <QLoggingCategory>
     
    @@ -102,6 +104,30 @@
     void QTsLibMouseHandler::readMouseData()
     {
         ts_sample sample;
    +    QString spec = QString::fromLocal8Bit(qgetenv("TSLIB_PARAMETERS"));
    +    int RotateAngle;
    +    int Width;
    +    int Height;
    +    QString ModeArg;
    +
    +    if(spec.isEmpty()){
    +	RotateAngle = 0;
    +	Height = 480;
    +	Width = 272;
    +    }
    +
    +    QStringList args = spec.split(QLatin1Char(':'));
    +    for (int i = 0; i < args.count(); ++i) {
    +        if(args.at(i).startsWith(QLatin1String("rotate"))) {
    +	   QString rotateArg = args.at(i).section(QLatin1Char('='), 1, 1);
    +	   RotateAngle = rotateArg.toInt();
    +        }
    +	else if(args.at(i).startsWith(QLatin1String("mode"))) {
    +	   ModeArg = args.at(i).section(QLatin1Char('='), 1, 1);
    +	   Width = ModeArg.section(QLatin1Char('x'),0,0).toInt();
    +	   Height= ModeArg.section(QLatin1Char('x'),1,1).toInt();
    +        }
    +    }
     
         while (get_sample(m_dev, &sample, m_rawMode)) {
             bool pressed = sample.pressure;
    @@ -121,8 +147,29 @@
                 if (dx*dx <= 4 && dy*dy <= 4 && pressed == m_pressed)
                     continue;
             }
    -        QPoint pos(x, y);
    -
    +	QPoint pos(x,y);
    +	//Switch to apply rotation
    +	switch (RotateAngle) {
    +            case 0:
    +		pos.setX(x);
    +		pos.setY(y);
    +		break;
    +            case 90:
    +		pos.setX(y);
    +		pos.setY(Width-x);		
    +		break;
    +            case 180:
    +		pos.setX(Width-x);
    +		pos.setY(Height-y);
    +		break;
    +            case 270:
    +		pos.setX(Height-y);
    +		pos.setY(x);
    +		break;
    +            default:
    +                break;
    +        }
    +	
             QWindowSystemInterface::handleMouseEvent(0, pos, pos, pressed ? Qt::LeftButton : Qt::NoButton);
     
             m_x = x;
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.