« 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
- Hacking Video Game Consoles
- Oh cool, there's a PSP SDK
- "If you want to know how it feels to start your own record label, pile up a big bunch of money in your backyard and burn it."
- Step into XCode
- How to Make Yourself Happy and Remarkably Less Disturbable
- Extreme Programming Explained 2nd Ed.
- "Do not work in the same department as your spouse." -- lol
- I demo my dinky little Cocoa app I've been writing :D. When I lament about the documentation being too sparse, they point me to cocoadev.com and suggest that I check out Apple's sample code.
- I also share about my journey through the wonderful world of refactoring.
- "Tell your manager you're refactoring, not rewriting."
- Rails E-Commerce
- I chat with some people about how I was originally going into graphic design (music education before that, and fine arts before that). "Oh, you'll definitely make more money with comp sci," they say. "You make a ton if you're a good programmer, but still a lot if you're a really bad one." Someone pipes up: "Wait, are you sure you make more as a good programmer? You'd probably make less money in most cases." We share a melancholy sigh and discuss manager ignorance.
- Tom tells me the secret to cheating in Wack-a-Mole, "handy for when you're playing for money." Basically, hit the things sideways to make them stick.
- Bradley tells me the secret to calculus; something about there being really only two basic concepts you need to understand.
- He also tells me his approach to learning human languages: get a bunch of books, then get a native speaker. Where to find native speakers? "I just ask around. It helps that I work for a big company." At some point in the evening, it occurs to me that being a both a mathematician and a polyglot has got to have some kind of uber-positive effect on one's programming skills. I'm sure his being a DDR master helps as well xD
- At some other point in the evening, it occurs to me that this was the first time I'd ever seen Wolf without a tie on. Lol! He encourages me to look into Aaron Hillegass' Cocoa book. Looks like it's actually available at my library :)
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:
- Find the object that represents the device in the I/O registry
- Create device interface
- Open connection to device
- 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:
- Create queue
- Add element cookies to queue
- Add queue to run loop
- 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.
