[英]IOHIDEventSystemCreate on iOS6 failed
IOHIDEventSystemCreate總是在iOS6上返回NULL(在iOS5上正常工作)。 誰知道為什么?
#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;
}
是的,它對我來說也不適用於iOS6。 我現在用這個:
void *system = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
IOHIDEventSystemClientScheduleWithRunLoop(system, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDEventSystemClientRegisterEventCallback(system, handle_event, NULL, NULL);
CFRunLoopRun();
但我不知道為什么它只報告多點觸控+鍵盤事件。 iOS6中的SpringBoard稱之為:
IOHIDEventSystemClientSetMatchingMultiple(system, array);
使用包含PrimaryUsagePage + PrimaryUsage的數組,但我無法使其工作......例如,如果有人知道獲取加速計事件的解決方案,我也很感興趣。
將IOKit.framework拖到項目中時,可以更改#include“IOHIDEventSystem.h”之類的標題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.