2013-01-16 40 views
3

IOHIDEventSystemCreate總是在iOS6上返回NULL(在iOS5上正常工作)。 任何人都知道爲什麼?IOHIDEventSystem在iOS6上創建失敗

Example on iPhoneDevWiki

#include <IOKit/hid/IOHIDEventSystem.h> 
#include <stdio.h> 

void handle_event (void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event) { 
    // handle the events here. 
    printf("Received event of type %2d from service %p.\n", IOHIDEventGetType(event), service); 
} 

int main() { 
    // Create and open an event system. 
    IOHIDEventSystemRef system = IOHIDEventSystemCreate(NULL); 
    IOHIDEventSystemOpen(system, handle_event, NULL, NULL, NULL); 

    printf("HID Event system should now be running. Hit enter to quit any time.\n"); 
    getchar(); 

    IOHIDEventSystemClose(system, NULL); 
    CFRelease(system); 
    return 0; 
} 

回答

1

是的,它不會對iOS6的工作對我來說太。 我現在用這個:

void *system = IOHIDEventSystemClientCreate(kCFAllocatorDefault); 
IOHIDEventSystemClientScheduleWithRunLoop(system, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); 
IOHIDEventSystemClientRegisterEventCallback(system, handle_event, NULL, NULL); 
CFRunLoopRun(); 

但我不知道爲什麼它只報告多點觸控+鍵盤事件。 跳板iOS6的電話本:

IOHIDEventSystemClientSetMatchingMultiple(system, array); 

含PrimaryUsagePage + PrimaryUsage一個數組,但我不能得到它的工作... 如果有人知道用於獲取加速度計的事件,例如一個解決方案,我很感興趣太。

+1

我得到'IOKit/hid/IOHIDEventSystem.h'文件未找到。任何想法我錯過了什麼 –