07
Oct
13

Fun with the Apple IR Remote, Part 1: Making it work

This article, by and large, is for Mac owners, as it describes the Apple infra-red (IR) remote control system that’s been used on and off in Apple machines for about 7 or 8 years.  There is an article here which describes the remote being used on a Windows PC, and here on a Mac running Windows, but I imagine these are not common usages for this system.

In fact, I don’t believe the Apple IR system is well known at all amongst Mac users, and I hope this study will show that it can be more useful to music makers than was previously thought.

*

From about 2005, Apple began adding an infra-red remote capability to their machines, which came with an attractive little remote control like this:

Remote IMG_1519

It’s not clear from the picture, but if you haven’t seen one, it’s quite tiny – about 8cm by 3cm.  I’ll be returning to that point in Part 2.

The IR system began with the iMac G5 and quickly spread to the white Macbook, Macbook Pro and Mac Mini.  A slightly larger silver aluminium version of the remote came out in 2009, but also in that year Macbooks stopped being made with IR capability.  It remained as an option on the Macbook Pro, but the remote itself wasn’t being bundled with the laptop.

This is the silver remote.  Note that the ‘Play’ button has been moved from inside the ‘+’, ‘-‘, ‘Left’ and ‘Right’ buttons, and placed separately, to the right of the ‘Menu’ button.

Aluminium remote2 MC377

At the time of writing, the Mac Pro and Mac Mini seem to have built-in IR capability.  It’s difficult to keep track of what does what, however, as newer models of computer seem to be dropping this feature and users are being encouraged to use an iPhone app which does a similar job; but if it has one of these on the front:

IR Sensor IMG_1521

then it’s got IR built in.  The one area where the control seems to have remained popular is with the Apple TV/Home Theatre users.  There was an application called Front Row, which used the remote to control films and music, but I don’t believe this has been in use since OS 10.7.

All of this is a shame, as the ability to control your computer wirelessly can often come in handy, and several companies produce excellent software which greatly expands the ability of the Apple remote to control pretty well any application in any way you want.

Of course, if you have a Mac, then you very likely have the luxury of Bluetooth as well, and I have blogged, or will be blogging, about various uses of Bluetooth.  However, it could be that your Bluetooth system is fully occupied with, say, your wii controller, and this extra way of passing information to your computer becomes a vital necessity.

Although most of the following is based on my experience with my MacBook, which has IR built in, I’ll be speaking about things one might do to add IR capability to a non-IR Mac.

*

First of all, then, the controller and getting it to work:

There are three things to do to make sure your IR remote is potentially going to work.  The first is to ensure that the battery is OK; the second is to confirm that the infra-red LED is lighting up; and the third is to make sure the computer’s IR capability is turned on.

The remotes are powered by a CR2032 coin battery.  Apple designers, as we know, live in a world where bent paperclips are always to hand, so with the white remote – like the method of ejecting stuck CDs – there’s an indentation in the bottom of the case which can be poked with a bent paperclip to eject the battery tray.  In this case it isn’t inside a small hole, so a pen, pencil, or a 3.5mm headphone plug will also work perfectly well.

As illustrated, the silver remote has a different method: a battery compartment which is opened by twisting a small coin in it.

Battery change2

As for checking that the remote is functioning, the essential problem with this is that the light it gives off is infra-red, and therefore you can’t actually see it.

Fortunately, though, cameras can!  So if you have a laptop with a camera at the top here:

Camera IMG_1523

all you have to do it open something like iChat, go to Video > Video Preview and film yourself pointing the remote at the camera and pressing buttons.  If you can see a light like this:

Battery test

then the unit is working.

Finally, you just have to make sure the IR capability isn’t turned off.  Do this by opening System Preferences > Security, and look for this:

Security preferences2

Make sure the box isn’t checked and it says ‘The computer will work with any available remote’.

While on this subject, it’s worth noting that this might not be the situation you want.  If you’re in an environment where there are several remotes in use, you might want  your machine to respond only to yours.  Under these circumstances, the ability to ‘pair’ your remote and computer might be very useful.  Clicking this button:

Pair3

will enable you to do that (provided you’re logged in as an Administrator).

When you click it, it tells you how to do the pairing:

Pair2

Rather like a wii controller, you point the remote at the computer (but in this case it must be from just 3 or 4 inches away) and press the ‘Menu’ and ‘Next’ (‘Right’) button at the same time.  After a few moments (maybe 5 seconds), the following large icon will appear on the screen, with the ‘link’ sign flashing:

Pair icon IMG_1523

The remote and the computer are now paired; the ‘Pair’ button changes to an ‘Unpair’ button, and the text now says ‘This computer will work with only the paired remote’.

The process of unpairing them is simply a case of clicking that button:

Unpair2

Using the remote itself, you can unpair it by pressing ‘Menu and ‘Left’ at the same time, for about 5 seconds.

