Tested only on iOS 6
You are actually on the right track. The problem is that you need to figure out what values ββyou should assign to these variables.
First of all, you need to import GraphicsServices.h. Then you can try the following code with the port, which you can get from How to find the purple port for the largest application in iOS 5 and above? .
I am not an iOS expert, and Apple does not provide any documentation, so I can not explain what is happening here. (This works fine for me.)
In any case, you can play with it using the xcode debugging mode to find out what happens under the hood.
struct GSTouchEvent * touchEvent = (struct GSTouchEvent*) &gsTouchEvent; bzero(touchEvent, sizeof(touchEvent)); touchEvent->record.type = kGSEventHand; touchEvent->record.subtype = kGSEventSubTypeUnknown; touchEvent->record.location = point; touchEvent->record.windowLocation = point; touchEvent->record.infoSize = sizeof(GSHandInfo) + sizeof(GSPathInfo); touchEvent->record.timestamp = GSCurrentEventTimestamp(); touchEvent->record.window = winRef; touchEvent->record.senderPID = 919; bzero(&touchEvent->handInfo, sizeof(GSHandInfo)); bzero(&touchEvent->handInfo.pathInfos[0], sizeof(GSPathInfo)); GSHandInfo touchEventHandInfo; touchEventHandInfo._0x5C = 0; touchEventHandInfo.deltaX = 0; touchEventHandInfo.deltaY = 0; touchEventHandInfo.height = 0; touchEventHandInfo.width = 0; touchEvent->handInfo = touchEventHandInfo; touchEvent->handInfo.type = handInfoType; touchEvent->handInfo.deltaX = 1; touchEvent->handInfo.deltaY = 1; touchEvent->handInfo.pathInfosCount = 0; touchEvent->handInfo.pathInfos[0].pathIndex = 1; touchEvent->handInfo.pathInfos[0].pathIdentity = 2; touchEvent->handInfo.pathInfos[0].pathProximity = (handInfoType == kGSHandInfoTypeTouchDown || handInfoType == kGSHandInfoTypeTouchDragged || handInfoType == kGSHandInfoTypeTouchMoved) ? 0x03: 0x00; touchEvent->handInfo.x52 = 1; touchEvent->handInfo.pathInfos[0].pathLocation = point; touchEvent->handInfo.pathInfos[0].pathWindow = winRef; GSEventRecord* record = (GSEventRecord*) touchEvent; record->timestamp = GSCurrentEventTimestamp(); GSSendEvent(record, port);
To use this code, you must call it several times. For one touch, there is a touch, a touch, and then a tint.
Also note that pathProximity is 0 when tapped up.
As far as I remember, winRef does not matter.
Hope this helps.
Edit: from Bugivore's comment, the problem is this:
The way I allocated touchEvent via malloc was wrong. This should be done as shown in EntryLevelDev - "static uint8_t handJob [sizeof (GSEventRecord) + sizeof (GSHandInfo) + sizeof (GSPathInfo)];"
pt2121 Apr 24 '13 at 2:08 2013-04-24 02:08
source share