GSSendEvent - Inject Touch Event iOS

Ich möchte das Touch-Ereignis in das iPhone injizieren. Ich erhalte die Koordinaten des Berührungsereignisses über die Netzwerkbuchse. GSSendEvent scheint eine gute Wahl zu sein. Es benötigt jedoch GSEventRecord als eine der Eingaben.

Weiß jemand, wie man GSEventRecord vorbereitet? Ich habe es anhand einiger Beispiele vorbereitet, aber die App stürzt nach dem Aufruf von GSSendEvent ab.

Schätzen Sie jede Hilfe.

-(void) handleMouseEventAtPoint:(CGPoint) point
{
static mach_port_t port_;

// structure of touch GSEvent
struct GSTouchEvent {
    GSEventRecord record;
    GSHandInfo    handInfo;
} ;

struct GSTouchEvent *touchEvent = (struct GSTouchEvent *) malloc(sizeof(struct GSTouchEvent));

bzero(touchEvent, sizeof(touchEvent));

// set up GSEvent
touchEvent->record.type = kGSEventHand;
touchEvent->record.windowLocation = point;
touchEvent->record.timestamp = GSCurrentEventTimestamp();
touchEvent->record.infoSize = sizeof(GSHandInfo) + sizeof(GSPathInfo);
touchEvent->handInfo.type = getHandInfoType(0, 1);
touchEvent->handInfo.pathInfosCount = 1;
bzero(&touchEvent->handInfo.pathInfos[0], sizeof(GSPathInfo));
touchEvent->handInfo.pathInfos[0].pathIndex     = 1;
touchEvent->handInfo.pathInfos[0].pathIdentity  = 2;
touchEvent->handInfo.pathInfos[0].pathProximity = 1 ? 0x03 : 0x00;
touchEvent->handInfo.pathInfos[0].pathLocation  = point;

port_ = GSGetPurpleSystemEventPort();

GSSendEvent((GSEventRecord*)touchEvent ,port_);


}
static GSHandInfoType getHandInfoType(int touch_before, int touch_now){
if (!touch_before) {
    return (GSHandInfoType) kGSHandInfoType2TouchDown;
}
if (touch_now) {
    return (GSHandInfoType) kGSHandInfoType2TouchChange;
}
return (GSHandInfoType) kGSHandInfoType2TouchFinal;
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage