[LINUX] HOW-TO use all custom buttons of your remote control with LIRC

  Thread Rating:
  • 2 Votes - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Temar Offline
Senior Member
Posts: 264
Joined: Nov 2008
Reputation: 8
Post: #1
As this Howto is linked in the wiki, I decided to update it to show the different ways howto configure your remote. Basically there are two ways of mapping your remote's buttons to XBMC actions:

1. Standard Remote configuration.
2. Universal Remote configuration.

Pros and Cons:

1. Standard Remote Configuration
  • (+) Easier to handle.
  • (-) Only a limited amount of buttons can be mapped.

2. Universal Remote Configuration
  • (-) Can be a bit confusing because of the button names.
  • (+) Allows you to map up to 256 buttons.


Requirements:

First you have to decide which type of configuration you want to use. If you have a XBox remote or any remote with only a few buttons, then you should use the Standard Remote Configuration. If you have a fancy high end remote with a lot of buttons then you should use the Universal Remote Configuration.

No matter which way you want to go, you need a fully working LIRC setup and you need to know:
  • The LIRC name of your remote.
  • The LIRC button names of your remote.

The name of your remote and all of the button names are defined in /etc/lirc/lircd.conf. Another way to get these names is by using the command line tool "irw". Start it and press every button on your remote. "irw" reports the remote's name and the name of the button which was pressed.


1. Standard Remote Configuration

First you have to understand the concept how XBMC maps the buttons of your remote. Open http://wiki.xbmc.org/?title=Keymap.xml and check the section Remote Buttons. There you find a table with the first column describing Button Strings. Button strings are XBMC's view on a standard remote. YOU CAN NOT DEFINE CUSTOM BUTTON STRINGS and therefore the number of button strings limits the number of buttons you can map. If your remote has more buttons you have to use the Universal Remote Configuration!

Each button string represents a remote input event. Until now XBMC does not know anything about your remote's buttons. It only knows these predefined input events. Think of it like keys on your keyboard. Every key has a name (or character) and each key triggers an input event. The same is true for a remote as XBMC sees it. As the button names of each remote are different XBMC predefines some input events which can be mapped to the buttons of your remote. This mapping is done in the Lircmap.xml configuration file.

1.1 Configuring "Lircmap.xml"

Location: $HOME/.xbmc/userdata/Lircmap.xml

Here is the general format of a valid Lircmap.xml file:

Code:
<lircmap>
  <remote device="LIRC_REMOTE_NAME">
    <BUTTON_STRING> LIRC_BUTTON_NAME </BUTTON_STRING>
  </remote>
</lircmap>

LIRC_REMOTE_NAME is the name of your remote as LIRC sees it and BUTTON_STRING is one of the valid remote input events described above. Let's suppose the name of your remote is MyRemote and your remote has 6 buttons. The LIRC names of these buttons are MyLeft, MyRight, MyUp, MyDown, MyOk and MyPrevious. Now you choose 6 button strings from the list of valid button strings to map these buttons to. For our 6 button remote example I choose the button strings: left, right, up, down, select and back. IT DOES NOT MATTER WHICH BUTTON STRINGS YOU CHOOSE! Just use the ones you think fit best for your buttons. Now that you know the name of your remote, the button names of your remote and the button strings, you can create your first Lircmap.xml file:

Code:
<lircmap>
  <remote device="MyRemote">
    <left>MyLeft</left>
    <right>MyRight</right>
    <up>MyUp</up>
    <down>MyDown</down>
    <select>MyOk</select>
    <back>MyPrevious</back>
  </remote>
</lircmap>

Now XBMC knows that the button MyLeft triggers the input event left. But that is not enough. An input event is like a key on the keyboard. It has no meaning until you map it to an XBMC action. To actually make XBMC do anything, you have to edit the Keymap.xml file.

1.2 Configuring "Keymap.xml"

Location: $HOME/.xbmc/userdata/Keymap.xml

Update 22.10.2010:

Since XBMC DHARMA the location of the Keymap.xml file changed. It is now named remote.xml and can be found in:

Location: $HOME/.xbmc/userdata/keymaps/remote.xml


Here is the general format of a valid Keymap.xml or remote.xml file:

Code:
<keymap>
  <global>
    <remote>
      <BUTTON_STRING> XBMC_ACTION </BUTTON_STRING>
    </remote>
  </global>
</keymap>

BUTTON_STRING is one of the button strings you mapped to one of your remote's buttons in Lircmap.xml and XBMC_ACTION is one of the valid XBMC actions defined in the section Available Actions of the wiki page: http://wiki.xbmc.org/?title=Keymap.xml.