According to Apple, the remote works up to 9 meters (30 feet) from the receiver.  Unlike Bluetooth, of course, we’re talking about light here, so there can’t be anything in between the remote and the receiver that would block the signal – although you might be lucky and able to bounce the signal off a wall on on its way to the receiver.

*

So, now the remote is working, what can you do?

The answer is, not a lot.  You can use Front Row to watch films or listen to music, unless you have a modern operating system, 10.7 or later; you can remotely control iTunes, or you can make your computer go to sleep and wake up.  Not very practical for making music, which is, after all, what this blog is about.

[Edit: since writing the above, I’ve installed OS 10.6 and a newer version of the program VLC, from Videolan, an excellent free audio, but predominantly video, file player.  Some of VLC’s functions can be controlled with the Apple Remote, which is handy.  I don’t know if this can be done with earlier versions of Mac OS].

So, an important part of making the remote work would be to find some suitable software to interpret the input.

The first thing I looked into when I got my remote out of the cupboard and got it working was whether it would work with PureData (Pd).  Many types of HID (Human Interface Device) will act as musical instruments or effects devices – as I have described in the blog before – and so can the Apple IR Remote, although only to a limited extent.

I used a generic ‘HID Tester’ patch which I had created for investigating different devices, and determined first of all that the IR system was recognised by Pd – in this instance as Device 0:

Pd device no

I activated Device 0 and pressed all the buttons in turn, but this is all I got:

print desktop2

So unfortunately Pd was only able to recognise two of the buttons on the IR Remote, ‘+’ and ‘-‘.

*

This was of limited value, so I needed to see if there was any software which could expand the usefulness of the device.

Luckily, there was.  There are several programs, in fact, which can greatly extend the range of control  the Remote can give you.

Andreas Hegenberg’s BetterTouch Tool (BTT) has a section for the Apple Remote, although is generally more aimed at the Magic Mouse and trackpad

bettertouch2

Nowadays, in fact, Andreas seems to be concentrating on the amazing Leap Motion Controller, which is going to deserve its own blog page one of these days.

I wasn’t able to test out the BetterTouch Tool: it’s free, so there’d be no problem for you downloading it (from here, for example) and trying it out, but only supports OS 10.7.  There might be a legacy version still available for 10.6, but I couldn’t find one for 10.5, which I’m still using.

I did find a screencap, though, which shows that button presses are known as ‘Gestures’.  This is an example of the window in which button presses are assigned different actions:

BTT Gesture setting

*

Mira is a dedicated Apple Remote app which, when installed, is controlled from System Preferences.  The opening view shows the remote buttons in the centre: you click on each button to assign a function to it, which may be a keystroke, system action, or instruction open a program (including AppleScripts).

mira windows

Mira supports short presses and long presses, effectively doubling the number of actions available from the 6 buttons, and provides a number of combinations of short press/long press combinations.  A comprehensive Help menu is available by clicking the ‘?’ button in the bottom right-hand corner of the Mira window.

Duo Press_Help

Mira is available from Twisted Melon in versions for OS 10.4+ and 10.5+.  Also available, for the deprived Mac with no IR receiver, they offer the Manta TR1 plug-in USB IR receiver.  At the time of writing Mira costs $15.95 (Canadian) for single licence and $29.99 for 3 licences; the Manta TR1 costs $19.99; and a bundle of 1 Mira licence and a Manta costs $29.99.

*

Remote Buddy looked particularly promising as it also offered control of wide array of remotes, not just the Apple remote, but other makes from the likes of Griffin and Sony, iPhone and iPod Touch, and even Nintendo wiimotes.  OS 10.4.6 and above are supported.

Remote Buddy also installed its driver, Candelair (also available as a free stand-alone).

Configuring the remote’s buttons consists of specifying an application – although ‘Default’ and ‘Virtual Remote’ options are available – and defining a group of actions called ‘behaviours’.

Picture 2_2

There are appropriate suggestions for each application, and you can create your own Custom actions.  Like Mira, Remote Buddy supports short and long button presses and allows the same kinds of action choices; Help is available from the Remote Buddy menu.  It costs €19.99.

As a matter of fact, once I had installed Remote Buddy/Candelair, the following entries showed up in PureData:

Pd Remote Buddy_Candelair Devices2

Opening these device numbers, I was able to see two more actions displayed:

Pd long press l & r2

However, I wasn’t able to use these with the [Route] object, as one normally would.

Even if you don’t use Remote Buddy, I’d recommend installing Candelair, as I’ve encountered a number of instances like this where the presence of this alternative driver allows you to do things that can’t be done otherwise.  It can be controlled – even uninstalled – in System Preferences:

Candelair Screens

*

