PDA

View Full Version : Where to find N900's touch coordinate data?


justforfun
2011-01-25, 14:49
Hi, does anyone know where to find N900's touch panel's coordinate data? I know N900 uses TSC2005 as its touch panel controller. And I run below command to get some hints. If I want to access the coordinate data in user space, what is the exact file and path? Thanks!

Nokia-N900:/sys/class/input/input3# dmesg | grep TSC2005
[ 6.085968] TSC2005 driver initializing
[ 6.086669] input: TSC2005 touchscreen as /class/input/input3

justforfun
2011-01-26, 07:38
The touch coordinate data should be in file /dev/input/event3, I used below command to show it.

cat /dev/input/event3

And then I touch the screen of N900 and some charaters are output on the screen. They should be the touch information, including the coordinate data. But why they look garbled。I tried several characters encoding but failed to show them clearly. Does anyone know the right way?

ossipena
2011-01-26, 10:18
But why they look garbled。I tried several characters encoding but failed to show them clearly. Does anyone know the right way?

you should cat 'em into a file and open the file with a program that can handle correct encoding.... xterm isn't such a program..... (it gets messed pretty easily when outputting anything except standard text files)

e:
for example
cat /dev/input/event3 > events.log

nicolai
2011-01-26, 11:14
The values are in a binary format.
Look for input event struct.
A simple python script to read and decode the data:

import struct
tsdevice = "/dev/input/ts"
format = "iihhi"

file = open(tsdevice,"rb")
event = file.read(16)
x = 0
y = 0

while True:
(time1, time2, type, code, value) = struct.unpack(format,event)
if type == 3:
if code == 0:
x = value
if code == 1:
y = value
if type == 0:
print x, ":", y
event = file.read(16)




Nicolai

justforfun
2011-01-29, 08:05
you should cat 'em into a file and open the file with a program that can handle correct encoding.... xterm isn't such a program..... (it gets messed pretty easily when outputting anything except standard text files)

e:
for example
cat /dev/input/event3 > events.log

Hi, thank you for your reply! But I think nicolai is right, those are binary instead of encoding issue.

justforfun
2011-01-29, 08:08
The values are in a binary format.
Look for input event struct.
A simple python script to read and decode the data:

import struct
tsdevice = "/dev/input/ts"
format = "iihhi"

file = open(tsdevice,"rb")
event = file.read(16)
x = 0
y = 0

while True:
(time1, time2, type, code, value) = struct.unpack(format,event)
if type == 3:
if code == 0:
x = value
if code == 1:
y = value
if type == 0:
print x, ":", y
event = file.read(16)




Nicolai


Hi Nicolai, thank you! Now I can show it correctly. Although I am not familiar with python, but I got hint from your code.

TiagoTiago
2011-01-31, 08:30
Does that report the calibrated or the raw coordinates? (I've read that the N900 watches where you click and notices when you click near but not exactly on a GUI element and then actually hits it and uses that data to correct for any deformations in the input)

justforfun
2011-02-14, 02:35
Does that report the calibrated or the raw coordinates? (I've read that the N900 watches where you click and notices when you click near but not exactly on a GUI element and then actually hits it and uses that data to correct for any deformations in the input)


Hi, I don't know whether it is calibrated or not. The data I got is as below. For the first 3 pairs of data, they seem to be wrong. And the rest ones seem to be right. The bottom-left corner of the screen seems to be the origin of coordinate.

Nokia-N900:~# ./catch_touch /dev/input/event3

Reading From : /dev/input/event3 (TSC2005 touchscreen)

x = 459

y = 1090665992

x = 459

y = 1090665992

x = 475

y = 1090665992

x = 475

y = 460

x = 475

y = 476

x = 477

y = 476

x = 477

y = 476

x = 3630

y = 476

x = 3630

y = 476

x = 3628

y = 476

x = 3628

y = 3262

x = 3628

y = 3262