Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOHIDEventSystemCreate on iOS6 failed

IOHIDEventSystemCreate always return NULL on iOS6 (work fine on iOS5). Anyone know why?

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;
}
like image 977
Kevin Cao Avatar asked Nov 21 '25 23:11

Kevin Cao


1 Answers

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();

But I don't know why it only reports multitouch+keyboard events. SpringBoard in iOS6 calls this:

IOHIDEventSystemClientSetMatchingMultiple(system, array);

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.

like image 190
Guigeek Avatar answered Nov 24 '25 13:11

Guigeek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!