开发者

How to know a device's name from its device ID in OS X?

开发者 https://www.devze.com 2022-12-10 04:47 出处:网络
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 p开发者_如何学编程os

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 p开发者_如何学编程osition 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.)


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'


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消