IOHIDEventSystemCreate在iOS6的失败(IOHIDEventSystemCre

2019-07-18 07:18发布

IOHIDEventSystemCreate总是在iOS6的(在iOS5中,做工精细)返回NULL。 任何人都知道为什么吗?

实施例上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;
}

Answer 1:

是的,它不会对iOS6的工作对我来说太。 我现在用的这个:

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

但我不知道为什么它只报告多点触控+键盘事件。 跳板iOS6的电话本:

IOHIDEventSystemClientSetMatchingMultiple(system, array);

含PrimaryUsagePage + PrimaryUsage一个数组,但我不能得到它的工作......如果有人知道用于获取加速度计的事件,例如一个解决方案,我很感兴趣了。



Answer 2:

你可以改变头象的#include“IOHIDEventSystem.h”当你拖动IOKit.framework到项目



文章来源: IOHIDEventSystemCreate on iOS6 failed