Adding a Remote to OpenElec XBMC KODIby Dylan - first posted February 16, 2015
I have the old silver AppleTV 1 with only 250 megs of ram. OpenElec has been a dream and breathed new life into the outdated device. I recently purchased the amazing CuBox-i4Pro from SolidRun, but ran into some problems with adding an IR Infrared Remote Control. No matter which resource I followed, I could not get my OpenElec box to recognize and receive input from my IR Remote.
The following are the steps to take in an easy to follow guide to connect your remote to an OpenElec device.
This article assumes you have internet setup and working on your OpenElec device, and that your OpenElec device has an IR receiver.
If you purchased a device such as the CuBox-i4Pro like I did and it does not come with a remote, then you can plug your computers mouse into the USB port to do the initial setup of XBMC/Kodi and internet. Also make sure you have SSH enabled via the OpenElec Configuration addon within XBMX/Kodi.
Step One: SSH Into OpenElec
If you are on a Windows machine then download PuTTY. PuTTY is an SSH client that will allow you to run commands in Windows that control OpenElec. You can get the IP address of your box by checking your System Information within XBMC/Kodi
The username is: root
The password is: openelec
(note: when typing your password, you will NOT see the characters appear in the terminal. This is normal)
Step Two: Stop lirc and xbmc
Here is the reason every other resource failed to provide appropriate steps. They never told you to stop XBMC/Kodi. Basically what was happening is that XBMX/Kodi if not shutdown would automatically restart the lirc after you’ve stopped it. Annoying! So type the following into the terminal, one line at a time.
systemctl stop eventlircd.service systemctl stop kodi.service ir-keytable
The first line stops the lirc event (Linux Infrared remote control), the second line stops XBMX/Kodi from running (and therefor restarting the lirc), and the last line will show you what supported protocols you have.
Step Three: Enable the above listed protocols.
As you can see in my above screenshot, I have a ton of available protocols. If you know which protocol your remote uses then only list that one, but for most of us, let’s just list them all. Enter the following into the terminal.
ir-keytable -c -p NEC,RC-5,RC-6,JVC,SONY,LIRC,OTHER
Now enter the follwing:
ir-keytable -c ir-keytable -t
The first line clears out the old keytable just in case there was something in there from before. The second line is what allows you to start using your remote. You should see something like “Testing events. Please, press CTRL-C to abort.” If you do not see this then you either typed something wrong in the above steps (it’s case sensitive!) or you do not have a working IR receiver. If you DO see the Testing events dialogue then great! Point your remote at your OpenElec box and start pressing the buttons you wish to map.
I personally like to keep to a simple easy to use order. So the first button I press is the button I want to be mapped to “up”, then “down”, then “left”, then “Right”, “enter”, “back”, “play”, “stop”, etc.
If working, then you should start to see text appear in the console every time you press a button on the remote. It might look something like “event MSC: scancode = 72cd5c”. Press CTRL+C to when you’re done.
Step Four: Create a keymap
If the above worked for you then success! OpenElec successfully recognizes your remote and it’s inputs. The only problem now is that just because you press the UP button on your remote, doesn’t mean that OpenElec knows that it’s the UP button. We need to tell OpenElec what each button on your remote is supposed to do.
If you are a linux wiz, then you can create the following file through your prefered methods. For the rest of you, I’d strongly recommend downloading Notepad++. Notepad++ will make it much easier to create the following file and to make sure it is encoded properly for OpenElec.
Open up Notepad++ and make the first line read as this:
# table mycustomremote, type: NEC
You may need to change NEC to whatever protocol your remote uses from the start of Step 3. Next, make every subsequent line start with the Scancode id of the button followed by the action you wish. Here is a list of all Kodi actions.
Here is what an example keymap looks like:
# table mycustomremote, type: NEC 0x4580 KEY_UP 0x4581 KEY_DOWN 0x4551 KEY_LEFT 0x454d KEY_RIGHT 0x4521 KEY_ENTER 0x452b KEY_BACKSPACE 0x4516 KEY_INFO 0x4584 KEY_CONTEXTMENU 0x4515 KEY_PLAYPAUSE 0x4514 KEY_STOP
Important: Windows and Linux use different character encoding. So in notepad++ click on Edit from the menu -> EOL Conversion -> UNIX/OSX Format. Save the file as mycustomremote – with no extension. Notepad++ should default the save type as txt, but if you select All types (very top option) it should save the file with no extension.
Step 5: Upload the new keymap to OpenElec
Open up any folder on your computer, or goto My Computer. In the address bar (the text box that shows you the path of your current folder) and type in
This will open up an folder that contains many of the settings and files for your OpenElec device. Open up the folder called Configfiles, then open rc_keymaps. Copy and paste (or drag and drop) the mycustomremote file we created in Step 4.
Now go back to your SSH console (puTTy) and enter the following commands:
systemctl start eventlircd.service systemctl start kodi.service ir-keytable -c -p NEC,RC-5,RC-6,JVC,SONY,LIRC,OTHER -w /etc/rc_keymaps/mycustomremote
The first two lines restart the lirc event and XBMC/Kodi, and the third line loads up the new keymap we created and uploaded. You should see something similar to “Wrote XXX keycode(s) to driver/Protocols changed to NEC RC-5 RC-6 JVC SONY LIRC other”.
That’s it! Your remote should now be working! Try using it and see if Kodi responds.
Step 6: Create an autostart.sh file
One small problem is that everytime you have to restart your box for whatever reason, you have to SSH back into the box and run the command
ir-keytable -c -p NEC,RC-5,RC-6,JVC,SONY,LIRC,OTHER -w /etc/rc_keymaps/mycustomremote
We can automate this by placing an autostart.sh file into the
folder of OpenElec. To do this, first open up notepad++ and enter the above command. Make sure you change the EOL Conversion to UNIX/OSX Format again and save it as autostart.sh
Now go to the
folder on your computer and place autostart.sh there.
I hope this helps!