« January 2007 | Main | March 2007 »

PSIG 101 | DDHidLib

Saturday, February 3, 2007

(What is PSIG? | PSIG 101 announcement)

I'm going to start taking notes at these programmer meetings I attend; mostly for my own benefit, but also because it would be a terrible shame for all of this to go unrecorded :).

Books, advice, ideas

Programming Special Interest Group
Presentation: DDHidLib

Dave began with a quick pictorial history of human interface devices. The hilarious thing about this group is that people actually remember the punch card reader and the teletype machine; someone even knew which model of teletype it was o___O.

I was especially interested in the video on Multi-Touch Interaction.

On to the main topic at hand: USB HID specifications include the HID device class (specifies how data should be extracted) and the HID usage tables (defines constants to be interpreted by the app). The specs can be downloaded here.

Apple's I/O kit has support for HID: IOHIDLib.

One of Apple's developer tools, IORegistryExplorer, provides a database of all devices on your system.

Accessing devices:

  1. Find the object that represents the device in the I/O registry
  2. Create device interface
  3. Open connection to device
  4. Communicate with device using functions provided by HID manager

Components of a device (every button, etc.) are called elements. Each element has unique number called a cookie, used to get status for the element. Cookies are static across sessions.

Queues for asynchronous notification:

  1. Create queue
  2. Add element cookies to queue
  3. Add queue to run loop
  4. Start queue

At this point, Dave gives us a detailed demo on IOHIDLib, scaring us with loads and loads of hard-to-understand code (scared me, anyway).

Then he whips out DDHidLib, his brilliant Obj-C wrapper around IOHIDLib. Why an Obj-C wrapper? Because of easier resource management, modern error handling, KVC/KVO (cocoa binding), and it makes common tasks easier. DDHidLib includes these classes: DDHidQueue and DDHidDevice<|---DDHidMouse

He also provides two very interesting utilities: HID Device Browser and HID Device Test. The device browser has this Event Watcher feature which we discovered can log keystrokes even while you're off typing in your OS X account password.

Dave hooked up various HIDs during his demo, like a Logitech Precision Gamepad and an N64 controller. He also passed around a variety of ancient game controllers -- you can get these things from Happ Controls. He concluded by playing the Atari 2600 game, Adventure, up on the big screen. All I can say is... wow :). We then discussed how somebody needs to make a repository for all these useful Cocoa tools, because Sourceforge doesn't accept everything.

1:09 PM | Comments (4)