且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

直接访问OSX中的键盘事件

更新时间:2023-12-01 19:09:22

我认为DirectInput的等效项是HID Manager. HID代表人机接口设备",而HID Manager(有时称为HIDLib)是HID的低级API:键盘,鼠标和操纵杆.​​ p>

Leopard有一个新的HID Manager API,记录在技术说明TN2187 中.在《 HID类设备接口指南》 中,记录了有关Leopard的API.我围绕旧的API DDHidLib 编写了Objecive-C包装器觉得有用. Leopard API更好.如果可以的话,我会直接使用它.

I'm looking for application-wide access to raw keyboard events in OS X, either using the Cocoa or Carbon frameworks (or any of the underlying APIs, for that matter). I know that I can override NSApplication's sendEvent: to get raw keyboard information, but for the meta keys (command, control, alternate, shift, etc) don't show up as keystroke events. I'm looking for something analogous to Microsoft's DirectInput framework.

Thanks!

I think the equivalent to DirectInput is HID Manager. HID stands for "human interface device" and HID Manager (sometimes called HIDLib) is the low-level API to HIDs: keyboards, mice, and joysticks.

Leopard's got a new HID Manager API, documented in Technical Note TN2187. The pre-Leopard API is documented in HID Class Device Interface Guide. I wrote an Objecive-C wrapper around the older APIs, DDHidLib, which you may find useful. The Leopard API is much nicer. I'd use that directly, if you can.