Undoubtedly, the be-all-and-end-all of infrared applications is iRed.  Designed to work with the iTrans infrared module – which transmits as well as receives  – this system can, in a nutshell, allow you to control your computer with any infrared control and allow your computer to control any device with an infrared receiver.

Possibly slightly extravagant for present purposes – and it doesn’t work with the standard Apple IR receiver, of course (which doesn’t transmit).  However, iRed Lite is much more the sort of thing I’m considering here.

In fact, for several reasons, this is the one I chose to use, partly because it’s free, partly because I liked the flexible onscreen display window, partly because it recognises short presses, long presses and double presses.

When opened, all that appears is an icon in the menu bar.  Clicking on this icon brings up a choice of actions, including opening the Onscreen Display or the Editor window.  This view of the Editor windows shows some of the important features:

Edit window

1.  This panel replicates the Onscreen Display.  The buttons are laid out here in the same format as the buttons on the remote.  The ‘extra’ button at the end of each row is for the ‘double-click’ action.

2.  This section, when the ‘Button’ tab is selected, allows for changing the style of the buttons.

3.  In this section the action performed by the button can be changed.

4.  This drop-down menu, as the name suggests, allows the settings for different Layers to be displayed.  A Layer is a collection of actions, usually applying to the same application.  When a Layer is active, the actions described in that layer are the ones which will be performed when the remote buttons are pressed.

5.  This drop-down menu gives access to more functions, such as remove selected button, create or remove a Layer and open the Character Palette for access to special characters and symbols.

6.  Clicking this arrow reveals or hides the sections on the right-hand side of  the picture in which more complex actions can be specified.

7.  Clicking on the ‘Add Action’ button allows actions to be specified which replicate keystrokes or mouse movements; a third possibility is to run an AppleScript.

8.  The special action is chosen in this area.  The picture shows a simple AppleScript to initiate an iTunes function.

Actions can be dragged and dropped onto the buttons in the panel on the left and different patterns of buttons can be created for ease of understanding or to match modified remotes.

*

Modified remotes is the subject of Part 2 of this series of posts, but before we leave the topic of software, I must just mention a small command-line app which runs from the Terminal.  I haven’t yet worked out if this is potentially useful or not yet, but it’s called iremoted and ‘listens for button-press events and prints the identifier (the HID element cookie, to be precise) of the button in question’.

A description of the program can be found here, together with the source code in a file called iremoted.c.  Its GitHub entry is here.  I compiled it from the Terminal by typing the recommended instruction ‘gcc -o iremoted iremoted.c -framework IOKit -framework Carbon’.

When I ran it, sure enough it showed me the HID element of the code sent by each button press, like this:iremoted Terminal window2

It’s interesting that ‘+’ and ‘-‘ were the only two buttons that showed an entry when pressed before another entry when released.  Whether this has anything to do with the fact that they were the only two buttons to show up in PureData, I don’t know.

The above isn’t the only information passed via the infra-red link when a button is pressed.  I’ve read numerous articles on the subject which, frankly, I don’t understand – they either don’t say the same thing, or they say the same thing in a different way . . . suffice it to say that 4 different pieces of information are transmitted each time a button is pressed, according to the NEC Infrared Transmission protocol, which Apple remotes use (in a slightly non-standard way): the first two are purely Apple’s own ID, the third is the instruction code, as above, and the fourth is the remote’s individual ID.

*

The individual remote ID is the final thing I want to deal with in this post – which I ought to do, as I glossed over it rather surreptitiously when talking about ‘pairing’ earlier on.

When you pair a remote with your computer, you’re not pairing just any remote in the vicinity: you’re pairing a particular remote; and the way the computer knows which particular remote is being paired is because of its individual ID, which is a number from 0 to 255.  This isn’t fixed: it can be changed, although not to a number of your choice.

The advantage of pairing a remote is that you can – as  in my earlier example – ensure, in an environment in which several remotes might be in use, that your computer responds only to your remote.  If by some chance you find yourself in a situation in which there are two remotes with the same number, you can change the number and re-pair it.  To change the number, all you do is press ‘Menu’ and ‘Play’ (the centre button) at the same time, and the number will increment.

I have read that the remote will attempt to pair when you do this, so if you don’t want to pair at the same time, do this outside the distance from the computer (3 or 4 inches) which is required for pairing to work.

So, pairing can be useful.  But what might be even more useful is not to pair a remote with your computer, but to allow the computer to recognise individual remotes by their IDs and have them do different things.  Programs like Remote Buddy do this, as the following screen shots show:

Multiple Remotes

Checking the box ‘Enable support for multiple remotes’ – indicated by the arrow at the top – brings up the list beneath.

In the right-hand column, remotes are distinguished by their ID number, not paired, but associated with different ‘behaviour’ groups.

*

In the iRed Lite Editor window, clicking on the ‘Layer’ tab brings up a number of parameters that can be altered, one of which is the ID of the remote which will control this layer.  The actions described will not be performed by another remote with a different ID.

