我試圖在我的應用程序中獲取觸摸事件。所以我使用IOHIDFamily回調來獲取事件。我的代碼是這樣的:IOHIDEventSystemClientScheduleWithRunLoop with EXC_BAD_ACCESS
void handle_event(void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event)
{
printf("Received event of type %2d from service %p.\n",
IOHIDEventGetType(event), service);
}
- (void)viewDidLoad
{
[super viewDidLoad];
void *ioHIDEventSystem = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
IOHIDEventSystemClientScheduleWithRunLoop(system, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDEventSystemClientRegisterEventCallback(system, handle_event, NULL, NULL);
CFRunLoopRun();
}
我執行時遇到一個錯誤:
IOHIDEventSystemClientScheduleWithRunLoop(系統,CFRunLoopGetCurrent(),kCFRunLoopDefaultMode);
IOKit`IOHIDEventSystemClientScheduleWithRunLoop:
...
0x32f8fd14:CMP.W R10,#0
0x32f8fd18:STRD R10,R11,[R4,#116] < --- EXC_BAD_ACCESS(代碼= EXC_ARM_DA_ALIGN)
0x32f8fd1c:beq 0x32f8fdac; IOHIDEventSystemClientScheduleWithRunLoop + 168
0x32f8fd1e:ldr r1,[r4,#96]
0x32f8fd20:cbz r1,0x32f8fd2a; IOHIDEventSystemClientScheduleWithRunLoop + 38
0x32f8fd22:MOV R0,R10
...
難道我用IOHIDFamily在錯誤的道路?