IOHIDEventSystemCreate 在 iOS6 上始终返回 NULL(在 iOS5 上工作正常)。
有人知道为什么吗?
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;
}
是的,它对我来说在 iOS6 上也不起作用。
我现在用这个:
void *system = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
IOHIDEventSystemClientScheduleWithRunLoop(system, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDEventSystemClientRegisterEventCallback(system, handle_event, NULL, NULL);
CFRunLoopRun();
但我不知道为什么它只报告多点触控+键盘事件。
iOS6 中的 SpringBoard 称之为:
IOHIDEventSystemClientSetMatchingMultiple(system, array);
包含 PrimaryUsagePage + PrimaryUsage 的数组,但我无法让它工作......
例如,如果有人知道获取加速度计事件的解决方案,我也很感兴趣。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)