HOW-TO:Set up an MCE remote control in Linux

This guide will help to configure an MCE Remote on a linux HTPC, even if all the commands are specific to Ubuntu, the main steps are the same on any modern linux distribution.

MCE remotes are IR remotes that split into two main categories:
 * MCE remotes that send keystrokes
 * Windows remotes also known as RC6 or eHome remotes

Most remotes work out of the box through the kernel input event subsystem. However they are often unusable in this state due to laggy/buggy behavior. On Linux it is often easier to use the Lirc package.

Simple Installation method with Lircd
The easiest way is to use the lircd daemon shipped with lirc package.

In terminal, use the following command: apt-get install -y lirc

After the installation a configuration dialog will appear on Ubuntu. Choose the correct values corresponding to your receiver (and eventually transmitter)

you can now test if the correct value are send by the remote buttons by using the  command tool and then launch XBMC and check if the main button are responding correctly.

You can always reconfigure the lirc package with the dpkg-reconfigure command: dpkg-reconfigure lirc

If the remote don't work it is always a good idea to reconfigure lirc package by choosing one of those 2 generic value for the receiver option :
 * Windows Media Center Transceivers/Remotes (all)
 * Linux input layer (/dev/input/eventX)

a more complete guide is available here : HOW-TO: Setup Lirc

Alternative Installation method using InputLirc
In some cases the simple method will work in a buggy way (keys pressed twice, key burst, laggy key, ... ). If this is the case or you want deeper control over the configuration then use inputlirc. Inputlirc is a small LIRC-compatible daemon that reads from /dev/input/eventX devices and sends the received keycodes to connecting LIRC clients.

dpkg-reconfigure lirc Then choose twice none for receiver and transmitter.
 * It is important to disable lircd daemon from lirc package, On ubuntu launch the lirc reconfiguration process with :

Make sure that lircd is not running. The START_LIRCD parameter should be now set to false in /etc/lirc/hardware.conf configuration file.

sudo apt-get install inputlirc
 * Install now inputlirc :

cat /proc/bus/input/devices
 * Before proceeding we need to know the eventX number corresponding to our remote :

For instance on my xtreamer ultra V1, the nuvoton receiver remote correspond to event4 cI: Bus=0019 Vendor=1050 Product=00c3 Version=0033 N: Name="Nuvoton w836x7hg Infrared Remote Transceiver" P: Phys=nuvoton/cir0 S: Sysfs=/devices/pnp0/00:09/rc/rc0/input4 U: Uniq= H: Handlers=kbd event4 ...

udevadm info -a -p $(udevadm info -q path -n /dev/input/event4) For the nuvoton, the ATTRS(id) will be used from the following output looking at device '/devices/pnp0/00:09/rc/rc0/input4/event4': KERNEL=="event4" SUBSYSTEM=="input" DRIVER=="" looking at parent device '/devices/pnp0/00:09/rc/rc0/input4': KERNELS=="input4" SUBSYSTEMS=="input" DRIVERS=="" ATTRS{name}=="Nuvoton w836x7hg Infrared Remote Transceiver" ATTRS{phys}=="nuvoton/cir0" ATTRS{uniq}=="" ATTRS{properties}=="0" looking at parent device '/devices/pnp0/00:09/rc/rc0': KERNELS=="rc0" SUBSYSTEMS=="rc" DRIVERS=="" ATTRS{protocols}=="rc-5 nec [rc-6] jvc sony mce_kbd lirc" looking at parent device '/devices/pnp0/00:09': KERNELS=="00:09" SUBSYSTEMS=="pnp" DRIVERS=="nuvoton-cir" ATTRS{options}==" ATTRS{id}=="NTN0530" looking at parent device '/devices/pnp0': KERNELS=="pnp0" SUBSYSTEMS==" DRIVERS=="
 * As the eventX number may sometimes varry upon reboot, one need to know a unique id value corresponding to our remote to further create a udev rule :

echo 'KERNEL=="event*",ATTRS{id}=="NTN0530",SYMLINK="input/myremote"' > /etc/udev/rules.d/10-persistent-ir.rules
 * One can now create a permanent symbolic link to our eventX device by creating a custom udev rule :

Reload the udev configuration and trigger these changes : /etc/init.d/udev reload udevadm trigger Aternatively, reboot in order to apply the udev changes.

There should now be a symbolic link in /dev/input/myremote

EVENTS="/dev/input/myremote" OPTIONS="-g -m 0 -c"
 * Configure inputlirc by editing /etc/default/inputlirc like this :

