Apple Remote Cocoa Source
Last weekend I had some fun playing around with the remote of my MacMini which is connected to a flat screen TV. I came up with ideas about apps that should use the remote (Browser, Dock, …).
Before starting such a project I wanted to check out how to use the apple remote in a cocoa app. After some browsing in the web it was clear that there is no official API released by Apple yet. The best resource I found was on the Cocoa Dev Wiki where some guys wrote about what they already found out. Based on this work I started to develop an Objective-C class which would handle asynchronous events from the apple remote control.
Today I had the time to do some sample app for the class and to release it to the public. Check it out on the Source Code page.
For details about how this works read the Cocoa Dev Wiki page about this topic. It contains a lot of links to useful documentation (IO Kit, Samples, …).
As I’ve written on the source code page keep in mind that there are no “Guidelines” about how to use the apple remote in third party apps.
Have fun and keep things simple (especially for the end user)!
March 23rd, 2006 at 11:42 am
Apple claims the little remote will control a Keynote presentation on MacBook Pro.
I don’t have MBP or the ability to do programming to achieve this for my iMac but you seem to be almost there.
I await further developments…..
March 23rd, 2006 at 3:31 pm
Just a couple of days more and you will be able to do more with the remote on your iMac.
stay tuned
March 23rd, 2006 at 3:52 pm
Hi Martin,
I just used your AppleRemote program to create such a driver for KeyNote - I’ll put it up on my site within a few minutes
Thanks for the class - there’ll be more coming out of this I can tell
March 23rd, 2006 at 3:57 pm
Gave your code to my system manager just before coffee break. He has been interupted a bit and had lunch but he now has application contolling Keynote.
Apart from Play and Stop slideshow, next slide and last slide, I have suggested the down-arrow be used to pause (B key in keynote) and the the up-arrow be used to resume with move to next slide.
I expect he will have finished that in few well before tea break.
March 23rd, 2006 at 4:03 pm
Wow! That sounds cool! Great work!
In the next days I will release a first beta of an app with which it’s even easier to control applications. You just need to know a little bit of AppleScript to control an app.
There will also be a website to download/submit scripts to make it easy to share these things.
March 23rd, 2006 at 5:50 pm
Yep leeg has done it. And well before tea.
http://users.ox.ac.uk/~wadh1342/tarballs/KeynoteDriver.tgz
March 23rd, 2006 at 10:47 pm
Just tried it and it works great.
By the way. I have iWork 06 installed and it supports the Remote. But not the down/up-arrow=pause function
March 24th, 2006 at 9:55 am
That may just be that I pushed the wrong version up to the webserver; I’ll have a check; the binary in the tgz ought to work though (I’m on iMac G5, iWork ‘06 too). BTW there’s no AppleScript interface for “fade through black” so I just used “pause slideshow” which returns you to the desktop :-/
March 25th, 2006 at 9:06 pm
Oh - that was my failure. I wanted to say that iWork 06 supports the remote out of the box without any hack necessary for Keynote.
Your program works wonderful and it demonstrates that the default behavior (which is provided by FrontRow/iWork) could be easily changed/overwritten. Great job.
March 29th, 2006 at 9:51 am
I assume you mean it works with MBP or even perhaps on Intel iMac but iWork 06 does not support the remote out of the box on the PPC iMac.
On March 22nd the day before this thread began, my wireless remote arrived. Still it will be useful on the PB.
March 30th, 2006 at 7:06 am
You are right. I tried that on a MBP. That’s interesting. That would mean that the Intel Frontrow has more functionality than the PowerPC one (or the added the feature explicitly for the MBP only)
April 3rd, 2006 at 1:54 pm
Very impressive, Martin. Very impressiv.
April 17th, 2006 at 9:32 pm
How do you link a button on the remote to a button in the program. I do not usually do alternative inputs in my code, so I cannot find out how to link to anything other than the “startListening,” and “stopListining” actions. Thanks in advance.
April 18th, 2006 at 8:37 am
There is no way to link a button of the remote to the button of your app. You have to implement the delegate method “appleRemoteButton:pressedDown” and set the instance with the method “setDelegate” on the AppleRemote instance.
In order to “simulate” a press on a button in the program you can use the method performSelectorOnMainThread:withObject:waitUntilDone.
This method has to be called on the controller instance to which the button of the interface is binded.
April 28th, 2006 at 11:20 am
Hi Martin,
I found your source code on cocoadev-wiki and I am impressed. Especially, because I was looking for exact that kind of code.
I am the developer of iRed (www.filewell.com/iRed), a software to be used with the USB- or LAN module IRTrans (www.irtrans.com). With iRed you may control your Mac by Infrared, as well as control your HiFi/Video/etc devices by IR.
However, you need the IRTrans to really make iRed useful until now. Entering “The IR Port”! Using your source code I will enhance iRed to be controllable by Apple Remote without further hardware needed. iRed supports calling AppleScripts based on incoming “triggers”, so nearly everything is possible. I’ve just released a “keystroke action”, which makes it very simple to send a keystroke to a specific application or to the current one.
I am optimistic to get a first version with IR port support out in some days. I’ll keep this blog in touch with my progress.
Well, one question remains: how to get the ID of the sending Apple Remote? Any hints?
Thank you so much for your source code - you’ve deserved a free license for sure
April 28th, 2006 at 12:00 pm
Thanks a lot in advance for any credits
I’m planning an update to the source in the next couple of days. I’ll try some things to find out the remote id.
I will also start to manage a list of links to products, free tools, … that are providing support for the Apple Remote. If you have written such an app or know of such apps please drop me a line (as a comment or by mail).
May 1st, 2006 at 7:24 am
Hi Martin! I released new version of my movie player - Movie Time with support for Apple Remote: http://www.sansworks.com/beta.html . Thank you very much for the hard work and for releasing sources for free!
May 1st, 2006 at 5:18 pm
Congratulations for your new release and thanks a lot for the credits. I’ll put your link on the new forthcoming download page.
An updated version of the source code is in the final testing phase and out really soon.
May 6th, 2006 at 6:01 pm
I am not a programmer, but is there a way to make this work with PowerPoint?
That would be a great demo for my boss who has a PC…
May 7th, 2006 at 7:58 pm
You are just a couple of days away to impress your boss.:-)
Stay tuned. A first beta of an app to do that is in the line and will be out next week.