views:

428

answers:

2

Hi all,

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.)

+2  A: 

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'
weichsel
+1  A: 

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.

WhirlWind