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);
}