Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HID's and IOServiceAddMatchingNotification



Spencer,

I had the exact same problem today. I was adding two
notifiers, kIOFirstMatchNotification and
kIOTerminatedNotification.  Even when plugging and
unpluggin the same device, my terminated callback
always worked, while the match callback was only
triggered the first time, when called manually right
after the notifier is installed.

 I noticed a small difference in my two callback
routines: the match callback explicitly released the
iterator and the terminated code did not.  So I
removed the code (see the end of the code below:
IOObjectRelease( iterator );) from the match callback
and everything works fine now.

Aaron

======================================
Hello,
I am trying to get my app to be notified every time a
human interface device is physically attached to the
computer and made available to access in userspace
through IOKit. The documentation leads me to believe
that this can be done using
IOServiceAddMatchingNotification. Unfortunately I have
been unable to get this to function as desired at
all--while IOServiceAddMatchingNotification does give
my app a list of all currently connected HID's, my
notification callback is never called when new devices
are connected. I have added the corresponding run loop
source to the run loop, and I am actually running the
run loop, so I'm stumped as to why this would be.

In hopes that someone on this list might be able to
shed some light on my problem, I have attached a
greatly simplified version of my program, which still
does not function as I had expected. In theory, while
this program is running, it should print something
every time a new device is connected, instead of just
once at the beginning. Can anyone see what is wrong
with this code? Am I suffering from some fundamental
misunderstanding of IOKit?

This is on a MacBook Pro v2,2, if that is at all
relevant.


thanks in advance,
spencer

void callback( void * ref, io_iterator_t iterator )
{
    printf( "new device(s)\n" );
    io_object_t hidObject = 0;
    while( hidObject = IOIteratorNext( iterator ) )
        IOObjectRelease( hidObject );
    IOObjectRelease( iterator );
}




 
____________________________________________________________________________________
TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.