4

I would like to achieve system-wide tap simulation on iOS, via a MobileSubstrate plugin. The idea is to be able to simulate touches (in a first time single touch, then multitouch) on a system-wide level, in iOS 5.1.1 .

I've been successful in implementing this article to simulate touches on a specific view, I now would like to be able to simulate them system-wide.

I understand I should use the private MobileServices framework to do so, and I've documented myself on GSEvent (I've also looked at Veency & MouseSupport sourcecodes).

I tried to hook up a view to intercept UIEvents and look at the underlying structure :

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    GSEventRef eventRef = (GSEventRef)[event performSelector:@selector( _gsEvent)];
    GSEventRecord record = *_GSEventGetGSEventRecord(eventRef);
    < breakpoint here to look at record >
}

and the result is extremely similar to the old (iOS 3) structure detailled above.

I then tried to fire up those events myself (on a Standalone app, not a MS tweak for now) :

+(void)simulateTouchDown:(CGPoint)point{

    point.x = roundf(point.x);
    point.y = roundf(point.y);

    GSEventRecord record;
    memset(&record, 0, sizeof(record));

    record.type = kGSEventHand;
    record.windowLocation = point;
    record.timestamp = GSCurrentEventTimestamp();

    GSSendSystemEvent(&record);

}

Now, that doesn't work at all (doesn't crash either).

Most codes (MouseSupport, Veency) look like this

// Create & populate a GSEvent
struct {
    struct GSEventRecord record;
    struct {
        struct GSEventRecordInfo info;
        struct GSPathInfo path;
    } data;
} event;

memset(&event, 0, sizeof(event));

event.record.type = kGSEventHand;
event.record.windowLocation = point;
event.record.timestamp = GSCurrentEventTimestamp();
event.record.infoSize = sizeof(event.data);

event.data.info.handInfo.type = kGSHandInfoTypeTouchDown;    
event.data.info.handInfo._0x44 = 0x1;
event.data.info.handInfo._0x48 = 0x1;

event.data.info.pathPositions = 1;  

event.data.path.pathIndex = 0x01;
event.data.path.pathIdentity = 0x02;
event.data.path.pathProximity = 0x00;
event.data.path.pathLocation = event.record.windowLocation;


GSSendSystemEvent(&event.record);

Only :

  • GSEventRecordInfo is unknown (and I can't find where it might be defined)
  • I don't see the point of making a whole event to only pass the record

Please someone who's been through this on iOS 5 guide me.

Olotiar
  • 3,119
  • 1
  • 15
  • 37
  • What do you mean ? How else would you simulate a system-wide event ? – Olotiar Jul 16 '12 at 06:51
  • You can find a definition for GSEventRecordInfo [here](http://gitweb.saurik.com/iphone-api.git/blob/0ec5695fb65e628e298935de594682090a637b35:/GraphicsServices/GSEvent.h). – boxel Oct 25 '12 at 14:03

1 Answers1

0

GSEventRecordInfo may have been introduced since iOS 3.2 (that's where the Graphics Services headers you linked to are from). class-dump the framework that's actually on your device on iOS 5.1.1 and see if it's defined there?

stonesam92
  • 3,787
  • 2
  • 16
  • 24
  • Hi. I tried, but class dump complains that the headers does not contain valid Obj-C – Olotiar Jul 16 '12 at 12:44
  • Oh sorry it looks like the framework is actually written in C so class-dumping will be of no use. Your best bet is to go on irc on the #theos channel and ask there, that's where all the people that made things like veency and reversed the framework like in the headers you linked to hang out, so they'll probably be able to answer your question best – stonesam92 Jul 16 '12 at 13:15