iOS6上的IOHIDEventSystemCreate失败了 [英] IOHIDEventSystemCreate on iOS6 failed
本文介绍了iOS6上的IOHIDEventSystemCreate失败了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
IOHIDEventSystemCreate总是在iOS6上返回NULL(在iOS5上正常工作)。
任何人都知道为什么?
IOHIDEventSystemCreate always return NULL on iOS6 (work fine on iOS5). Anyone know why?
#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上工作。
我现在用这个:
Yes, it doesn't work on iOS6 for me too. I now use this:
void *system = IOHIDEventSystemClientCreate(kCFAllocatorDefault);
IOHIDEventSystemClientScheduleWithRunLoop(system, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
IOHIDEventSystemClientRegisterEventCallback(system, handle_event, NULL, NULL);
CFRunLoopRun();
但我不知道为什么它只报告多点触控+键盘事件。
iOS6中的SpringBoard称之为:
But I don't know why it only reports multitouch+keyboard events. SpringBoard in iOS6 calls this:
IOHIDEventSystemClientSetMatchingMultiple(system, array);
包含PrimaryUsagePage + PrimaryUsage的数组,但我无法正常工作...
如果有人知道获得加速度计事件的解决方案,我也很感兴趣。
with an array containing PrimaryUsagePage + PrimaryUsage, but I can't get it working... If someone knows a solution for getting accelerometer events for example, I'm interested too.
这篇关于iOS6上的IOHIDEventSystemCreate失败了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文