The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
WinRT+SDL2 multitouch and current resolution
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
Is there already multitouch support with Windows Phone and SDL2?
I want to get the screen coordinates of my current pressed fingers.
for example: one finger is moving the character and another is shooting at an enemy at the same time.

another question:
how do i get the current resolution of my windows phone. for example when its tilted or not i can change my gui size.
Re: WinRT+SDL2 multitouch and current resolution
DLudwig


Joined: 09 Feb 2012
Posts: 179
Meldryt wrote:
Is there already multitouch support with Windows Phone and SDL2?
I want to get the screen coordinates of my current pressed fingers.
for example: one finger is moving the character and another is shooting at an enemy at the same time.


Yes, SDL2's touch API is supported on Windows Phone.

Meldryt wrote:
how do i get the current resolution of my windows phone. for example when its tilted or not i can change my gui size.


The SDL_Window APIs can be used here. On Windows Phone, the SDL window is treated as if it's always fullscreen, and SDL_GetWindowSize() can be used to get the current resolution, with device orientation being taken into account. SDL_WINDOWEVENT + SDL_WINDOWEVENT_SIZE_CHANGED events will also be sent out when the device's orientation changes.

Cheers,
-- David L.
Re: WinRT+SDL2 multitouch and current resolution
DLudwig


Joined: 09 Feb 2012
Posts: 179
[quote="DLudwig"]
Meldryt wrote:
Yes, SDL2's touch API is supported on Windows Phone.


Minor note/addition/correction: This does include support for multiple, concurrent touches. I.e. SDL's touch API is supported, -and- multi-touch should be working (in SDL2/WinRT).

Cheers,
-- David L.
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
ok "multi" touch works for me when one finger is pressed and moved and another finger is shortly touched down and up.
but when i have two fingers pressed and moved at the same time i never get the event for the second finger.

i need something like multigestures with the current coordinates of all fingers, but i couldnt find such thing.
DLudwig


Joined: 09 Feb 2012
Posts: 179
Meldryt wrote:
ok "multi" touch works for me when one finger is pressed and moved and another finger is shortly touched down and up.
but when i have two fingers pressed and moved at the same time i never get the event for the second finger.

i need something like multigestures with the current coordinates of all fingers, but i couldnt find such thing.


Hmmm, that sounds like a bug in SDL. I'll try to take a look at this within the next week or so, and'll post back details here if I'm able to find anything.

Cheers,
-- David L.
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
here is a litte code example.
after the first touch, the second finger position is never updated

Code:
SDL_TouchID device=SDL_GetTouchDevice(0);
   for(int i=0;i<SDL_GetNumTouchFingers(device);++i)
   {
      SDL_Finger *finger = SDL_GetTouchFinger(device,i);
      if(finger!=NULL)
      {
         multipos[i][0]=finger->x;
         multipos[i][1]=finger->y;
      }
   }
[/code]
DLudwig


Joined: 09 Feb 2012
Posts: 179
Meldryt wrote:
here is a litte code example.
after the first touch, the second finger position is never updated


Thanks for the sample!

I was able to reproduce this on my end, whereby the first-pressed finger would get updated, but not the 2nd, 3rd, etc. I'd get finger-down and finger-up events for all fingers, however finger-move events would only get sent out for the first-pressed finger.

I just pushed out a fix to SDL hg, via https://hg.libsdl.org/SDL/rev/1cb6ac648db7 , that seemed to fix it on my end. If you apply it, and still see the same bug, let me know and I'll take another look.

Cheers, and thanks much for the info on this!
-- David L.