How to get the click input position through Touchscreen?

Hi all,

I am trying to build something cool with Pi touchscreen. The essential thing is getting the pixel position whenever the user clicks/touches the touchscreen. Can somebody provide examples or documentation which tells how to capture the user input from the touchscreen?

Thanks a lot!
Sincerely.

This is a little short of documentation, but it’s a starting point- https://github.com/pimoroni/python-multitouch

This Python library will grab all the 10 points of touch from the official display and let you use them how you like.

Hi @gadgetoid

I tried the documentation you mentioned. (The examples are clear and simple to understand.) However, I am still searching the method in C++. Since the python-multitouch is limited by python3. Do you have any idea?

Sincerely.

Here’s a somewhat random example in C: https://gist.github.com/uobikiemukot/457338b890e96babf60b

I’d expect there to be a library for this- but I haven’t come across or used one myself.

In short, an input device in /dev/input is just a file like most everything else in Linux, and you can read the events right out of it assuming you know their structure.

Fortunately it’s well documented in input.h etc:

You’re just reading chunks of Time, Type, Code, and Value from the input device- and valid values and ranges for Type, Code and Value are quite widely documented.

1 Like