Thursday, August 24, 2017

How to check if your touch screen is really sending touch events

I've had this problem twice in the last year, I'm testing something related to touch in my laptop and I'm stuck trying to figure out if it's my code that is wrong or if my screen is misconfigured and it's only sending mouse events.

Thanks to Shawn of Qt fame for having helped me the two times and explained me how to test if my screen is sending touch events, I'm writing this blog so i don't forget and ask him a third time :D

First step is figuring out the xinput id of the touch screen of my laptop

tsdgeos@yoga:~:$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Wacom Co.,Ltd. Pen and multitouch sensor Finger id=9 [slave pointer (2)]
⎜ ↳ ETPS/2 Elantech TrackPoint id=13 [slave pointer (2)]
⎜ ↳ ETPS/2 Elantech Touchpad id=14 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Wacom Co.,Ltd. Pen and multitouch sensor Pen id=10 [slave keyboard (3)]
↳ Integrated Camera id=11 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=12 [slave keyboard (3)]
↳ ThinkPad Extra Buttons id=15 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]

In this case would be id=9

Then you can do

tsdgeos@yoga:~:$ xinput test-xi2 9

and if the output contains RawTouchBegin and RawTouchEnd events, it means that the screen is correctly sending touch events :)

Next you probably want to check if Qt actually is seeing those events, for that there's a few ready to use demos in the qtdeclarative source code, so I would do

tsdgeos@yoga:~:$ qml qt5/qtdeclarative_58/examples/quick/touchinteraction/multipointtouch/multiflame.qml

And after putting my five fingers on the screen I would see

So all is good, the bug is my code and not in Qt or the configuration of my touch screen :D

1 comment:

Bhushan Shah said...

evtest is also useful tool to figure out if you are getting a events or not,

It will first print all the devices, and then you will have a list of all the input devices present, after that you can select your touch screen and all the input events from it.