Page 1 of 2 12 LastLast
Results 1 to 10 of 11
Discuss [Dev Tips] Partial GSEvent struct reversed - up to 5 multi-touch points! at the Free Toolchain Software - Hackint0sh.org; I've been curious about the GSEvent struct for a while, and was suspecting there was ...
  1. #1
    Professional Array

    Join Date
    Oct 2007
    Posts
    63
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    9

    Talking [Dev Tips] Partial GSEvent struct reversed - up to 5 multi-touch points!

    I've been curious about the GSEvent struct for a while, and was suspecting there was a way to access more than 2 of the multi-touch points of gestures... And I was right.
    After some disassembling in the GraphicsServices framework, I managed to reverse enough of the GSEvent struct to get the needed info. Here is what I got so far:
    Code:
    struct GSPathPoint {
    	char unk0;
    	char unk1;
    	short int status;
    	int unk2;
    	float x;
    	float y;
    };
    
    typedef struct {
    	int unk0;
    	int unk1;
    	int type;
    	int subtype;
    	float unk2;
    	float unk3;
    	float x;
    	float y;
    	int timestamp1;
    	int timestamp2;
    	int unk4;
    	int modifierFlags;
    	int unk5;
    	int unk6;
    	int mouseEvent;
    	short int dx;
    	short int fingerCount;
    	int unk7;
    	int unk8;
    	char unk9;
    	char numPoints;
    	short int unk10;
    	struct GSPathPoint points[numPoints];
    } GSEvent;
    The GSPathPoint struct that appeared inside the GSEvent struct probably has something to do/is a CGPath, but I've got enough of it to get things to work, so no more reversing for now...
    After you get the event pointer in a view, you can access the good stuff like this:
    event->mouseEvent - type of the event, one of :
    • 1 - MouseDown
    • 2 - MouseDragged
    • 5 - something like a MouseUp, but not sure
    • 6 - MouseUp


    event->fingerCount - number of fingers touching the screen.

    event->numPoints - number of points in the points array. Can be > than fingerCount after a MouseUp.

    event->points[0..numPoints] contains the info on every point.

    event->points[0..numPoints].status = 3 when the mouse is down, I think there is a flag for moved too.


    This is good news for the games/emulators authors, as now you can have up to 5 buttons on screen working independently.
    If someone can figure out the unk's, I would love to hear from you...

    PS: This also means multi-touch support in the next version of iPhysics, and just a little more time until iPinball comes out...
    Last edited by nop144666; 12-25-2007 at 11:49 PM.


  2. #2
    Respected Professional Array TwistyValhalla's Avatar

    Join Date
    Sep 2007
    Posts
    645
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    40

    Default

    Great work man!

    iPhone (OTB 1.1.1 / Currently 3.1)
    Unlock, activation, jailbreak: PwnageTool 3.1
    City Fido, Vancouver

  3. #3
    J to the T. Shaken, not Stirred Array thecompkid's Avatar

    Join Date
    Jul 2007
    Posts
    1,152
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    74

    Default

    Quote Originally Posted by nop144666 View Post
    PS: This also means multi-touch support in the next version of iPhysics, and just a little more time until iPinball comes out...
    Holy crap, you don't know how many times I have tried to use multitouch in iPhysics without it being there. Add that one feature, and iPhysics becomes hands down the best iPhone app.

  4. #4
    Professional Array

    Join Date
    Jul 2007
    Posts
    69
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    10

    Default

    have you done any testing to verify this works? and can track more than 2 inputs simultaneously ?
    say 3 fingers all moving at the same time?

  5. #5
    Professional Array

    Join Date
    Oct 2007
    Posts
    63
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    9

    Default

    Quote Originally Posted by drunknbass View Post
    have you done any testing to verify this works? and can track more than 2 inputs simultaneously ?
    say 3 fingers all moving at the same time?
    Yup, lot's of testing, and it's integrated in iPhysics now... Up to 5 fingers, with full tracking...


  6. #6
    Respected Professional Array TwistyValhalla's Avatar

    Join Date
    Sep 2007
    Posts
    645
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    40

    Default

    Awesome. Waiting for the new version of iPhysics!

    iPhone (OTB 1.1.1 / Currently 3.1)
    Unlock, activation, jailbreak: PwnageTool 3.1
    City Fido, Vancouver

  7. #7
    Professional Array

    Join Date
    Jul 2007
    Posts
    69
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    10

    Default

    can you post a code sample... id like to see

  8. #8
    Senior Professional Array

    Join Date
    Jul 2007
    Posts
    492
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    30

    Thumbs up

    Now that is hardcore. iPhysics rocks, the best mind stimulation ever.
    8g 1.0 OTB HW-Unlocked (took it apart) on Rogers, take that Ted!

  9. #9
    Professional Array

    Join Date
    Dec 2007
    Location
    Germany
    Posts
    74
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    9

    Default

    maybe i dont get it because im new to iphysics, but how exactly do i manage to move more then one field simultanously? When i draw something and then touch it i can move it, but when i touch the screen in another place at the same time to draw something other or move another object it just doesnt react.

    Does this only works with special levels or what else am i doing wrong?

  10. #10
    Professional Array

    Join Date
    Oct 2007
    Posts
    63
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    9

    Default

    Quote Originally Posted by drunknbass View Post
    can you post a code sample... id like to see
    I can't post the code from iPhysics, as it's quite tied up with the rest of the code, but here goes my testing code.

    EDApplication.h:
    Code:
    #import <Foundation/Foundation.h>
    #import <UIKit/UIKit.h>
    
    struct GSPathPoint {
    	char unk0;
    	char unk1;
    	short int status;
    	int unk2;
    	float x;
    	float y;
    };
    
    typedef struct {
    	int unk0;
    	int unk1;
    	int type;
    	int subtype;
    	float unk2;
    	float unk3;
    	float x;
    	float y;
    	int timestamp1;
    	int timestamp2;
    	int unk4;
    	int modifierFlags;
    	int unk5;
    	int unk6;
    	int mouseEvent;
    	short int dx;
    	short int fingerCount;
    	int unk7;
    	int unk8;
    	char unk9;
    	char numPoints;
    	short int unk10;
    	struct GSPathPoint points[10];
    } GSEvent;
    
    @interface EDView : UIView {
    	CGPoint fingers[5];
    	int numFingers;
    }
    - (void)dumpEvent:(GSEvent*)event;
    @end
    
    @interface EDApplication : UIApplication {
    	EDView *vw;
    }
    @end
    EDApplication.m:
    Code:
    #import "EDApplication.h"
    #include <stdlib.h>
    #include <math.h>
    
    @implementation EDApplication
    - (void) applicationDidFinishLaunching: (id) unused {
    	[UIHardware _setStatusBarHeight:0.0f];
    	[self setStatusBarMode:2 orientation:0 duration:0.0f fenceID:0];
    
    	UIWindow *window;
    	struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
    
    	window = [[UIWindow alloc] initWithContentRect: rect];
    	
    	vw = [[EDView alloc] initWithFrame: rect];
    
    	[window orderFront: self];
    	[window makeKey: self];
    	[window _setHidden: NO];
    
    	[window setContentView: vw];
    }
    @end
    
    #define DUMP_LINES 10
    
    @implementation EDView
    - (void)dumpEvent:(GSEvent*)event {
    /* Test 1: Dump raw data
    	char tmp[256];
    	int l, i;
    	char *bytes = (char *)event;
    	for (l = 0; l < DUMP_LINES; l++) {
    		tmp[0] = 0;
    		for (i = 0; i < 8; i++) {
    			sprintf(tmp, "%s %02X", tmp, *(bytes++));
    		}
    		sprintf(tmp, "%s -", tmp);
    		for (i = 0; i < 8; i++) {
    			sprintf(tmp, "%s %02X", tmp, *(bytes++));
    		}
    		NSLog(@"%s", tmp);
    	}
    */
    /* Test 2: Simple events
    	NSLog(@"MouseEvent: %d, fingerCount: %hd, numPoints: %hhd, pos: %f, %f", event->mouseEvent, event->fingerCount, event->numPoints, event->x, event->y);
    	int i;
    	for (i = 0; i < event->numPoints; i++) {
    		NSLog(@"  Point %d: %f, %f", i + 1, event->points[i].x, event->points[i].y);
    	}
    */
    /* Test 3: Multi-mouse tracking
    	int i, j;
    	
    	bool oks[5] = {false, false, false, false, false};
    	
    	for (i = 0; i < event->fingerCount; i++) {
    		bool found = false;
    		for (j = 0; j < numFingers; j++) {
    			int dist = ABS(event->points[i].x - fingers[j].x) + ABS(event->points[i].y - fingers[j].y);
    			if (dist < 20) {
    				found = true;
    				oks[j] = true;
    				if (dist > 2) {
    					fingers[j].x = event->points[i].x;
    					fingers[j].y = event->points[i].y;
    					// MOUSEMOVE
    					NSLog(@"MouseMove: %d, pos: %f, %f", j, fingers[j].x, fingers[j].y);
    				}
    				break;
    			}
    		}
    		if (!found) {
    			fingers[numFingers].x = event->points[i].x;
    			fingers[numFingers].y = event->points[i].y;
    			oks[numFingers] = true;
    			numFingers++;
    			// MOUSEDOWN
    			NSLog(@"MouseDown: %d, pos: %f, %f", numFingers, fingers[numFingers-1].x, fingers[numFingers-1].y);
    		}
    	}
    	for (j = 0; j < numFingers; j++) {
    		if (!oks[j]) {
    			// MOUSEUP
    			NSLog(@"MouseUp: %d, pos: %f, %f", j + 1, fingers[j].x, fingers[j].y);
    			numFingers--;
    			fingers[j].x = fingers[numFingers].x;
    			fingers[j].y = fingers[numFingers].y;
    			oks[j] = oks[numFingers];
    			j--;
    		}
    	}
    */
    }
    
    - (id)initWithFrame:(struct CGRect)frame {
    	[super initWithFrame: frame];
    	numFingers = 0;
    	[super setTapDelegate: self];
    	[super setGestureDelegate: self];
    	return self;
    }
    
    - (void)gestureChanged:(GSEvent*)event {
    	NSLog(@"gestureChanged:");
    	[self dumpEvent: event];
    }
    
    - (void)gestureEnded:(GSEvent*)event {
    	NSLog(@"gestureEnded:");
    	[self dumpEvent: event];
    }
    
    - (void)gestureStarted:(GSEvent*)event {
    	NSLog(@"gestureStarted:");
    	[self dumpEvent: event];
    }
    
    - (void)mouseDown:(GSEvent*)event {
    	NSLog(@"mouseDown:");
    	[self dumpEvent: event];
    }
    
    - (void)mouseDragged:(GSEvent*)event {
    	NSLog(@"mouseDragged:");
    	[self dumpEvent: event];
    }
    
    - (void)mouseEntered:(GSEvent*)event {		
    	NSLog(@"mouseEntered:");
    	[self dumpEvent: event];
    }
    
    - (void)mouseExited:(GSEvent*)event {		
    	NSLog(@"mouseExited:");
    	[self dumpEvent: event];
    }
    
    - (void)mouseMoved:(GSEvent*)event {
    	NSLog(@"mouseMoved:");
    	[self dumpEvent: event];
    }
    
    - (void)mouseUp:(GSEvent*)event {
    	NSLog(@"mouseUp:");
    	[self dumpEvent: event];
    }
    
    - (void)view:(UIView *)view handleTapWithCount:(int)count event:(GSEvent *)event {
    	NSLog(@"handleTapWithCount: %d", count);
    	[self dumpEvent: event];
    }
    			
    - (double)viewTouchPauseThreshold:(UIView *)view {
    	return 0.5;
    }
    
    - (BOOL)isFirstResponder {
    	return YES;
    }
    
    @end
    main.m:
    Code:
    #import <UIKit/UIKit.h>
    
    #import "EDApplication.h"
    
    int main(int argc, char **argv)
    {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        return UIApplicationMain(argc, argv, [EDApplication class]);
    }
    Just uncomment one of the test blocks and have fun... Test 3 is not very accurate, but you can get the idea.

    Quote Originally Posted by Gregsen View Post
    maybe i dont get it because im new to iphysics, but how exactly do i manage to move more then one field simultanously? When i draw something and then touch it i can move it, but when i touch the screen in another place at the same time to draw something other or move another object it just doesnt react.

    Does this only works with special levels or what else am i doing wrong?
    Right now I'm not implementing any new input style, so all drawing and stuff is just for 1 touch mode. Where multi-touch is going to be used now is in triggers, which can be used as on-screen buttons, in single and multi-player games... But I welcome suggestions on how to use multi-touch to make more interesting input methods...


 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 06-24-2010, 05:20 PM
  2. Replies: 0
    Last Post: 06-24-2010, 05:20 PM
  3. Replies: 0
    Last Post: 01-05-2010, 08:20 PM
  4. Replies: 0
    Last Post: 05-27-2009, 03:20 AM
  5. Replies: 0
    Last Post: 02-26-2009, 07:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 11:05 PM.
twitter, follow us!