For our 6 button remote example we select the XBMC actions: Left, Right, Up, Down, Select and PreviousMenu. We can now map these actions to the button strings we used in our Lircmap.xml file.

Code:
<keymap>
  <global>
    <remote>
      <left>Left</left>
      <right>Right</right>
      <up>Up</up>
      <down>Down</down>
      <select>Select</select>
      <back>PreviousMenu</back>
    </remote>
  </global>
</keymap>

That's it. After restarting XBMC we can use our new remote configuration.


2. Universal Remote Configuration

If you want to go for the hard way, you should first read and understand the configuration of a standard remote described in the first section of this howto. Do not configure anything - just read and try to understand the concept XBMC uses for its configuration.

As you can see from the first section of this howto, the number of button strings (= remote input events) is limited in XBMC. You can not define your own button strings and therefore you may not be able to use all of your remote's buttons. Configuring your remote as a universal remote circumvents this limit.

2.1 Configuring "Lircmap.xml"

Location: $HOME/.xbmc/userdata/Lircmap.xml

As you already know from the first section, the general format of a Lircmap.xml file looks like that:

Code:
<lircmap>
  <remote device="LIRC_REMOTE_NAME">
    <BUTTON_STRING> LIRC_BUTTON_NAME </BUTTON_STRING>
  </remote>
</lircmap>

We will again use our 6 button remote example but this time we will treat our remote as a universal remote. Instead of using button strings as input events, universal remotes use obc# tags. The general format of a universal remote button entry is:
Code:
<obc#> LIRC_BUTTON_NAME </obc#>
obc# is the identifier for our new universal remote input event with # being a number between 0 and 255. We will now create a Lircmap.xml file for the 6 buttons of our example remote from the first section. Be aware that the identifier obc has to be lowercase - OBC# is NOT valid!

ALSO NOTE THAT THE OBC CODES ARE SHARED WITH THE CODES FOR THE STANDARD REMOTE. YOU CAN FIND THESE IN /XBIRRemote.h FILE IN SVN. NOTE THAT OBC = 255 - VALUE THUS IF YOU USE <obc39> YOU'RE USING THE SAME CODE AS <back>

Code:
<lircmap>
  <remote device="MyRemote">
    <obc1>MyLeft</obc1>
    <obc2>MyRight</obc2>
    <obc3>MyUp</obc3>
    <obc4>MyDown</obc4>
    <obc5>MyOk</obc5>
    <obc6>MyPrevious</obc6>
  </remote>
</lircmap>

As you can see the file is quite similar to the one from the first section, except that we now use obc-tags as input events instead of button strings. You should now create an obc-entry for each button of your remote. In the next section we will assign these obc input events to XBMC actions.


2.2 Configuring "Keymap.xml"

Location: $HOME/.xbmc/userdata/Keymap.xml

Update 22.10.2010:

Since XBMC DHARMA the location of the Keymap.xml file changed. It is now named remote.xml and can be found in:

Location: $HOME/.xbmc/userdata/keymaps/remote.xml


Here is the general format of a valid Keymap.xml or remote.xml file for universal remotes:

Code:
<keymap>
  <global>
    <universalremote>
      <OBC_TAG> XBMC_ACTION </OBC_TAG>
    </universalremote>
  </global>
</keymap>

OBC_TAG is one of the obc# tags you used in your Lircmap.xml file and XBMC_ACTION is one of the XBMC actions listed in the section Available Actions of the wiki page http://wiki.xbmc.org/?title=Keymap.xml.

Again we choose the same XBMC actions like in the first section of this howto but this time we have to tell XBMC that we are using a universal remote configuration. A corresponding Keymap.xml file for our Lircmap.xml example could look like this:

Code:
<keymap>
  <global>
    <universalremote>
      <obc1>Left</obc1>
      <obc2>Right</obc2>
      <obc3>Up</obc3>
      <obc4>Down</obc4>
      <obc5>Select</obc5>
      <obc6>PreviousMenu</obc6>
    </universalremote>
  </global>
</keymap>

You can now use all of your obc# buttons to map them to different XBMC actions. Be aware that you have to use the <universalremote> tag instead of the <remote> tag.

Have fun mapping your buttons.

