Reputation: 2897
By searching in stackoverflow I got how to simulate a touchDown event on iOS, but after many tryings, I didn't get how to make a touchMoved event with GSEvent, does anyone knows?
simulate a touchDown event:
static void sendclickevent() {
CGPoint location = CGPointMake(200, 288);
// 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.windowLocation = location;
event->record.timestamp = GSCurrentEventTimestamp();
event->record.infoSize = sizeof(GSHandInfo) + sizeof(GSPathInfo);
event->handInfo.type = kGSHandInfoTypeTouchDown;
if (is_50_or_higher){
event->handInfo.x52 = 1;
} else {
event->handInfo.pathInfosCount = 1;
}
bzero(&event->handInfo.pathInfos[0], sizeof(GSPathInfo));
event->handInfo.pathInfos[0].pathIndex = 1;
event->handInfo.pathInfos[0].pathIdentity = 2;
event->handInfo.pathInfos[0].pathProximity = 1 ? 0x03 : 0x00;;
event->handInfo.pathInfos[0].pathLocation = location;
mach_port_t port = (mach_port_t)getFrontMostAppPort();
GSSendEvent((GSEventRecord *)event, port);
}
Upvotes: 1
Views: 924
Reputation: 167
event->handInfo.type = kGSHandInfoTypeTouchDown;
You have a touchdown, and you have a touchup right?
a single tap is like this:
touchdownAtPoint(x,y);
wait(0.1);//wait for 0.1 sec
touchUpAtPoint(x,y);
When you want to do a touch moved, should be sth like this:
touchdownAtPoint(x,y);
touchdownAtPoint(x+1,y);//scroll to right?
touchdownAtPoint(x+2,y);
.................
touchdownAtPoint(x+n,y);
touchUpAtPoint(x+n,y);
Of course you should write you own loop for it. Anyway I don't know if it is the most correct way but I got it to work.
Upvotes: 1