This page documents some informal experiments with the Apple Remote; it is a contribution to the Buttons project and was initiated as part of the NoTube EU project.
See also: blog post, ruby code, xmpp integration discussions
HTML/js client code available: screenshot, svn
The purpose of this page is to help developers understand how to read events from the Apple Remote, and to explore ways of wiring this event stream into a Buttons XMPP protocol.
Success: there is now running code that streams these events over XMPP
Contents |
Overview
Summary:
- left, right, pause/play and menu - send you 'pressed' and 'unpressed' when the latter occurs (so long as it happens quickly, a second or two max)
- up (+) and down (-) will immediately send pressed / unpressed events, without waiting
- OSX APIs allow client code to negotiate exclusive access to the IR stream
- the event codes and general approach are defined by the USB HID specs
See buttons on delicious for related links
Next steps / help needed
- Given a commandline compiled C program on OSX that periodically emits event descriptions to stdout, how can we wire this into XMPP?
- perhaps a little ruby program with a separate thread to communicate with an osx shell running this script?
Software
We use a trivially modified version of iremoted iremote.c, called buttons_iremote.c, see svn for src.
- it emits pseudo-xml streams for slightly easier parsing
- it requests exclusive access to the remote's IR event stream, to avoid desktop interference (frontrow, volume)
Building:
- gcc -Wall -o iremoted_buttons iremoted_buttons.c -framework IOKit -framework Carbon
Example use
Cornercase:osx danbri$ ./iremoted_buttons <pressed>0x15</pressed> <depressed>0x15</depressed> <pressed>0x15</pressed> <depressed>0x15</depressed> <pressed>0x16</pressed> <depressed>0x16</depressed>
Experiment summary
I'm running a modified version of iremoted, patched to get exclusive access to the OSX IR event stream from this (USB HID) device, ie. Volume/FrontRow etc don't interfere.
The comments intersperced with the markup were typed as I did the tests, and are left unedited (for now).
Oh, and I messed up my demo by pressing pause and menu at same time, which I think is the pairing command; I think I need to reboot. Reboot didn't help, but Preferences/Security and 'Unpair' did.
Button event logs
The following is the log from some tests with the IR Apple Remote, to see what events it sends.
Cornercase:buttons danbri$ ./iremoted_buttons <pressed>0x1d</pressed>
<depressed>0x1d</depressed>
(that was a quick press of '+' key)
<pressed>0x1d</pressed>
<depressed>0x1d</depressed>
(same but longer, a few seconds) <pressed>0x1e</pressed>
<depressed>0x1e</depressed>
(quick press of - key)
<pressed>0x17</pressed>
<depressed>0x17</depressed>
left
<pressed>0x16</pressed>
<depressed>0x16</depressed>
right
<pressed>0x16</pressed>
<depressed>0x16</depressed>
r <pressed>0x16</pressed>
<depressed>0x16</depressed>
<pressed>0x17</pressed>
<depressed>0x17</depressed>
<pressed>0x1d</pressed>
<depressed>0x1d</depressed>
<pressed>0x1d</pressed>
<depressed>0x1d</depressed>
long presses of left and right are ignored; no events sent. by contrast, + sends press/unpress at the same time, when the button is initially pressed <pressed>0x1e</pressed>
<depressed>0x1e</depressed>
<pressed>0x1d</pressed>
<depressed>0x1d</depressed>
<pressed>0x1d</pressed>
<depressed>0x1d</depressed>
<pressed>0x1d</pressed>
<depressed>0x1d</depressed>
ah no, i lied, it does wait for depress
<pressed>0x1e</pressed>
<depressed>0x1e</depressed>
ok middle key now:
<pressed>0x15</pressed>
<depressed>0x15</depressed>
<pressed>0x15</pressed>
<depressed>0x15</depressed>
<pressed>0x15</pressed>
<depressed>0x15</depressed>
that's the odd one, it waits until you release, then sends both. pause/play button.
<pressed>0x15</pressed>
<depressed>0x15</depressed>
... and if you hold for more than a few seconds, forget about it, no events come through.
<pressed>0x14</pressed>
<depressed>0x14</depressed>
<pressed>0x14</pressed>
<depressed>0x14</depressed>
menu seems to work the same way as pause/play.
</pre>