简体   繁体   中英

How do I “unregister” an IOKit.HID callback?

I'm using IOHIDDeviceRegisterInputReportCallback to listen to incoming reports while using a HID device. At the point I disconnect from the device (in software, not physically), I'd like to unregister this callback. However, I'm not seeing any methods to unhook my callback in Apple's docs. I'm sure I'm just missing something. Can anyone point me to the proper way to unhook from a device? If I'm not supposed to directly unhook my callback, what's the proper way to disconnect from my software from the HID device?

I'm doing this project in Swift, but an answer in Objective-C or C++ should be fine too.

Shortly after I asked this, I found the answer in Apple's documentation . They state:

Note: There is no function to unregister IOHID callback routines. They are unregistered by calling the register function and passing NULL for the pointer to the callback routine.

So, the answer is to pass a null/nil pointer to the callback registration function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM