Force Touch Events?

Member
Posts: 20
Joined: 2010.09
Post: #1
I can successfully overload and print out the values from:
touchesBegan:
touchesEnded:
touchesMoved:

When none of the touches are moving, there are no events generated. Is there anyway to force an update or get a list of all touches even if the touches are not in motion. I would like to know where all the touches are on every update frame of my game.

Thomas.
http://www.rattansoftware.com
Groundhog Assault 3D (Apple App Store)
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
It's advisable to keep your own list of active touches. Add to the list in -touchesBegan:, compare pointers to figure out which one(s) you're dealing with in -touchesMoved:, and remove from the list in -touchesEnded: and -touchesCancelled:. This is really a bare necessity of processing touch events; unless I'm mistaken, when -touchesMoved: called, only touches that actually moved are passed to it. If there are active touches that didn't move, they won't be in its list.
Quote this message in a reply
Member
Posts: 20
Joined: 2010.09
Post: #3
I'll have to try that, but there is problem.

if you push finger #1 down and hold it down (no motion), you'll get a begin touch event. Pressing finger #2 down goes not generate any event until finger #1 moves.

What I'd like to do is capture all the fingers that are down and I don't see how that is possible even if I starting tracking.

Thomas.
http://www.rattansoftware.com
Groundhog Assault 3D (Apple App Store)
Quote this message in a reply
Moderator
Posts: 442
Joined: 2003.08
Post: #4
That doesn't seem correct, it should generate another beganTouches event. Can you post your code for those functions (used the code tags to get it formatted nicely)?
Alex
Quote this message in a reply
Member
Posts: 20
Joined: 2010.09
Post: #5
Not sure what the code tags are, hope you dont mind. I've posted the three functions I'm using to capture the events. I believe these are standard implementations, but could be wrong. You can drop this into a iPad GLES project, watch the console and the following will happens.

Only the first finger down will generate a begin event.
Only the first finger will generate an end event.
No other finger will generate any event until the first finger moves.

I would love to get begin, motion and end events for any and all fingers. Seems odd that I can't.
Code:
//---------------------------------------------------------------------
// touchesBegan
//---------------------------------------------------------------------
- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
{
NSSet *allTouches = [event allTouches];

  printf("Begin Touch: ");

  for (UITouch *touch in allTouches)
  {
    if (touch.phase == UITouchPhaseBegan)
    {
    CGPoint location  = [touch locationInView: self];
      
       printf("(%5.2f %5.2f), ",location.x,location.y);
    }
  }
  
  printf("\n");
}




//---------------------------------------------------------------------
// touchesMoved
//---------------------------------------------------------------------
- (void) touchesMoved: (NSSet*) touches withEvent: (UIEvent*) event
{
NSSet *allTouches = [event allTouches];

  printf("Move Touch: ");

  for (UITouch *touch in allTouches)
  {
    if (touch.phase == UITouchPhaseMoved)
    {
    CGPoint location  = [touch locationInView: self];
      
       printf("(%5.2f %5.2f), ",location.x,location.y);
    }
  }
  
  printf("\n");
}


//---------------------------------------------------------------------
// touchesEnded
//---------------------------------------------------------------------
- (void) touchesEnded: (NSSet*) touches withEvent: (UIEvent*) event
{
NSSet *allTouches = [event allTouches];

  printf("End Touch: ");

  for (UITouch *touch in allTouches)
  {
    if (touch.phase == UITouchPhaseEnded)
    {
    CGPoint location  = [touch locationInView: self];
      
       printf("(%5.2f %5.2f), ",location.x,location.y);
    }

  }
  
  printf("\n");
}

Thomas.
http://www.rattansoftware.com
Groundhog Assault 3D (Apple App Store)
Quote this message in a reply
Moderator
Posts: 442
Joined: 2003.08
Post: #6
I formatted your code using the correct tags. Please use them when posting code. When I get a chance I'll check out the code to see if I can figure out what's going on.
Alex
Quote this message in a reply
Member
Posts: 20
Joined: 2010.09
Post: #7
Thanks Alex.

