Getting the Media Center Remote working

XBMC was supposed to work out of the box with the Media Center Remote, but for me it never did. Apparently this is because in linux kernel 2.6.something they merged some of those drivers into the kernel, X started handling them, and stuff like that.

To get it working, I had to take the following steps, most of which came from or were based on a thread on the XBMC forum.

Normally the up/down keys seem to work, but that’s only because X11 is treating the remote as keyboard input and is channelling the arrow keys properly whereas the other keys are a mystery to XBMC. Although it would be possible to bind all the other keys manually, I’d rather use XBMC’s normal way of doing this, namely through lirc. So the first step is to get X11 to *not* do anything with the remote input.

To prevent X11 from handling the remote input, add the following lines to /etc/X11/xorg.conf:

Section “InputClass”
Identifier “Remote”
MatchProduct “Media Center Ed. eHome Infrared Remote Transceiver”
Option “Ignore” “True”
EndSection

Then we need to get lirc up and running, so first let’s install it:

apt-get install lirc

Next we need to tell lirc what device the remote is on, seeing as the new kernel driver doesn’t use the normal /dev/lirc but /dev/lirc0. Edit /etc/lirc/hardware.conf and change the following three lines (just find the line where everything before the = is the same)

DRIVER=”default”

DEVICE=”/dev/lirc0″

Then we need to load the mceusb config file shipped with lirc:

cp /usr/share/lirc/remotes/mceusb/lircd.conf.example /etc/lirc/lircd.conf

At this point you should restart lirc with:

/init.d/lirc restart

And then try running

irw

and pressing some keys on the remote. It should give some output. Note that the ^]B like output is output generated by the kernel for the arrow keys. Try the big “OK” button to be sure, I’m fairly certain that the kernel doesn’t map that one. Ctrl+c out of this when you’re ready testing.

Finally, XBMC expects the MCE driver to give slightly different output. To fix this, we should print or open on another computer the file/etc/lirc/lircd.conf and open /usr/share/xbmc/system/Lircmap.xml. Then for each item in the <remote device=”mceusb”> section, change the middle bit to something from the lircd.conf file. For example:

<play>Play</play>

should become

<play>KEY_PLAY</play>

After you’ve changed all those and restarted X and XBMC, it should be working.

Finally because I wanted the box to sleep when pressing power instead of shutting down completely, I opened /usr/share/xbmc/system/keymaps/remote.xml and changed the line:

<power>XBMC.ShutDown()</power>

to

<power>XBMC.Sleep()</power>

Now I had actually thought to be done by now, but after a few tries it seems the computer randomly shut down sometimes. This was caused by the new kernel drivers also passing all keypresses to the input subsystem, and the input system deciding that KEY_POWER really meant KEY_POWER. To fix this, add the following line to /etc/rc.local, preferably at the start.

echo none +lirc > /sys/class/rc/rc0/protocols

This will tell the kernel to not attempt to decode the IR signal using any protocols, but instead only send it on to LIRC.

Leave a Reply

Your email address will not be published. Required fields are marked *