Author Topic: Multiple Touch Feature  (Read 2609 times)

nednones

  • Guest
Multiple Touch Feature
« on: April 16, 2012, 03:14:58 pm »
Figured I'd put this question back out there, particularly to the DFSDK team. It's that penultimate golden question, who can you detect two swipes in DFSDK and obtain the coordinate of each swipe instantaneously? Anyone have any ideas?   

tim

  • Administrator
  • Hero Member
  • *****
  • Posts: 1595
  • Karma: +11/-1
    • View Profile
    • DragonFireSDK
Re: Multiple Touch Feature
« Reply #1 on: April 19, 2012, 10:14:58 am »
The way multitouch works is that every touch now invokes a touch event.  Previously, DFSDK was limited to a single touch and while that finger was on the screen, no further touch events were possible.

We are working on a mechanism for reporting which "finger" caused the event without breaking your existing code.
Tim Sommers
DragonFireSDK Team

nednones

  • Guest
Re: Multiple Touch Feature
« Reply #2 on: April 19, 2012, 01:00:56 pm »
Cool, keep me updated! That type of coding is a biggy for two of my apps at the moment. Cheers Tim

glina126

  • Guest
Re: Multiple Touch Feature
« Reply #3 on: July 16, 2012, 06:21:22 am »
I believe I have acomished what you are asking for in a very simple code. I will post it when I get home tonight if you like.
I'm able to work with 2 or more fingers and each is assigned an ID so you can easily determine which made a swipe or etc. You could get both at the same time too**

nednones

  • Guest
Re: Multiple Touch Feature
« Reply #4 on: July 16, 2012, 12:05:03 pm »
Awesome, post it please so that I can analyse the performance?

glina126

  • Guest
Re: Multiple Touch Feature
« Reply #5 on: July 18, 2012, 10:16:14 am »
sorry it took me so long to get back to you but here is the code.. I hope thats what your looking for.

Code: [Select]

#include "DragonFireSDK.h"
#include <string>

//items
int background;
int touch1, touch2;
int button1, button2;

int x1Change, x2Change;
int y1Change, y2Change;


// declerations
int TouchArea(int id, int event, int x, int y);

void AppMain()
{
// background image ----------------------------
background = ImageAdd("Images/background.png");
ViewAdd(background,0,0);

// button images ------------------------
button1 = ImageAdd("Images/button1.png");
button2 = ImageAdd("Images/button2.png");

ViewAdd(button1,0,0);
ViewAdd(button2,0,0);

ViewSetVisible(button1,0);
ViewSetVisible(button2,0);

// touch handlers ---------------------------
touch1 = TouchAdd(0, 0, 320, 480, TouchArea, 0);

touch2 = TouchAdd(0, 0, 320, 480, TouchArea, 1);
TouchSetVisible(touch2,0);

}

void AppExit()
{
}

void OnTimer()
{
}

int TouchArea(int id, int event, int x, int y)     //event: 1=down, 2=move, 3=up
{
  if (id == 0)
  {   
  if(event == 1)
  {
  // update cordniates of button1
  //  make button1 visible
  // touch2 visible

  ViewSetxy(button1,x-80,y-100);
  ViewSetVisible(button1,1);
  TouchSetVisible(touch2,1);

  }

  if(event == 2)
  {
  // update cordinates of button1

  ViewSetxy(button1,x-80,y-100);
  }

  if(event == 3)
  {
  // make button1 invisible
  // touch2 invisible

  ViewSetVisible(button1,0);
  TouchSetVisible(touch2,0);

  }

  }

  if (id == 1)
  {
  if(event == 1)
  {
  // update cordniates of button2
  //  make button2 visible

  ViewSetxy(button2,x-80,y-100);
  ViewSetVisible(button2,1);

  }

  if(event == 2)
  {
  // update cordinates of button1
  ViewSetxy(button2,x-80,y-100);
  }

  if(event == 3)
  {
  // make button1 invisible

  ViewSetVisible(button2,0);
  }
  }

  return 0;
}


with a bit of extra code you can easily control the swipe of 5 fingers (max supported) interdependently.

I hope I was of help!

Damian 

nednones

  • Guest
Re: Multiple Touch Feature
« Reply #6 on: July 20, 2012, 01:04:52 am »
Awesome, shall test this later today!

nednones

  • Guest
Re: Multiple Touch Feature
« Reply #7 on: July 20, 2012, 06:41:49 am »
glina126 you're a star, will be posting an example in the Tutorials section!!!

glina126

  • Guest
Re: Multiple Touch Feature
« Reply #8 on: July 20, 2012, 07:21:19 am »
Thanks Nednones!! Hah I'm just happy I could be of help!! I just wish I had more time to program and have an app out already :/

Oh and I'm looking forward to reading the tutorial!! :D
« Last Edit: July 20, 2012, 07:38:05 am by glina126 »