Temar
(This post was last modified: 2010-10-22 12:24 by Temar.)
find quote
analogue Offline
Skilled Python Coder
Posts: 149
Joined: May 2008
Reputation: 5
Post: #2
Nice work..thanks!
find quote
sho Offline
Team-XBMC Member
Posts: 4,128
Joined: May 2004
Reputation: 3
Post: #3
This probably belongs here:
http://wiki.xbmc.org/index.php?title=Uni...te_Control

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find quote
Temar Offline
Senior Member
Posts: 264
Joined: Nov 2008
Reputation: 8
Post: #4
sho Wrote:This probably belongs here:
http://wiki.xbmc.org/index.php?title=Uni...te_Control

I updated the Howto to show both ways of configuring your LIRC remote.

About Wiki Access: I already tried to get wiki access, but noone responded in IRC. Where else can I apply for wiki access?
find quote
onesojourner Offline
Aeon Group
Posts: 296
Joined: Jul 2008
Post: #5
Sticky this please!

ﻪﻥﻋﺸﻷﻜﻈﭚ
find quote
proctor Offline
Senior Member
Posts: 113
Joined: Aug 2008
Reputation: 0
Post: #6
Thanks for this. You shouldn't have to dive into sourcecode to setup a remote.
find quote
Maxim Offline
Fan
Posts: 706
Joined: Sep 2004
Reputation: 0
Post: #7
Thank you very much for this post, it was most helpful in configuring my remote with XBMC.
find quote
CrashX Offline
Posting Freak
Posts: 1,164
Joined: Jan 2009
Reputation: 2
Post: #8
Thanks for the guide ... Ask Pike for wiki access since it should be posted their ..

Location is not always $HOME/.xbmc/userdata/Keymap.xml
(This post was last modified: 2009-05-01 18:54 by CrashX.)
find quote
Temar Offline
Senior Member
Posts: 264
Joined: Nov 2008
Reputation: 8
Post: #9
CrashX Wrote:Thanks for the guide ... Ask Pike for wiki access since it should be posted their ..

Thanks for the hint, I'll send him a PM.

Quote:Location is not always $HOME/.xbmc/userdata/Keymap.xml

Why not? Where else does XBMC store the user's preferences?

Temar
find quote
treefrog Offline
Junior Member
Posts: 1
Joined: Apr 2009
Reputation: 0
Post: #10
Thanks for the guide. I now have all 49 buttons on this MCE remote working. As stated earlier this should be in the wiki. I would also like to suggest a note to linux users in the advancedsettings/displayremotecodes section.
Since it says "xbox only" it might be nice to mention this guide there also
find quote
spiff Offline
Retired Developer
Posts: 12,386
Joined: Nov 2003
Post: #11
it's a wiki. catch pike on irc, ask for ninja and off you goSmile
find quote
tmpdir Offline
Member
Posts: 80
Joined: Feb 2009
Reputation: 0
Post: #12
Temar Wrote:About Wiki Access: I already tried to get wiki access, but noone responded in IRC. Where else can I apply for wiki access?

Hey Temar, nice reading. About your remark, I've asked my wiki access as described here.
find quote
mgchan Offline
Junior Member
Posts: 6
Joined: Jun 2009
Reputation: 0
Post: #13
My Windows MCE remote seemed to work out of the box, after having switched from Myth on Mythbuntu by just adding on XBMC; for the most part I've got everything I need, but I would like to tweak a few settings (e.g. making the "Play" button make videos go straight to 1x playback). I'd rather not have to re-code all the buttons. Is there a place where I can edit what's already there? I don't have a Lircmap or Keymap file in my ~/.xbmc/userdata folder right now, so I'm not sure how XBMC is using my MCE remote (there's no xbmc file in my ~/.lirc folder either)
find quote
Temar Offline
Senior Member
Posts: 264
Joined: Nov 2008
Reputation: 8
Post: #14
mgchan Wrote:I'd rather not have to re-code all the buttons. Is there a place where I can edit what's already there?

Depending on where you installed XBMC the Keymap.xml & Lircmap.xml should be located in:

/usr/share/xbmc/system/
or
/usr/local/share/xbmc/system/
find quote
Nogood5 Offline
Senior Member
Posts: 184
Joined: Feb 2004
Reputation: 0
Post: #15
Temar Wrote:Depending on where you installed XBMC the Keymap.xml & Lircmap.xml should be located in:

/usr/share/xbmc/system/
or
/usr/local/share/xbmc/system/

When i try to edit these files winSCP denies me access. Same with Filezilla.
I am still very much a Linux noob so would appreciate some directions.

I tried copying them over to: /home/xbmc/.xbmc/system for lircmap and /keymaps/ for the remote.xml

But my changes take no effect. How can i get access to these files? Or was i on the right track by copying them over.
find quote
Post Reply