I'm trying to write a simple command line program which sends keystrokes on a given keyboard to a UDP server. I'm programming on OSX using the IOKit
framework and its IOHIDManager
class.
For the purpose of my program, I'd like to use the kIOHIDOptionsTypeSeizeDevice
when opening the IOHIDManager
instance and sending the UDP messages in the callback setup using IOHIDManagerRegisterInputValueCallback
.
When I setup the filtering through the IOHIDManagerSetDeviceMatching
function to match the internal keyboard of my MacBook Pro, everything works fine: key presses aren't passed on to the focused application anymore and events correctly sent over UDP.
When I try to match a USB CardReader ( http://www.gitak.com/GIT-200USB.PDF ), everything works correctly up to the first event sent by the device when swiping a card. After the first character, the registered callback isn't called anymore.
To be more precise:
kIOHIDOptionsTypeSeizeDevice
kIOHIDOptionsTypeNone
instead of kIOHIDOptionsTypeSeizeDevice
(even though the events are still passed to the focused application)The relatively simple program can be found here:
https://gist.github.com/3783042
How can I modify it in order to not cause the card reader to become unresponsive after having sent the first event?
As it turns out, it was the device being defective. I ordered a new one and everything works now!