I have written a python script that polls evdev for a HID barcode scanner (emulates a keyboard): the script works well on Linux platforms (Ubuntu). Is there an OS X Python equivalent for evdev that would allow minor porting of the existing python script?
If you have Python experience and have configured it for a HID device input, please indicate this in your response.
I guess there is no evdev port for mac os because last one depends on linux kernel. If you want to implement some business logic on a HID in mac os you should to use as in the comments suggested some high level abstraction. But if you want evdev on low level, I think easy way to do so using the Docker. I have no experience with HID devices on mac os, but I resolved the same problem with the other driver.
I got a simple test working using cython-hidapi (installable as
pip install hidapi
- note this is different to the one linked in the comments but seems to be similar in function). I also had installedhidapi-devel
from macports but I'm not sure that this is necessary as it continues to work after deactivating the port.By modifying the example try.py to use the VID/PID of a Microsoft USB wireless keyboard/mouse device as follows
And running with
$ sudo python try.py
I was able to get the following output:The particular device I'm using seems to enumerate as multiple HID devices for the keyboard & mouse amongst other things, so it seems to be a bit random which one you get, but for a barcode scanner it should be pretty straight forward.