maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Where to find N900's touch coordinate data? (https://talk.maemo.org/showthread.php?t=68929)

justforfun 2011-01-25 14:49

Where to find N900's touch coordinate data?
 
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


justforfun 2011-01-26 07:38

Re: Where to find N900's touch coordinate data?
 
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?

ossipena 2011-01-26 10:18

Re: Where to find N900's touch coordinate data?
 
Quote:

Originally Posted by justforfun (Post 928752)
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

nicolai 2011-01-26 11:14

Re: Where to find N900's touch coordinate data?
 
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

justforfun 2011-01-29 08:05

Re: Where to find N900's touch coordinate data?
 
Quote:

Originally Posted by ossipena (Post 928869)
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.

justforfun 2011-01-29 08:08

Re: Where to find N900's touch coordinate data?
 
Quote:

Originally Posted by nicolai (Post 928921)
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.

TiagoTiago 2011-01-31 08:30

Re: Where to find N900's touch coordinate data?
 
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

Re: Where to find N900's touch coordinate data?
 
Quote:

Originally Posted by TiagoTiago (Post 932386)
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


All times are GMT. The time now is 01:18.

vBulletin® Version 3.8.8