Friday 18 May 2012

Notes on Apple IR remotes reverse-engineering

In 2009, I wrote a driver to make the infra-red remote on my original MacBookAir work out-of-the-box on Linux. The driver was rejected upstream on the basis that the device would soon be supported through more generic means. In the meanwhile, it lived in Fedora's kernel tree, and I took some notes about implementing pairing, so that only your remote would work with your computer.

I'm posting this now because I wanted to poke at a MacOS X application today, and couldn't for the life of me remember the name of the program to monitor disk-activity. Hope this finds its way to a search engine near you.

  • Launched the System Preferences, Security, and unlock the panel.
  • In a terminal: sudo fs_usage -f filesys -w and check the output when enabling/disabling the remote.
  • We can see the modified file is /Library/Preferences/
  • Installed PlistEditPro and opened the file up.
  • Now try to pair a remote (menu and next together)
  • You can see the UID value changing in the file. I named the remotes I had available to me:
    • New remote: UID = 145 
    • Old clean remote: UID = 24
    • Old dirty remote: UID = 227 
  • After adding some debug to the aforementioned appleir driver, in Linux, I got:
    • New remote: appleir: received (5 bytes) 25 87 e0 91 02
    • Old clean remote: appleir: received (5 bytes) 25 87 e0 18 03
    • Old dirty remote: appleir: received (5 bytes) 25 87 e0 e3 02
  • So the 4th byte is the remote's UID.
Now one could implement remote pairing using a sysfs attribute, a udev helper to apply the pairing across reboots, and PolicyKit helper to set and save the paired UID.

This will be left as an exercise to the reader :)

No comments: