Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It can be done by using IOKit and the HIDManager class.</p> <p>If exclusive access to the keyboard is desired, the <code>kIOHIDOptionsTypeSeizeDevice</code> option can be used, but the program will have to be run with root privileges.</p> <p>A stub of the code required to obtain this result is shown below:</p> <pre><code>// Create a manager instance IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDManagerOptionNone); if (CFGetTypeID(manager) != IOHIDManagerGetTypeID()) { exit(1); } // Setup device filtering using IOHIDManagerSetDeviceMatching //matchingdict = ... IOHIDManagerSetDeviceMatching(manager, matchingdict); // Setup callbacks IOHIDManagerRegisterDeviceMatchingCallback(manager, Handle_DeviceMatchingCallback, null); IOHIDManagerRegisterDeviceRemovalCallback(manager, Handle_RemovalCallback, null); IOHIDManagerRegisterInputValueCallback(manager, Handle_InputCallback, null); // Open the manager and schedule it with the run loop IOHIDManagerOpen(manager, kIOHIDOptionsTypeSeizeDevice); IOHIDManagerScheduleWithRunLoop(manager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); // Start the run loop //... </code></pre> <p>More detailed information can be found in the Apple docs over here: <a href="http://developer.apple.com/library/mac/#documentation/DeviceDrivers/Conceptual/HID/new_api_10_5/tn2187.html" rel="noreferrer">http://developer.apple.com/library/mac/#documentation/DeviceDrivers/Conceptual/HID/new_api_10_5/tn2187.html</a></p> <p>The complete code I used for my application can be found here: <a href="https://gist.github.com/3783042" rel="noreferrer">https://gist.github.com/3783042</a></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. 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