not sure how you even came up with this t.tfinger.x it should be your event instance e.tfinger.x

from testgesture.c

```
x = ((float)event->tfinger.x)/inTouch->xres;
y = ((float)event->tfinger.y)/inTouch->yres;
```

what you should have

```
x = ((float)e.tfinger.x)/t->xres;
y = ((float)e.tfinger.y)/t->yres;
```

then if you keep looking where it calls the draw from testgesture.c

```
if(event->type == SDL_FINGERMOTION)
drawCircle(screen,x*screen->w,y*screen->h,5,col);
else if(event->type == SDL_FINGERDOWN)
drawCircle(screen,x*screen->w,y*screen->h,-10,col);
```

you notice how it multiply’s the x and y by the screen width and height giving the final x and y coordinate

or you could do

```
x = ((float)e.tfinger.x)/t->xres * screen_width;
y = ((float)e.tfinger.y)/t->yres * screen_height;
```

the reason for 0 is because it equals a small decimal number below 1 so an int will be either 1 or 0 so you need to multiply for the final int value or use floats.

Also note on iOS for me to get the right coordinates I seem to have needed to use the latest screen size width and height even though my width was actually 480.

```
x = ((float)e.tfinger.x)/t->xres * 568;
y = ((float)e.tfinger.y)/t->yres * 320;
```

Gabriele Greco wrote:> Can someone point me to a working example?

I’m trying to follow testgesture.c but it seems that there is something strange going on.

I get xres / yres at 32768 when I call SDL_GetTouch() on my FINGERDOWN event, and this cause my coords to always be 0,0:

case SDL_FINGERDOWN:

?{ ?

? ?SDL_Touch *t = SDL_GetTouch(e.tfinger.touchId);

? ?int x = t.tfinger.x / t->xres,

? ? ? ?y ?= t.tfinger.y / t->yres;

// -> x and y are always 0

[…]

Maybe this has something to do with the fact I’m using a logical size for the window different from the physical one?

Tests done on iOS6, both on real device (iphone5) and simulator.

–

Bye,

?Gabry