iphone - iOS6 上的 IOHIDEventSystemCreate 失败

标签 iphone ios jailbreak iokit

IOHIDEventSystemCreate 在 iOS6 上总是返回 NULL(在 iOS5 上工作正常)。 有人知道为什么吗?

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;
}

最佳答案

是的,它也不适用于我的 iOS6。 我现在用这个:

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

但是我不知道为什么它只报告多点触控+键盘事件。 iOS6 中的 SpringBoard 调用这个:

IOHIDEventSystemClientSetMatchingMultiple(system, array);

有一个包含 PrimaryUsagePage + PrimaryUsage 的数组,但我无法让它工作... 例如,如果有人知道获取加速度计事件的解决方案,我也很感兴趣。

关于iphone - iOS6 上的 IOHIDEventSystemCreate 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14354240/

相关文章:

iphone - Facebook API 限制

iphone - 推送通知证书问题

ios - 如何保护越狱设备中的 plist 文件?

ios - 自定义字体未添加到项目中

iphone - 连接从自定义类加载的 XIB 到 Storyboard的操作

iOS - 在 Swift 中,我们是 "send a message"还是 "call method/function"?

ios - 如何在越狱调整中检测 AVCaptureSession 启动并获取哪个应用程序启动它?

iOS MobileSubstrate CFNotificationCenterPostNotification - 不工作

ios - 如何将数据从 UITableViewCell 传输到另一个 UIViewController?

ios - 自定义 UITableView 分隔符在 View 加载时正确显示,但在单元格滚动出 View 并返回时默认为不需要的行为