Reply
Thread Tools
Posts: 58 | Thanked: 8 times | Joined on Aug 2010
#1
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!

Code:
Nokia-N900:/sys/class/input/input3# dmesg | grep TSC2005
[    6.085968] TSC2005 driver initializing
[    6.086669] input: TSC2005 touchscreen as /class/input/input3
 
Posts: 58 | Thanked: 8 times | Joined on Aug 2010
#2
The touch coordinate data should be in file /dev/input/event3, I used below command to show it.

Code:
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?
 

The Following User Says Thank You to justforfun For This Useful Post:
ossipena's Avatar
Posts: 3,159 | Thanked: 2,023 times | Joined on Feb 2008 @ Finland
#3
Originally Posted by justforfun View Post
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
Code:
cat /dev/input/event3 > events.log
__________________
Want to know something?
K.I.S.S. approach:
wiki category:beginners. Browse it through and you'll be much wiser!
If the link doesn't help, just use
Google Custom Search
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#4
The values are in a binary format.
Look for input event struct.
A simple python script to read and decode the data:
Code:
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
 

The Following 6 Users Say Thank You to nicolai For This Useful Post:
Posts: 58 | Thanked: 8 times | Joined on Aug 2010
#5
Originally Posted by ossipena View Post
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
Code:
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.

Last edited by justforfun; 2011-01-29 at 08:08.
 
Posts: 58 | Thanked: 8 times | Joined on Aug 2010
#6
Originally Posted by nicolai View Post
The values are in a binary format.
Look for input event struct.
A simple python script to read and decode the data:
Code:
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.
 
Posts: 1,522 | Thanked: 392 times | Joined on Jul 2010 @ São Paulo, Brazil
#7
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)
 
Posts: 58 | Thanked: 8 times | Joined on Aug 2010
#8
Originally Posted by TiagoTiago View Post
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

Last edited by justforfun; 2011-02-14 at 06:20.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 10:11.