iRed Layer window2

This raises the possibility of using a number of separate remotes for entirely separate purposes, using modified remotes with multiple ‘personalities’, or teaching a universal remote with a learning capability to mimic remotes with different IDs.  This article: http://funwithcomputers.wordpress.com/2008/03/01/using-the-harmony-880-remote-with-your-macs-built-in-ir-port/ describes a project to teach a Logitech Harmony 880 to imitate 8 Apple remotes via Remote Buddy.  In this way 48 different buttons were created (could have been 96, but long presses were not configured) and all manner of things could be controlled in a home theatre set-up.

At some point, you might want to check the ID Number of your remote.  If you’ve only got one, chances are its number will pop up everywhere.  If you have more than one, someone else uses one in the vicinity of your computer, or you haven’t really used it before, here are two ways to find out what it is.

The first thing to say is that isn’t always quite as easy as it might be, as only ID number changes seem to be registered.  If you have more than one remote, it’s less of a problem – every time you use a different remote there’s a number change; if you have only remote, the following needs to be done the first time you use your remote after booting up the computer:

Open iRedLite and select ‘Preferences’ from its drop-down menu, and then ‘Apple Remote IDs’.  It will probably show ‘0’ as the current ID number.  Press a button on your remote, and it will display the remote’s ID number, as below.  If you have more than one remote, you can check the numbers here at any time, as the change from one ID number to another will be registered (although once I was fairly sure I wouldn’t be incrementing the IDs any more I wrote the numbers on the back of each remote!)

Apple Remote ID No window2

Another useful program you could use for this purpose is Joystick and Gamepad Tester.  I’ve blogged about this at greater length elsewhere, but since the Apple infrared receiver is part of the USB system, it will be picked up by this program, which is designed to identify buttons and other controls on USB devices (such as joysticks and gamepads).
In my experience, this only worked after I’d installed Candelair, as recommended above.
I open Joystick and Gamepad Tester and click ‘Ok’:
JAGT 1
I can then choose from a drop-down list.  Instead of choosing ‘IR Receiver’, which normally shows nothing, I choose ‘IOSPIRIT IR Receiver Emulation’:
JAGT IOSPIRIT

A list of buttons and functions appears, the last being the Remote ID number.  Pressing a button on the remote shows the current ID number in the ‘Now’ column.  Any button will do, as the device’s ID number is transmitted as part of every message.  Don’t take any notice of the ‘Min’ and ‘Max’ columns, as they just show other device ID numbers that may have been used before.

JAGT ID No

*

Some of the above could only legitimately be described as ‘fun’ by those of us with a rather esoteric definition of the word.  In Part 2 I’ll progress closer to using the IR remote for modification and music-making purposes.

Advertisements

8 Responses to “Fun with the Apple IR Remote, Part 1: Making it work”


  1. 1 juan
    February 23, 2014 at 10:44 pm

    Hi.
    Excellent article, written from a hacker pov (and it’s so hard to find info about hacking apple hardware, given the closed policy they put on everything they make).
    Only one question: is there a way to make the remote operate two buttons simultaneously? My idea is to use combinations of buttons on the remote (i.e. Menu AND -) to get more combinations without the need to hold for long time (or double press a button).
    Thanks!

    • February 28, 2014 at 9:34 am

      Juan,

      It would certainly be possible, if using the PCB from the Apple remote inside another unit, as I did, to wire up the new buttons to operate two or more of the Apple remote buttons. The problem would be what coded signal would be sent out by the unit, and how this would be interpreted. I assume there’s a limited number of possible signals that can be sent out by the unit, and a limited number of possible signals which are interpreted by the software available; and that these limited numbers are all used by the short press, long press and double press options. However, I don’t know this for sure.

      One possible, although somewhat more complicated, solution would be to incorporate some circuitry – perhaps using 555 timers – which would translate a single short press into a long or double press, so that all functions are accessed by single button presses.

      Andy

  2. 3 Adam
    December 20, 2015 at 7:16 pm

    PLEX Home Theater works extremely well with the Apple IR Remote.

  3. May 1, 2016 at 4:10 pm

    Thanks for the informative page, specially the infrared tip.

    • September 25, 2016 at 7:12 pm

      The eBay link is no longer valid, but the device itself is still available from SmartGUS. While somewhat less fun than my version, it’s much less work, being a very small infrared receiver with integral USB plug. It costs about £20.

  4. 7 gus
    September 26, 2016 at 12:26 pm

    About 20 € ! Thanks for your comment.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


andymurkin

October 2013
M T W T F S S
« Sep   Nov »
 123456
78910111213
14151617181920
21222324252627
28293031  

Enter your email address to follow this blog and receive notifications of new posts by email.


%d bloggers like this: