This howto is pretty lethal! In this article I’ll show you how to set up your remote control in Kodi and how to assign every single key according to your preferences.

Changing the language just using a single keypress during a movie or show/ hide subtitles is not an elaborate process anymore. This, and many other functions you’ll be able to control after you finished this howto.
🙂

In case you never installed an IR-Receiver on Raspberry Pi 2, you can find my first article here:

lirc_gpio_raspberry_pi_2_white_case_stormtrooper_design_arrow

Using every IR-Remote with Raspberry Pi 2 with this cheap and easy solution – Part 1


This Howto is based on working in Kodi. Therefore I can’t assure you it will work with other operating systems as well.

Also for this test, i took my favourite Xbox One Media Remote. In case you’re looking for a very good remote, this will be one of the best choices. 🙂

This Howto may be a little complicated for beginners, but I’ll try to explain every step detailed as possible, so everybody should be able to get it done.

As always, as the base hardware I use the Raspberry Pi 2.

Ok, lets start, yeehaa.

 

1. Preparation

Whole setup will be done using the terminal. So you need to connect to the Rasberry using Putty again. In case you don’t know how to do it, I’ll explain it here again.

Download Putty from here:

Download: PuTTY

No installation required, just start putty.exe.

After you’ve started Putty, enter the IP Address of your Pi. You can find it in Kodi at OptionsSystem info.
Here you can see a screenshot.

So, just enter the IP Address in Putty and the terminal opens.

raspberry_ip_address_putty

Now login with username “root” and password “openelec“.

Notice: You won’t see any input when entering the password. Just keep typing it correctly and confirm with enter key.

login_openelec_root_password

If everything worked, you should be logged in and see a Input prompt. You can start to input commands now. 😉

 

2. Activate Lirc module

Lirc (Linux Infrared Remote Control) is a program, which converts infrared signals into program commands.

First you need to activate this module on your Raspberry Pi 2. To do this , just add the entry “dtoverlay=lirc-rpi” in your config.txt.

To do this in the terminal, you need to enter following commands:

mount -o remount,rw /flash

With this command you’ll be able to access the partition, where the config.txt is located.

Next open the config.txt and add the entry “dtoverlay=lirc-rpi” at the end of it (navigate to the bottom using the arrow keys).

nano /flash/config.txt

putty_config.txt_bearbeiten

After you made the entry, just press CTRL+O to save the file and exit the editor with CTRL+X

Following this reboot the Pi (with command “reboot” or just pull the power plug) for the changes to take effect, and then reconnect using putty to continue.

 

3. Record buttons

Now you need to record all buttons.

First, stop the active Lirc process to use the record function. To do that , enter following command in the terminal and confirm with enter key:

killall lircd

Now you can start the recording. With the following command the process will be started and creates a lircd.conf which includes all parameters after the recording:

irrecord /storage/.config/lircd.conf

After you entered this, a wizard starts and guides you thorough every ste to record all your buttons.

You can confirm the first dialogue with the enter key.

In the next dialogue the step by step instruction starts. You’ll get instructions before every step.

At first Lirc needs to identify the frequency range. To do so, you’ll need to press as many buttons as possible, just randomly pressed, without any order till Lirc has collected enough information.

irrecord_dialog_3

You’ll see a interim announcement where you can see your frequency. Now you need to continue to press random buttons.

After that is finished, the button assignment begins.

The process is the same all the time, first you have to name the Button, and then press and hold it on your remote until it gets recognized.

Take care while naming the buttons. The name has to begin with “KEY_“.
I created a list with names, which are allowed here.
Basically it’s just important that every button has a name at the end. You can assign the function later as you like to. But it’s better to assign names that match with the function.

irrecord_dialog_5

After every button is named , confirm with enter and you’re done with creating the lircd.conf file.

This file is located in the configfiles folder.

That’s how the file looks like after the recording with Xbox remote control: lircd.conf

In case you assigned a Key name wrong or not optimally, you can make corrections afterwards, just stick to the allowed names.

If you own the same Xbox One remote, you can use my config file and skip the recognition. 🙂

Just to be safe reboot your Pi so that the Lirc process starts and uses the new created lircd.conf.

Short function test

You can test if it works using following command in the terminal:

irw

When you press some buttons on your remote control now, you should see the names of pressed buttons show up in the terminal. With CTRL+C you can exit this mode again.

 

4. Connect Lirc with Kodi

Now that every button has an assigned name, but Kodi can’t make use of that yet. The link between Lirc and Kodi is the Lircmap.xml file.

This file converts the buttons of your remote with functions in Kodi.

it has to be created and put into the Userdata folder by yourself.

You can access it easily by enter your Raspberries IP at the Windows Explorer Address bar in following notation: –> \\192.168.1.111\

If you enter the IP Address without the backslash, it will open in your internet browser. 😉

screenshot_lircmap.xml_raspberry_netzwerk

That’s how the completed Lircmap.xml of my Xbox One remote looks like: Lircmap.xml (Right click — Save Target As…)

In case you’re not using a proper text editor, I highly recommend to use Notepad++ oder Sublime Text 3 to edit xml files like this.

If you don’t create a Lircmap.xml file, Kodi will use a global Lircmap.xml.
In case you names your buttons correctly , your remote will also work somehow, already.

To get full control , better create the file with proper entries and put it into the Userdata folder.

Here you can see my finished file for use with my Xbox One remote:

lircmal.xml_xbox_remote

You have to assign all of your buttons. I listed all possible functions on this site.

Every remote has it’s special keys. For example, I assigned the button “KEY_LIST” to the function “star“. With that, later, the “Favourite Menu” appears when you press that key. It won’t work now, but we’ll assign “star” to this function later.

After you assigned some functions already, just reboot your Pi and some functions should work already now.

 

5. Make individual adjustments

Let’s do some finetuning. As I already wrote above, I wanted to open the favourites menu when pressing the key “KEY_LIST“, which directs to the function “star” in my Lircmap.xml.

For adjustments like this, you’ll need another file called remote.xml. It has to be putted here: Userdata → keymaps

On this Kodi-Wiki you can lookup the command for opening the favourite menu and change the function of “star”.

The finished remote.xml with this adjustment looks like this after you’re done:

remote.xml_beispiel

I made several adjustments for my remote. My final remote.xml looks like this:

meine_remote.xml

Here is a download link: remote.xml (Right click — Save Target As…)

You can see 3 different regions: global, FullscreenVideo and Home.

Everything in <global> will be executed, no matter in which state Kodi is at the moment.

Everything in <FullscreenVideo> will only be executed while a movie runs in fullscreen mode.

Everything in <Home> will only be executed while you’re in the main menu of Kodi

If you need further information about the structures, you can read about it here.

With this option you can assign multiple uses to just one button, depending on the state of Kodi. As an example, I assigned the “pageminus” button like this. If you press it, youll get into the Main menu. But if a video runs, you’ll change the subtitle track, from german to english etc…

I assigned the powerkey to the screenshot function to make screenshots in Kodi whenever I like. Very convenient for my Blog. 😉

Now you should be able to assign every button according to your wishes. If you have questions or problems, feel free to make a comment.