The Bouncer
My entry into Iron Coder Live, C4[1] Edition, called "The Bouncer", took third place. I'm pretty happy considering the first and second were native iPhone applications, and mine was an Input Manager hack. Congrats to Glen and Ken Aspeslagh for first place and Lucas Newman for second!
The Bouncer is an application that can bounce the dock icon of other running Cocoa applications. It has an "interactive" mode where you can bounce the icons by using different keys on your keyboard. I finished off the demo with icons bouncing in sync to an audio clip of The Blue Danube. Here is a video of the hack in action:
Direct link: TheBouncer.mp4 (5.9 MB), TheBouncer.mov (3.8 MB)
I don't yet have a binary available, but the code is available in my Subversion repository. The Input Manager itself is pretty simple. It sets up a distributed object with one method:
- (void) bounce
{
[NSApp requestUserAttention: NSInformationalRequest];
[NSApp cancelUserAttentionRequest: NSCriticalRequest];
}
The rest is just gravy. For the interactive window, I use a custom view. The goofy icon animation was definitely inspired by Dance Dance Revolution and Guitar Hero. Originally I used the standard keyUp:
and keyDown:
callbacks, but those also get triggered on key autorepeats which I didn't want. So I fell back to using the HID API using my DDHidLib. This has the nice side benefit of registering key presses for other apps, too. I show this in the video when icons still bounce when typing in Text Edit. I did manage to utilize the iPhone to start off the playback remotely. This was a simple CGI program that sent a BSD notification to start the playback.