在OS X中对HID设备的原始访问

Fak*_*ame 10 device-driver hid osx-snow-leopard

在OS X上获取HID设备原始访问权限的最简单方法是什么?

我一直在查看IOKit示例,但即使打开一个设备似乎也是不必要的复杂,涉及多个回调并包含来自六个库的东西.
libusb可用于OS X,但是内核会抓取所有HID设备以进行独占访问,并且在尝试使用无代码.kext阻止它与我的设备关联时,我一直遇到奇怪的行为(它阻止内核抓取设备最初,但任何配置设备的调用似乎都会导致内核从我正在测试的小python libusb脚本中获取设备.

基本上,我有一个只传输数据的HID设备.我想打开它(理想上是独占的)访问,然后获取数据流.

我在IOKit文档中找到的所有示例都非常复杂,与libusb中的~8行相比.必须有一种更简单的方法,而不是第三方的图书馆.

值得注意的是,我完全不熟悉OS X的任何功能编程.

Python支持将是一个很好的加分

Gor*_*ail 7

不幸的是除了使用没有其他方法HID Manager。OS X 中不支持对 HID 设备的原始访问。

\n\n

文档得很清楚:

\n\n
HID family. Through the HID Manager, the HID family provides a device\ninterface for accessing a variety of devices, including joysticks and other \ngame devices, audio devices, non-Apple displays, and UPS (uninterruptible \npower supply) devices. \n
Run Code Online (Sandbox Code Playgroud)\n\n

通过 POSIX api 进行原始访问仅适用于存储、网络和串行设备:

\n\n
Using POSIX APIs\nFor each storage, network, and serial device the I/O Kit dynamically\ncreates a device file in the file system\xe2\x80\x99s /dev directory when it discovers \na device and finds a driver for it, either at system startup or as part of \nits ongoing matching process. If your device driver is a member of the I/O \nKit\xe2\x80\x99s Storage, Network, or Serial families, then your clients can access your \ndriver\xe2\x80\x99s services by using POSIX I/O routines.\n
Run Code Online (Sandbox Code Playgroud)\n\n

因此,您可以HID Manager直接使用 api,也可以使用libusb或(正如另一个答案提到的)hidapi,它们只不过是HID Managerapi 上的包装库。使用这些库的好处是它们抽象了大部分低级调用,从而使它们更易于使用。

\n