21 Aug 2020 - The wiki is undergoing a major cleanup. If you arrived here from a search engine and cannot find the page, please use the wiki search instead (top right corner of page)
More info can be found on the forum

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

From Official Kodi Wiki
Jump to: navigation, search

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.

1 Install the remote

1.1 Simple Installation method with Lircd

The easiest way is to use the lircd daemon shipped with lirc package. Most likely you will also want lirc-compat-remotes which are put in /usr/share/lirc/remotes.

In terminal, use the following command:

apt-get install -y lirc lirc-compat-remotes

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 irw 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

1.2 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.

  • It is important to disable lircd daemon from lirc package, On ubuntu launch the lirc reconfiguration process with :
dpkg-reconfigure lirc

Then choose twice none for receiver and transmitter.

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

  • Install now inputlirc :
sudo apt-get install inputlirc
  • Before proceeding we need to know the eventX number corresponding to our remote :
cat /proc/bus/input/devices

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
  • 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 :
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':
looking at parent device '/devices/pnp0/00:09/rc/rc0/input4':
ATTRS{name}=="Nuvoton w836x7hg Infrared Remote Transceiver"
looking at parent device '/devices/pnp0/00:09/rc/rc0':
ATTRS{protocols}=="rc-5 nec [rc-6] jvc sony mce_kbd lirc"
looking at parent device '/devices/pnp0/00:09':
looking at parent device '/devices/pnp0':
  • One can now create a permanent symbolic link to our eventX device by creating a custom udev rule :
echo 'KERNEL=="event*",ATTRS{id}=="NTN0530",SYMLINK="input/myremote"' > /etc/udev/rules.d/10-persistent-ir.rules

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

  • Configure inputlirc by editing /etc/default/inputlirc like this :
OPTIONS="-g -m 0 -c"
  • Restart inputlirc
/etc/init.d/inputlirc stop
/etc/init.d/inputlirc start
  • Copy the LircMap configuration file into the personal directory
cp /usr/share/xbmc/system/Lircmap.xml ~/.xbmc/userdata/Lircmap.xml
  • Edit the linux-input-layer remote section to add the remote link name, one should have something like this :
<remote device="linux-input-layer">
  • Launch xbmc and test the working remote

Based on : [1]

2 Configure the remote buttons

2.1 Edit the driver table

If you are using inputlirc or lircd with the Linux input layer (/dev/input/eventX) 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
  • First install the ir-keytable package
apt-get install ir-keytable
  • Stop or kill any lirc daemon (inputlircd or lircd)
pkill lirc
  • Launch ir-keytable in test mode for the remote and read the scancode sent by pressing the buttons :
ir-keytable  -t --device=/dev/input/myremote

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
  • Dump the driver table into /etc/lirc/myirtable.cfg
ir-keytable -r --device=/dev/input/myremote  > /etc/lirc/myirtable.cfg
  • Analyse the table file and grep the line corresponding to KEY_TITLE, KEY_SUBTITLE and KEY_SELECT
scancode 0x800f044d = KEY_TITLE (0x171)
scancode 0x800f045a = KEY_SUBTITLE (0x172)

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 : [2]

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

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.
  • Clear the driver table and update it with the table file :
ir-keytable -c --device=/dev/input/myremote
ir-keytable  --device=/dev/input/myremote --write=/etc/lirc/myirtable.cfg 
Wrote 63 keycode(s) to driver
  • 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

2.2 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




A complete guide is available here : LIRC

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