Archive 17/01/2023.

[SOLVED] Multitouch coordinates

sabotage3d

Hi ,
What is the best way to query Multitouch coordinates, absolute and relative ?
I had a look in the documentation but I can only see GetMousePosition () . Is it applicable for touch events ?

Thanks in advance,

Alex

hdunderscore

You would do something like…

for(int i = 0; i < input.GetNumTouches(); i++) { TouchState* ts = input.GetTouch(i); }

urho3d.github.io/documentation/H … input.html
urho3d.github.io/documentation/H … state.html

sabotage3d

Thanks a lot :slight_smile:
Just one thing can we get both relative and absolute position ?

hdunderscore

It looks like they are both available in TouchState (absolute: position_ / lastPosition_, relative: delta_).

sabotage3d

thanks it works quite well
Just one thing if we want to check for a touch event is that the best way to do it :

[code]bool touchEvent = false;

if(input->GetNumTouches()>0)
{
touchEvent = true ;
}[/code]

I wonder if there is something similar to SDL:

if (evt.type == SDL_FINGERDOWN) { SDL_Touch *state = SDL_GetTouch(evt.tfinger.touchId); }

hdunderscore

That way works, but if you want another method you can subscribe to the touch events:
TouchBegin
TouchMove
TouchEnd

eg:

[code]SubscribeToEvent(“TouchBegin”, “Handle_TouchBegin”);
}

void Handle_TouchBegin(StringHash eventType, VariantMap& eventData)
{
log.Info(“TouchBegin”);
}[/code]

urho3d.github.io/documentation/H … _list.html

sabotage3d

Awesome works like a charm :slight_smile: