Category Archives: XBMC

Adding custom action to a keycode in XBMC

There are some USB IR remotes out there specifically made to be used in media centers. I bought one of those to setup my parents Raspberry Pi.

usb-ir-remote

It looked like everything worked out of the box with XBMC but then we noticed that the volume down button was not doing anything. So I had to check which keycode was being issued to bind it to the appropiate action in XBMC. You have to activate the debug on XBMC (Settings->System->Debugging) and then pressed the key a couple of times. Then look at the log file (temp/xbmc.log in your userdata directory, which in Linux is ~/.xbmc) for something like this:

18:25:59 T3034951680   DEBUG: OnKey: f14 (0xf09d) pressed, action is ...

You can use cat and grep for that:

$ cat ~/.xbmc/temp/xbmc.log | grep pressed

And there you have your keycode in hexadecimal format. Just convert it to decimal, which in this case is 65197, and then you need to know the name of the action you want to give to that keycode. The list can be found in ButtonTranslator.cpp:

        {"volumedown"        , ACTION_VOLUME_DOWN},

Finally add the key binding in keymaps/keyboard.xml file in your userdata directory:

<keymap>
  <global>
    <keyboard>
      <key id="65197">volumedown</key>
    </keyboard>
  </global>
</keymap>

Ref: http://wiki.xbmc.org/index.php?title=keymap#Keyboards
http://wiki.xbmc.org/index.php?title=HOW-TO:Modify_keyboard.xml