Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Only tested on iOS 6</strong></p> <p>You are actually on the right track. The problem is you have to figure out what values you should assign to these variables.</p> <p>First of all, you need to import GraphicsServices.h. Then, you can try the following code with the port which you can get from <a href="https://stackoverflow.com/questions/16156831/how-to-find-the-purple-port-for-the-front-most-application-in-ios-5-and-above/16157532#16157532">How to find the purple port for the front most application in IOS 5 and above?</a>.</p> <p>I am not an iOS expert and Apple doesn't provide any documentation so I can't explain much what's going on here. (It happens to work fine for me.) </p> <p>Anyway, you can play with it using xcode debug mode to see what happens under the hood.</p> <pre><code>struct GSTouchEvent * touchEvent = (struct GSTouchEvent*) &amp;gsTouchEvent; bzero(touchEvent, sizeof(touchEvent)); touchEvent-&gt;record.type = kGSEventHand; touchEvent-&gt;record.subtype = kGSEventSubTypeUnknown; touchEvent-&gt;record.location = point; touchEvent-&gt;record.windowLocation = point; touchEvent-&gt;record.infoSize = sizeof(GSHandInfo) + sizeof(GSPathInfo); touchEvent-&gt;record.timestamp = GSCurrentEventTimestamp(); touchEvent-&gt;record.window = winRef; touchEvent-&gt;record.senderPID = 919; bzero(&amp;touchEvent-&gt;handInfo, sizeof(GSHandInfo)); bzero(&amp;touchEvent-&gt;handInfo.pathInfos[0], sizeof(GSPathInfo)); GSHandInfo touchEventHandInfo; touchEventHandInfo._0x5C = 0; touchEventHandInfo.deltaX = 0; touchEventHandInfo.deltaY = 0; touchEventHandInfo.height = 0; touchEventHandInfo.width = 0; touchEvent-&gt;handInfo = touchEventHandInfo; touchEvent-&gt;handInfo.type = handInfoType; touchEvent-&gt;handInfo.deltaX = 1; touchEvent-&gt;handInfo.deltaY = 1; touchEvent-&gt;handInfo.pathInfosCount = 0; touchEvent-&gt;handInfo.pathInfos[0].pathIndex = 1; touchEvent-&gt;handInfo.pathInfos[0].pathIdentity = 2; touchEvent-&gt;handInfo.pathInfos[0].pathProximity = (handInfoType == kGSHandInfoTypeTouchDown || handInfoType == kGSHandInfoTypeTouchDragged || handInfoType == kGSHandInfoTypeTouchMoved) ? 0x03: 0x00; touchEvent-&gt;handInfo.x52 = 1; touchEvent-&gt;handInfo.pathInfos[0].pathLocation = point; touchEvent-&gt;handInfo.pathInfos[0].pathWindow = winRef; GSEventRecord* record = (GSEventRecord*) touchEvent; record-&gt;timestamp = GSCurrentEventTimestamp(); GSSendEvent(record, port); </code></pre> <p>To use this code, you have to call it multiple times. For one tap, there are touch-down, touch-drag and then touch-up.</p> <p>Also note that pathProximity is 0 when touch is up.</p> <p>As far as I remember, the winRef doesn't matter.</p> <p>Hope this helps.</p> <p>Edit: From Bugivore's comment, the problem is:</p> <blockquote> <p>The way I allocated touchEvent via malloc was wrong. It should be done as EntryLevelDev showed - "static uint8_t handJob[sizeof(GSEventRecord) + sizeof(GSHandInfo) + sizeof(GSPathInfo)];"</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload