2
votes

I am using Qt 4.8.3 on a small ARM embedded Linux device with a touchscreen. I have my touchscreen configured with tslib and calibrated it so there is a pointercal file in /etc/. The locations of my touch events work just fine but no matter what I get a QEvent for Mouse Move before Mouse Press or Mouse Release Events. Furthermore, I don't get any Mouse Related Events until I physically lift my finger from the touchscreen. I need normal behavior where I press on the touchscreen and receive a mouse down event immediately and then my move events ( if there are any ) and then a mouse release event when I lift my finger.

So what I'm seeing from the point of view of events received when I pressed down and then release looks like:

50 SockAct <-- Received right at press down
           <-- NO Other events received until press released
           <-- Now release by lifting finger from screen
50 SockAct <-- Immediately received a 50 ( SockAct ) and the rest of the events below:
2          <-- 2 == mouse down
2          <-- 2 == mouse down
3          <-- 3 == mouse release / up
3          <-- 3 == mouse release / up
77         <-- 77 == redraw

I also attempted to look at the QWS Server events by implementing the following qwsEventFilter to watch QWS events that come in to my QApplication:

/// For investigation mouse events
#include <QWSServer>
#include <QWSMouseHandler>
#include <QWSEvent>

bool GUIApp::qwsEventFilter(QWSEvent *e)
{

    qDebug() << e->type;

    if(e->type == QWSEvent::Mouse) {

        QWSMouseHandler *curMouse = QWSServer::mouseHandler();
        qDebug() << "mouse position is: " << curMouse->pos();

    }

    return false;

    /*
    QWSEvent::NoEvent   0   No event has occurred.
    QWSEvent::Connected 1   An application has connected to the server.
    QWSEvent::Mouse 2   A mouse button is pressed or released, or the mouse cursor is moved. See also Qt for Embedded Linux Pointer Handling.
    */

}

Now, when I launch my App I am seeing the same behavior after touching the screen -- that is the following is printed:

2 <-- Nothing is printed until I release my finger from the screen!
mouse position is:  QPoint(89,312) 
2 
mouse position is:  QPoint(89,312) 

As you can see as soon as I release my finger I get 2 events, presumably press down and release.

I've run 'evtest' on my /dev/input/touchscreen device in Linux and certainly see a touch down event immediately when pressing down on the screen. And I do not get a mouse release event until I lift my finger, so the driver behaves as expected. There are also no 'repeat' touch down events when I press - it is just one event for one press down , but behaves correctly.

I'm not sure why I'm seeing the behavior I do. There must be a translation issue between Qt and the input device.

Furthermore, If I add a small 3ms delay in processing my MouseButtonRelease received event, then I get desired behavior in terms of how the app works but I still do not receive my Mouse events until I release the press. I should not have to add a delay at all, I would expect my mouse down to happen, then any moves, and finally a mouse up event in turn

Does anybody know how to fix this or what may be causing this?? Thank you very much!

--

I don't see the following printed out until I actually lift my finger:

...
MOVE TYPE:  5 
"Mouse move (382,129)" 
MOUSE BUTTON PRESS TYPE:  2 
"Mouse Button Press (1)" 
MOUSE BUTTON RELEASE TYPE:  3 
"Mouse Button Release (1)" 
....

Here is my eventFilter where I examine my received events in my App:

////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Just for kicks print out the mouse position
if (event->type() == QEvent::MouseButtonPress)
{
    qDebug() << "MOUSE BUTTON PRESS TYPE: " << event->type();
    QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
    qDebug() << QString("Mouse Button Press (%1)").arg(mouseEvent->button());
}
if (event->type() == QEvent::MouseMove)
{
    qDebug() << "MOVE TYPE: " << event->type();
    QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
    qDebug() << QString("Mouse move (%1,%2)").arg(mouseEvent->globalX()).arg(mouseEvent->globalY());
}
if (event->type() == QEvent::MouseButtonRelease)
{
    qDebug() << "MOUSE BUTTON RELEASE TYPE: " << event->type();
    QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
    delay();
    qDebug() << QString("Mouse Button Release (%1)").arg(mouseEvent->button());
    //return true; // Gobble the event
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

Here is my delay function:

void Monitor::delay()
{
    QTime dieTime = QTime::currentTime().addMSecs(3);
    while( QTime::currentTime() < dieTime )
    QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
1
Any reason you're not reimplementing mouseMoveEvent and friends to deal with your mouse events?Xavier Holt
I didn't think that would be necessary since I expected Qt to interpret the mouse events as I see them being exposed by evtest from the atmel touchscreen driver on the Linux console.PhilBot
Well, I can't say anything definitive, since I don't know the details of your set-up, but from a generic Qt perspective, reimplementing specific event handlers is the norm. According to this thread, it's more efficient as well. Dunno if the difference is related to your problem, though - what object do you install that event filter on, anyway?Xavier Holt
I am installing it on qApp - I noticed that whenever I press down in Qt and print events, I always get immediately a QT::SockAct ( code 50 ) event and then no other events until I release my finger from the touch screen, then immediately I get 2 touch down events, 2 release events, and a redraw. Something is holding my app captive when I press down it seems. I cannot find much information on this Qt:SockAct event.PhilBot

1 Answers

1
votes

Solved- I found this thread: https://github.com/kergoth/tslib/issues/10 which outlines the same problem. It seems to be an issue in Tslib with the Atmel MXT Maxtouch driver. Commenting out the Variance module in the ts.conf file solved my problem - I now get mouse down events immediately after touching the screen.