Thomas.
http://www.rattansoftware.com
Groundhog Assault 3D (Apple App Store)
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #8
This sounds kind of familiar, I believe I have struck it before, but can't remember exactly what the issue was.

You have setMultipleTouchEnabled:YES on your view right?

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Member
Posts: 20
Joined: 2010.09
Post: #9
Yes, the multi touch flag is set by default when you have XCode create a GLES project.

Thomas.
http://www.rattansoftware.com
Groundhog Assault 3D (Apple App Store)
Quote this message in a reply
Member
Posts: 204
Joined: 2002.09
Post: #10
(Feb 4, 2011 08:02 PM)Ropeburn Wrote:  Yes, the multi touch flag is set by default when you have XCode create a GLES project.

I dropped your code into the EAGLView.m of a new OpenGLES project and... it worked just fine.

Code:
[Session started at 2011-02-04 22:15:02 -0500.]
// SINGLE TOUCH
Begin Touch: (363.00 477.00),
Move Touch: (348.00 509.00),
Move Touch: (348.00 508.00),
End Touch: (348.00 508.00),
// TWO TOUCHES
Begin Touch: (291.00 512.00), (477.00 512.00),
Move Touch: (291.00 513.00), (477.00 511.00),
Move Touch: (288.00 523.00), (480.00 501.00),
Move Touch: (287.00 523.00), (481.00 501.00),
Move Touch: (287.00 522.00), (481.00 502.00),
Quote this message in a reply
Member
Posts: 20
Joined: 2010.09
Post: #11
Hmm, thats good news and what I would expect. However, this what I get when I drop it into a new project.

Begin Touch: (597.00 749.00), // finger #1 down
Move Touch: (596.00 747.00),
Move Touch: (597.00 747.00),
Move Touch: (598.00 747.00),
Move Touch: (598.00 748.00), // finger #2 down
Move Touch: (598.00 749.00),
Move Touch: (598.00 750.00),
Move Touch: (107.00 756.00), (599.00 750.00), // finger #1 moving
Move Touch: (107.00 775.00), (600.00 749.00),
Move Touch: (600.00 748.00),
Move Touch: (109.00 794.00), (601.00 748.00),
Move Touch: (107.00 810.00), (602.00 748.00),
Move Touch: (105.00 824.00), (603.00 748.00),
Move Touch: (99.00 856.00), (604.00 748.00),
Move Touch: (605.00 748.00),
Move Touch: (97.00 860.00), (606.00 748.00),
Move Touch: (96.00 860.00), (606.00 749.00),
Move Touch: (606.00 750.00),
Move Touch: (603.00 751.00),
End Touch: (603.00 751.00), // finger #1 off

Thomas.
http://www.rattansoftware.com
Groundhog Assault 3D (Apple App Store)
Quote this message in a reply
Member
Posts: 20
Joined: 2010.09
Post: #12
Ok, I believe I have found the issue. I did go back once again and check to see if I had enabled multi touch, and I had not. It appears that it is not automatically set as I had thought. I am sorry for wasting everyones time. Thanks for the help.
T.
setMultipleTouchEnabled:YES

Thomas.
http://www.rattansoftware.com
Groundhog Assault 3D (Apple App Store)
Quote this message in a reply
Nibbie
Posts: 3
Joined: 2011.01
Post: #13
setMultipleTouchEnabled:YES is your answer..

Kind Regards
Upps sorry You already found the answer Smile sorry to not to read whole replies...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Integrating Force And Torque Nick 5 3,639 Oct 23, 2006 10:03 AM
Last Post: Skorche
  Is Force Feedback broken in Tiger? Andrew 3 3,507 Aug 23, 2005 03:59 AM
Last Post: Andrew
  Force feedback example? rvangaal 7 4,762 Mar 24, 2003 03:01 AM
Last Post: rvangaal