static IOHIDEventRef generateChildEventTouchDown(int index, float x, float y)
{
IOHIDEventRef child = IOHIDEventCreateDigitizerFingerEvent(kCFAllocatorDefault, mach_absolute_time(), index, 3, 3, 0.5, 0.5, 0.0f, 0.0f, 0.0f, 1, 1, 0);
IOHIDEventSetFloatValue(child, 0xb0014, 0.04f); //set the major index getRandomNumberFloat(0.03, 0.05)
IOHIDEventSetFloatValue(child, 0xb0015, 0.04f); //set the minor index
eventToAppend[index] = child;
isEventTouchUp[index] = false;
return child;
}
void performTouchFromRawData(UInt8 *eventData)
{
// generate a parent event
IOHIDEventRef parent = IOHIDEventCreateDigitizerEvent(kCFAllocatorDefault, mach_absolute_time(), 3, 99, 1, 4, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, 0, 0);
IOHIDEventSetIntegerValue(parent , 0xb0019, 1); //set flags of parent event flags: 0x20001 → 0xa0001
IOHIDEventSetIntegerValue(parent , 0x4, 1); //set flags of parent event flags: 0xa0001 → 0xa0011
// append new events
for (int i = 0; i < getTouchCountFromDataArray(eventData); i++)
{
//NSLog(@"### com.zjx.springboard: get data. index: %d. type: %d. touchIndex: %d. x: %f. y: %f", i, getTouchTypeFromDataArray(eventData, i), getTouchIndexFromDataArray(eventData, i), getTouchXFromDataArray(eventData, i), getTouchYFromDataArray(eventData, i));
appendChildEvent(parent, getTouchTypeFromDataArray(eventData, i), getTouchIndexFromDataArray(eventData, i), getTouchXFromDataArray(eventData, i), getTouchYFromDataArray(eventData, i));
}
// append those existing events
for (int i = 0; i < MAX_TOUCH_INDEX; i++)
{
if (!isEventTouchUp[i])
{
if (eventToAppend[i])
IOHIDEventAppendEvent(parent, eventToAppend[i]);
}
}
IOHIDEventSetIntegerValue(parent, 0xb0007, 0x23);
IOHIDEventSetIntegerValue(parent, 0xb0008, 0x1);
IOHIDEventSetIntegerValue(parent, 0xb0009, 0x1);
postIOHIDEvent(parent);
CFRelease(parent);
}
static void postIOHIDEvent(IOHIDEventRef event)
{
static IOHIDEventSystemClientRef ioSystemClient = NULL;
if (!ioSystemClient)
{
ioSystemClient = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
}
if (senderID != 0)
{
IOHIDEventSetSenderID(event, senderID);
}
else
{
NSLog(@“### com.zjx.springboard: sender id is 0!”);
return;
}
IOHIDEventSystemClientDispatchEvent(ioSystemClient, event);
}
怎么解决呢