Dev:IOHIDFamily

IOHIDFamily is a kernel extension that provides an abstract interface of with human interface devices (HID), e.g. the touchscreen, buttons, accelerometer, etc. In the user-land, there are two kinds of APIs associated to the IOHIDFamily: (1) the "public" ones, which are intended for HID driver writers; (2) the "private" ones, which are intended for event processing. This document will only outline the private APIs. References to the public one can be found in the Mac development documentation.

Class structure
Users of IOHID always first create an IOHIDEventSystem object that interfaces with the whole HID system. An event system consists of multiple IOHIDServices and IOHIDDisplays.

Services are various interfaces to the IOHIDLibPlugin kernel plugin (located at /System/Library/Extensions/IOHIDFamily.kext/PlugIns/IOHIDLib.plugin/IOHIDLib). They accept direct human input, and are the sources of all IOHIDEvents.

Displays are, obviously, the LCD screen. The IOHIDDisplay class can only control the brightness, not colors of individual pixels (Drawing is controlled by the VRAM). You only can control the displays indirectly by changing properties of the event system.

IOHID defines 20 types of events, of which the only handles 4 of them: keyboard (for buttons), digitizer (i.e. touchscreen), accelerometer and proximity events (temperature events are handled by IOKit directly). Each event may contain sub-events.

Problems with iOS >= 6.1 (or even earlier)
Since at least iOS 6.1 there is a check in the function IOHIDEventSystemCreate that compares the bundle identifier with "com.apple.springboard". If that check fails, the function will return NULL. Therefore you can no longer use the HID system in apps unless you circumvent this check.

Services
To access the services, you have to first match them using IOHIDEventSystemCopyMatchingServices</tt>. These criteria can be obtained using ioreg -l</tt>.

Keyboard events
The iPhoneOS button events are in fact treated as "keyboard" events. The following shows how to identify them or :