Negative Touch Vector

Hi :slight_smile:

I ran into a peculiar issue with my touch input class.

I’m doing a simple:

foreach (Touch t in Input.touches)
{
     touches[t.fingerId].position.x = t.position.x;
     touches[t.fingerId].position.y = Core.system.resolution.y - t.position.y;
}

where ‘touches’ is a list containing 5 instances of my own touch class (containing nothing but a few public variables).

Core is just my namespace that has a reference to the system.resolution of the device (640x960 in this case).

Now for the odd part; when a touch is registered at the top of the screen (outside the screen actually), I’ll get something like (0,-10) for the position vector - and if I touch towards the bottom - I’ll never get passed (0,940).

So, at the top get -10px on y - and at the bottom it cuts off 20px on y.

Is this an intended feature of the iPhone 4? - offsetting the screen coordinate-system slightly, or what is this?

I did write a “fix” for this taking the actual touch-point into account (40x40px from what I understand) - but it’s rather messy, and would prefer a cleaner version if possible.

Any help/insight would be appreciated. :slight_smile:

20px delta would be the status bar

Thank you :slight_smile:

So - my current way of “correcting” it would be acceptable then?

if (t.position.y > Core.system.resolution.y)
   touches[t.fingerId].position.y = 0.0f;
else
   touches[t.fingerId].position.y = Core.system.resolution.y - t.position.y + 20;