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.

Qt Code:
  1. So what I'm seeing from the point of view of events received when I pressed down and then release looks like:
  2.  
  3. 50 SockAct <-- Received right at press down
  4. <-- NO Other events received until press released
  5. <-- Now release by lifting finger from screen
  6. 50 SockAct <-- Immediately received a 50 ( SockAct ) and the rest of the events below:
  7. 2 <-- 2 == mouse down
  8. 2 <-- 2 == mouse down
  9. 3 <-- 3 == mouse release / up
  10. 3 <-- 3 == mouse release / up
  11. 77 <-- 77 == redraw
To copy to clipboard, switch view to plain text mode 

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:

Qt Code:
  1. ...
  2. MOVE TYPE: 5
  3. "Mouse move (382,129)"
  4. MOUSE BUTTON PRESS TYPE: 2
  5. "Mouse Button Press (1)"
  6. MOUSE BUTTON RELEASE TYPE: 3
  7. "Mouse Button Release (1)"
  8. ....
To copy to clipboard, switch view to plain text mode 

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

Qt Code:
  1. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. // Just for kicks print out the mouse position
  3. if (event->type() == QEvent::MouseButtonPress)
  4. {
  5. qDebug() << "MOUSE BUTTON PRESS TYPE: " << event->type();
  6. QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
  7. qDebug() << QString("Mouse Button Press (%1)").arg(mouseEvent->button());
  8. }
  9. if (event->type() == QEvent::MouseMove)
  10. {
  11. qDebug() << "MOVE TYPE: " << event->type();
  12. QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
  13. qDebug() << QString("Mouse move (%1,%2)").arg(mouseEvent->globalX()).arg(mouseEvent->globalY());
  14. }
  15. if (event->type() == QEvent::MouseButtonRelease)
  16. {
  17. qDebug() << "MOUSE BUTTON RELEASE TYPE: " << event->type();
  18. QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
  19. delay();
  20. qDebug() << QString("Mouse Button Release (%1)").arg(mouseEvent->button());
  21. //return true; // Gobble the event
  22. }
  23. ////////////////////////////////////////////////////////////////////////////////////////////////////////////
To copy to clipboard, switch view to plain text mode 

Here is my delay function:

Qt Code:
  1. void Monitor::delay()
  2. {
  3. QTime dieTime = QTime::currentTime().addMSecs(3);
  4. while( QTime::currentTime() < dieTime )
  5. QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
  6. }
To copy to clipboard, switch view to plain text mode