如何在 OS X 中从设备 ID 获知设备名称?

发布于 2024-08-09 23:57:20 字数 163 浏览 3 评论 0原文

我正在 OS X 中编写一个程序,该程序接收来自鼠标和触摸板的单击事件。当用户单击某处时,操作系统会将设备 ID(只是一个 int)和光标的位置发送到我的回调函数。我想知道点击事件是来自鼠标还是触摸板。那么,如何从设备ID得知设备的名称呢?

谢谢你!

(我很抱歉我的英语不好。)

I'm writing a program in OS X that receives click events from a mouse and a touchpad. When the user clicks at somewhere, the OS sends the device ID, which is just an int, and the position of the cursor to my callback function. I want to know if the click event comes from mouse or touchpad. So, how can I know the device's name from its device ID?

Thank you!

(I'm sorry for my poor English.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

驱逐舰岛风号 2024-08-16 23:57:20

您可以查看 IOKit 注册表.
作为起点: HID Explorer示例代码

要检查您正在搜索的 ID 是否存在于 IOKit 注册表中,您可以 grep ioreg 命令行实用程序的输出:

ioreg |grep 'Track'

You could look at the IOKit Registry.
As starting point: HID Explorer sample code

To check if the ID you are searching for exists in the IOKit Registry, you can grep the output of the ioreg command line utility:

ioreg |grep 'Track'
最后的乘客 2024-08-16 23:57:20

连接到 I/O 注册表中的服务平面,然后使用 IORegistryEntrySearchCFProperty() 和 kIORegistryIterateRecursively() 来搜索与您拥有的设备 ID 相匹配的设备 ID。然后,您应该能够找到注册表中列出的设备的其他属性。

IORegistry Explorer 将帮助您了解注册表的布局。

Connect to the service plane in the I/O registry, then use IORegistryEntrySearchCFProperty() with kIORegistryIterateRecursively() to search for a device ID that matches the one that you have. You should then be able to find the other properties of the device as they are listed in the registry.

IORegistry Explorer will help you understand the layout of the registry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文