IOServiceAddMatchingNotification
IOServiceAddMatchingNotification
- Subject: IOServiceAddMatchingNotification
- From: Greg Hoover <email@hidden>
- Date: Tue, 22 Jan 2008 09:53:25 -0700
I'm using the following code to add a notification callback for HID
devices. It works the first time I plug in the USB device (and
sometimes the 2nd time), but typically only the first plug in is ever
registered. My understanding is that the notification is persistent
and shouldn't need to be recreated, no?
Thanks in advance.
+ (void)addHIDDeviceAddedNotificationCallback:
(IOServiceMatchingCallback)notificationCallback withContext:(void
*)context {
NSMutableDictionary *matchingDict;
kern_return_t result;
io_iterator_t addedIterator;
if (!notifyPort)
notifyPort = IONotificationPortCreate(kIOMasterPortDefault);
CFRunLoopAddSource(CFRunLoopGetCurrent(),
IONotificationPortGetRunLoopSource(notifyPort),
kCFRunLoopDefaultMode);
matchingDict = (NSMutableDictionary
*)IOServiceMatching(kIOHIDDeviceKey);
if (!matchingDict)
return;
result = IOServiceAddMatchingNotification(notifyPort,
kIOFirstMatchNotification,
(CFMutableDictionaryRef)matchingDict,
notificationCallback,
context,
&addedIterator);
// have to call to arm the notification callback
while (IOIteratorNext(addedIterator));
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden