PDA

View Full Version : Qt Embedded Touchscreen QMouseEvents Not Received Until MouseButtonRelease Received



phil999
14th January 2013, 20:59
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'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::AllEve nts, 100);
}

phil999
15th January 2013, 19:08
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.