The device interface mechanism supported by the I/O Kit gives applications the ability to communicate with hardware from outside the kernel. This document describes how to use the device interface provided by the Human Interface Device (HID) family to access HID class devices (such as keyboards, mice, and uninterruptible power supplies) from applications running on Mac OS X.
You should read this document if you are an application developer who needs to write custom code to communicate with a HID class device from user space.
Important: This document is not intended to cover kernel-level HID device drivers. While it may provide some benefit in terms of understanding HID at a conceptual level, the details of writing in-kernel HID drivers are beyond the scope of this document. For more information on kernel drivers, see Getting Started with Hardware and Drivers and Kernel Framework Reference.
The document is divided into two main chapters:
“USB HID Overview” provides basic information about HID class devices and the Mac OS X HID Manager.
“Working With Legacy HID Class Device Interfaces” briefly outlines the process of accessing a HID class device and then presents a detailed code sample illustrating this process by acquiring access to a joystick.
Although the sample code in this document has been checked for accuracy, it is not intended to meet the needs of a commercial application. For example, error handling is minimal and simply facilitates debugging of this code—you should develop your own techniques for detecting and handling errors. Therefore Apple does not recommend that you directly incorporate the entire sample program into a commercial application.
Important: The sample code in this document is written to work with Mac OS X version 10.3 and later, and may not work with earlier releases.
This document assumes you are familiar with the general I/O Kit and device interface information presented in Accessing Hardware From Applications. In particular, for definitions of I/O Kit terms used in this document such as matching dictionary, family, and driver, see the overview of I/O Kit terms and concepts in the chapter Accessing Hardware From Applications.
A detailed description of the HID class specification is beyond the scope of this document—for more information, including the complete listing of HID usage tables, visit the USB website at http://www.usb.org.
For API documentation, see the IOHIDLib.h
and IOHIDKeys.h
entries in I/O Kit Framework Reference.
Last updated: 2009-10-19