/etc/init.d/inputlirc stop /etc/init.d/inputlirc start
 * Restart inputlirc

cp /usr/share/xbmc/system/Lircmap.xml ~/.xbmc/userdata/Lircmap.xml
 * Copy the LircMap configuration file into the personal directory

 cx23885_remote devinput /dev/input/myremote KEY_LEFT ...
 * Edit the linux-input-layer remote section to add the remote link name, one should have something like this :


 * Launch xbmc and test the working remote

Based on :

Edit the driver table
If you are using inputlirc or lircd with the  value for the receiver parameter, you can tweak the driver keycode/scancode table with the ir-keytable command line tool. In the following example one will make some changes on the driver table used by the nuvoton remote shipped with the Xtreamer Ultra V1. This example can be adapted to any remote.

By default, after using the inputlirc method on ubuntu 13.04, the subtitle, tilte and enter button are mapped like this for this remote on this HTPC : subtitle => KEY_TITLE title => no key code sent enter => no key code sent

One will change the driver table to map those 3 buttons like this : subtitle => KEY_SUBTITLE title => KEY_TITLE enter => KEY_SELECT

apt-get install ir-keytable
 * First install the ir-keytable package

pkill lirc
 * Stop or kill any lirc daemon (inputlircd or lircd)

ir-keytable -t --device=/dev/input/myremote
 * Launch ir-keytable in test mode for the remote and read the scancode sent by pressing the buttons :

The output looks like this : Testing events. Please, press CTRL-C to abort. 1378830829.479887: event MSC: scancode = 800f044d 1378830829.479887: event sync 1378830829.728814: event key up: KEY_TITLE (0x0171) 1378830829.728814: event sync 1378830833.290068: event MSC: scancode = 800f0451 ... 1379288588.428518: event MSC: scancode = 800f0437 1379288588.428518: event sync ...

By analyzing the ouput, one can determine the the button/scancode association : subtitle => 800f044d title => 800f0451 enter =>800f0437

ir-keytable -r --device=/dev/input/myremote > /etc/lirc/myirtable.cfg
 * Dump the driver table into /etc/lirc/myirtable.cfg

scancode 0x800f044d = KEY_TITLE (0x171) scancode 0x800f045a = KEY_SUBTITLE (0x172)
 * Analyse the table file and grep the line corresponding to KEY_TITLE, KEY_SUBTITLE and KEY_SELECT

As you can see, KEY_SELECT is not associated to any scancode, KEY_TITLE is associated to the subtitle button scancode and KEY_SUBTITLE is associate to a non existent scancode.


 * Before procedding, it is necessary to know the key hex value associated to KEY_SELECT

Those are located in the kernel source code in include/uapi/linux/input.h file. One can browse the source code here :


 * 1) define KEY_SELECT		0x161

subtitle => 800f044d => KEY_SUBTITLE (0x172) title => 800f0451 => KEY_TITLE (0x171) enter =>800f0437 => KEY_SELECT (0x161)
 * Edit the table file dumped before to have this button key association :

after modifying the KEY_TITLE,KEY_SUBTITLE lines and adding the KEY_SELECT line the edited part should look like this : scancode 0x800f044d = KEY_SUBTITLE (0x172) scancode 0x800f0451 = KEY_TITLE (0x171) scancode 0x800f0437 = KEY_SELECT (0x161)


 * Make sure with your favorite tool that there isn't two lines with the same scancode fot those buttons in the file and save it.

ir-keytable -c --device=/dev/input/myremote ir-keytable --device=/dev/input/myremote --write=/etc/lirc/myirtable.cfg Wrote 63 keycode(s) to driver
 * Clear the driver table and update it with the table file :


 * To make the changes persistent upon reboot add those 2 last command above to /etc/rc.local


 * One can now test if everything works correctly with ir-keytable test mode, then restart inputlirc or lircd and launch xbmc

Edit LircMap.xml and Keyboard.xml
First thing to do is to check the LircMap.xml located in ~/.xbmc/userdata/Lircmap.xml.

One can acquire the button key values with the help of irw and then edit this file to better suits our needs. This can even be mandatory sometimes.

For instance some remotes will send KEY_NUMERIC_1 instead of KEY_1 for the numeric pad. It is then necessary to edit the file at the correponding remote section from KEY_1 to KEY_NUMERIC_1

A complete guide is available here : Userdata/lircmap.xml

For further tweaking it is necessary to edit the Keyboard.xml file. A complete guide is available here : Keymap