Total Linux Noob's guide to getting a Context menu button working on HDMI CEC remote

I am a long time XBMC user & very recent RPi 2 + OSMC fan. FYI I am running the RC version of OSMC.
I am not familiar with Linux AT ALL and probably the last person that wants to do ANYTHING in the Terminal.
This was one reason that OSMC caught my attention - because the install process (using the Installer app) was so simple!
I wanted to pass on how I got the Context Menu (& Info) function working on my Sony Remote - mapped to the FF and REW buttons - without SSHing or doing anything in the command line.

One of the things I really looked forward to with the RPi + OSMC was the ability to control using my regular TV remote without messing around with IR receivers / drivers etc.
In short: HDMI CEC - the protocol which allows connected devices to be controlled over the HDMI cable.

I have a Sony Bravia TV but these instructions should work for most OSMC/Kodi installs which are controlled using a remote over HDMI CEC.

You will need:

  1. Your OSMC install device and a means to control it - especially a way of using the context menu (I used the XBMC app on my iPhone)
  2. a computer with a working USB port
  3. a USB memory stick / card (mine was formatted to FAT32)
  4. a remote to use with your TV of course (most likely the original one)

To get the Context Menu & Info buttons working on your remote I’d recommend finding some buttons which already control things in OSMC but that you can live without.
I chose to reassign the FFWD and REW button on my remote

The settings for custom remote button assignments are kept in the remote.xml file which resides in the Keymaps folder, deep within Kodi - most of the guides I looked at to help me started going on about SSH at this point… but we can get this done without learning how to code.

My OSMC install did not have a remote.xml file installed (probably because there were no custom buttons set up), so I needed to create one.
Feel free to use my remote.xml file if you would like to use your FFWD button for the Context Menu and the REW button for the Info function.
If you want to assign your own buttons, it would be best to start with a default one.

On your computer generate a remote.xml file - do this by creating a blank ‘plain text’ file, copying and pasting the ENTIRE contents of the default remote.xml file I linked to above.
Make sure you name it “remote.xml” without the quotations - I made mine on a Mac using TextEdit (make sure you’re using Plain Text format)
I bet the Windows Notepad would work just as well.
Then customize it to suit your needs - find the name of the function you want to replace, then put ‘Context Menu’ inbetween the ><

For MY needs the two changes I made were:

> <forward>ContextMenu</forward>
> <reverse>info</reverse>

Once you have your remote.xml file, copy it onto your USB drive. (Safely) Eject it from your computer then plug it into your OSMC device (in my case a Raspberry Pi 2)
Boot the device & get it up on whatever screen you are using. Then using a method of control WHICH ALREADY ALLOWS YOU TO USE THE CONTEXT MENU (I used the XBMC remote app on my phone) navigate to…
System>Settings>File Manager

In File Manager there are two columns on screen - A and B. You can copy files from one to the other, which is what we are going to do.
First in one column (A), navigate to “Profile directory” and click it, then click on “keymap” - now you are looking at the contents of the Kodi keymap folder
Next in the OTHER column (B), navigate to your USB device and click it. Once you see the contents of your USB device navigate to the remote.xml file and then (while it is highlighted) use the Context Menu button to open the menu and select ‘Copy’. This will copy the remote.xml file from your USB stick into the Keymaps folder in Kodi - you should now see it appear in the other column (A).
At this point back all the way out to the main menu & navigate down to Power. Click it and select Reboot. Now cross your fingers & take a deep breath.
Once OSMC reboots, try out your TV remote & see if you have the Context Menu / Info functions where you want them.
I really hope that this helps someone else, I spent most of this weekend grappling with this & am so happy I made some progress I just wanted to share.
If it did help you or if you have a question feel free to post a reply - don’t forget to hit Thanks if this was useful. :heart:

2 Likes

Not hating on the effort, but there’s an app for that.

http://forum.kodi.tv/showthread.php?tid=168767

The ability to remap remote buttons is fundamental to a mediacenter, I think. So I am looking at building it into the MyOSMC options. But that would be further down the line.

5 Likes

I agree!
That would be AWESOME.
I thought that the Keymap Editor addon was going to be my savior but it did not work for me at all, I don’t really know why.

Hello,

I used your remote.xml file but this isn’t working for me. I downloaded your file and with the help of winscp i pasted it in “/home/osmc/.kodi/userdata/keymaps” but still when I start OSMC pressing FF or REW button won’t show the context menu.

Could anyone please help?

Thank you.

Try renaming the file to keymap.xml
Place it in /home/osmc/.kodi/userdata/keymaps
Here is a copy of my keymap.xml

<keymap>
<global>
   <remote>
        <yellow>ContextMenu</yellow>
        <green>PreviousMenu</green>
        <blue>Info</blue>
   </remote>
</global>
</keymap>

Work fine for me :smile: And remember a reboot for the changes to work.

Isn’t working either. :frowning:

Am I doing something wrong?

Strange. Did you remember to reboot?

Sorry to hear you’re having trouble with that.
thansen_dk provided a different solution which, I’m sure you’re aware, uses the Yellow, Green & Blue buttons on the remote for those functions instead.
I would have mapped my buttons similarly but my remote doesn’t have those color buttons on it.
My tip would be to make sure the buttons you want to use are ones whose functions are passed to OSMC via HDMI. Lots of the buttons on my remote only relate to the TV’s functions & so are not passed to OSMC and are not suitable candidates for a ‘Context Menu’ function. Hope that helps.
One other thought that occurs to me: make sure that the keymap/remote.xml files you’re creating are in “plain text” format - the wrong formatting will definitely cause problems.
Also did you already try the Keymap Editor addon, like Karnage suggested above?