Iphone 如何在越狱设备上使用GSEvent模拟多点触控?

Iphone 如何在越狱设备上使用GSEvent模拟多点触控?,iphone,ios,objective-c,iphone-privateapi,tweak,Iphone,Ios,Objective C,Iphone Privateapi,Tweak,我想在越狱设备上模拟多点触控事件,我尝试了GSEvent,我不知道结构的每个字段,所以我假设每个pathInfo意味着一个手指信息,但没有效果,有人能给我一些帮助吗?非常感谢 typedef struct touch { int identity; int x; int y; GSHandInfoType type; } touch; static void sendTouches(touch touches[]) { if (touches_coun

我想在越狱设备上模拟多点触控事件,我尝试了
GSEvent
,我不知道结构的每个字段,所以我假设每个pathInfo意味着一个手指信息,但没有效果,有人能给我一些帮助吗?非常感谢

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);
}
typedef结构触摸{
智力同一性;
int x;
int-y;
GSHandInfoType类型;
}触摸;
静态无效SendTouchs(触摸触摸[])
{
if(touch_countrecord.type=kGSEventHand;
事件->记录.subtype=kgSeventSubtype未知;
event->record.windowLocation=CGPointMake(触摸[0].x,触摸[0].y);
event->record.timestamp=GSCurrentEventTimestamp();
event->record.infoSize=sizeof(GSHandInfo)+sizeof(GSPathInfo);
事件->handInfo.type=触摸[0]。键入;
事件->handInfo.x52=触摸次数;
事件->handInfo.pathinfoscont=touchs\u计数;
对于(inti=0;ihandInfo.pathInfos[i],sizeof(GSPathInfo));
事件->handInfo.pathInfos[i].pathIndex=1;
事件->handInfo.pathInfos[i].pathIdentity=2;
事件->handInfo.pathInfos[i].路径接近=(触动[i].x==kGSHandInfoTypeTouchDown | |触动[i].x==KGSHANDINFOTYPETouchDrawed | |触动[i].x==kGSHandInfoTypeTouchMoved)?0x03:0x00;;
事件->handInfo.pathInfos[i].pathLocation=CGPointMake(触摸[i].x,触摸[i].y);
}
马赫数端口=(马赫数端口)GetFrontMostapport();
GSSendEvent((GSEventRecord*)事件,端口);
}
int测试()
{
//模拟两个手指从屏幕中心到两侧的触摸。
struct touch touchestown[2]=[{0,140,200,kgshandinfotypetouchedown},
{116200,kgshandinfotype着地}];
struct touch touchsmove[2]=[{0,40,200,kgshandinfotypetouch},
{1300,200,kgshandinfotypetouch}];
struct touch touchUp[2]=[{0,40,200,kGSHandInfoTypeTouchUp},
{1300,200,kGSHandInfoTypeTouchUp}];
触地得分;
美国LEEP(20000);
SendTouchs(触摸移动);
美国LEEP(20000);
SendTouchs(触碰);
}

我会尝试尝试使用handInfoType常量的不同值,正如我在回答您关于主屏幕单击的问题时所示。谢谢@Nate,我将尝试中断GSSendEvent以观察这些值。