我想在iPhone中注入触摸事件.我通过网络套接字获取触摸事件的坐标.GSSendEvent似乎是不错的选择.但是,它需要GSEventRecord作为输入之一.
有谁知道如何准备GSEventRecord?我根据一些例子准备了它,但是在GSSendEvent调用之后应用程序崩溃了.
感谢任何帮助.
-(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_ = …Run Code Online (Sandbox Code Playgroud) GSSendEvent 对我不起作用了.
即使订阅回调函数GSEventRegisterEventCallBack也不会触发触摸事件,[UIEvent _gsEvent]返回NULL.
发生了什么?