Wie simuliere ich Multi-Touch mit GSEvent auf einem Gerät mit Jailbreak?

Ich möchte ein Multi-Touch-Ereignis auf einem Gerät mit Jailbreak simulierenGSEvent, Ich konnte nicht jedes Feld der Strukturen kennen, also nahm ich an, dass jedes pathInfo einen Finger bedeutet, aber keine Auswirkung, kann mir jemand helfen? Vielen Dank.

typedef struct touch {
    int identity;
    int x;
    int y;
    GSHandInfoType type;
} touch;

static void sendTouches(touch touches[])
{

    if (touches_count<1) {
        return;
    }

    uint8_t touchEvent[sizeof(GSEventRecord) + sizeof(GSHandInfo) + sizeof(GSPathInfo)*touches_count];

    // structure of touch GSEvent
    struct GSTouchEvent {
        GSEventRecord record;
        GSHandInfo    handInfo;
    } * event = (struct GSTouchEvent*) &touchEvent;
    bzero(touchEvent, sizeof(touchEvent));

    // set up GSEvent
    event->record.type = kGSEventHand;
    event->record.subtype = kGSEventSubTypeUnknown;
    event->record.windowLocation = CGPointMake(touches[0].x, touches[0].y);
    event->record.timestamp = GSCurrentEventTimestamp();
    event->record.infoSize = sizeof(GSHandInfo) + sizeof(GSPathInfo);
    event->handInfo.type = touches[0].type;
    event->handInfo.x52 = touches_count;
    event->handInfo.pathInfosCount = touches_count;

    for (int i=0; i<touches_count; i++) {
        bzero(&event->handInfo.pathInfos[i], sizeof(GSPathInfo));
        event->handInfo.pathInfos[i].pathIndex     = 1;
        event->handInfo.pathInfos[i].pathIdentity  = 2;
        event->handInfo.pathInfos[i].pathProximity = (touches[i].x == kGSHandInfoTypeTouchDown || touches[i].x == kGSHandInfoTypeTouchDragged || touches[i].x == kGSHandInfoTypeTouchMoved) ? 0x03 : 0x00;;
        event->handInfo.pathInfos[i].pathLocation  = CGPointMake(touches[i].x, touches[i].y);
    }

    mach_port_t port = (mach_port_t)getFrontMostAppPort();
    GSSendEvent((GSEventRecord *)event, port);

}

int test()
{
    // simulate two fingers touch from  the center to two sides of the screen.

    struct touch touchesDown[2] = [{0, 140, 200, kGSHandInfoTypeTouchDown},
                                   {1, 160, 200, kGSHandInfoTypeTouchDown}];

    struct touch touchesMove[2] = [{0, 40, 200, kGSHandInfoTypeTouchDragged},
                                   {1, 300, 200, kGSHandInfoTypeTouchDragged}];

    struct touch touchesUp[2] = [{0, 40, 200, kGSHandInfoTypeTouchUp},
                                 {1, 300, 200, kGSHandInfoTypeTouchUp}];

    sendTouches(touchesDown);
    usleep(20000);
    sendTouches(touchesMove);
    usleep(20000);
    sendTouches(touchesUp);
}

Antworten auf die Frage(0)

Ihre Antwort auf die Frage