I\'ve now discovered how to hook/tap keyboard events on OS X at a low level: How to tap (hook) F7 through F12 and Power/Eject on a MacBook keyboard
Printing out the
If you register the callback on each device of interest individually with IOHIDDeviceRegisterInputValueCallback
then the sender
argument will be a IOHIDDeviceRef
indicating the device. (instead of using IOHIDManagerRegisterInputValueCallback
where the sender will be the HID manager reference)
The only downside for this is that you'll need to register for and handle notification of hotplugging events for matching devices. (register whenever a new device appears, and deregister when a device disappears)
You can get HID device references using IOHIDDeviceCreate()
- this takes an io_service_t
as an argument. This in turn means you need to use the standard IOKit IOService matching functions to obtain and watch your list of devices, but you do indeed get an explicit list of individual devices, which you can query for names to show to the user, etc. The key function for this is IOServiceAddMatchingNotification.