直接访问OSX中的键盘事件 [英] Direct access to keyboard events in OSX

查看:90
本文介绍了直接访问OSX中的键盘事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找使用Cocoa或Carbon框架(或任何底层API)在OS X中对原始键盘事件进行应用程序范围的访问.我知道我可以重写NSApplication的sendEvent:来获取原始的键盘信息,但是对于元键(命令,控制,替代键,Shift键等)不会显示为按键事件.我正在寻找类似于Microsoft DirectInput框架的东西.

谢谢!

解决方案

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

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.

这篇关于直接访问OSX中的键盘事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