Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The HID Class Device Interface is definitely what you need. There are basically two steps:</p> <p>First you need to find the mouse devices. To do this you need to construct a matching dictionary and then search the IO Registry with it. There is some sample code <a href="http://developer.apple.com/documentation/devicedrivers/conceptual/HID/basics/basics.html#//apple_ref/doc/uid/TP40000970-CH211-CHDGCEDC" rel="noreferrer">here</a>, you will need to add some additional elements to the dictionary so you just get the mice instead of the all HID devices on the system. Something like this should do the trick:</p> <pre><code>// Set up a matching dictionary to search the I/O Registry by class // name for all HID class devices` hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); // Add key for device usage page - 0x01 for "Generic Desktop" UInt32 usagePage = 0x01; CFNumberRef usagePageRef = ::CFNumberCreate( kCFAllocatorDefault, kCFNumberLongType, &amp;usagePage ); ::CFDictionarySetValue( hidMatchDictionary, CFSTR( kIOHIDPrimaryUsagePageKey ), usagePageRef ); ::CFRelease( usagePageRef ); // Add key for device usage - 0x02 for "Mouse" UInt32 usage = 0x02; CFNumberRef usageRef = ::CFNumberCreate( kCFAllocatorDefault, kCFNumberLongType, &amp;usage ); ::CFDictionarySetValue( hidMatchDictionary, CFSTR( kIOHIDPrimaryUsageKey ), usageRef ); ::CFRelease( usageRef ); </code></pre> <p>You then need to listen to the X/Y/button queues from the devices you found above. This <a href="http://developer.apple.com/documentation/devicedrivers/conceptual/HID/workingwith/workingwith.html#//apple_ref/doc/uid/TP30000105-TP9" rel="noreferrer" title="HID Class Device Interface">sample code</a> should point you in the right direction. Using the callbacks is much more efficient than polling!</p> <p>The HID code looks much more complex than it is - it's made rather "wordy" by the CF stuff. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload