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

Install unetbootin in Ubuntu for simple bootable GNU/Linux USB drives creation

sudo add-apt-repository ppa:gezakovacs/ppa
sudo apt-get update
sudo apt-get install unetbootin

UNetbootin_logo

Ref: https://launchpad.net/~gezakovacs/+archive/ubuntu/ppa

Boost low volume in XBMC

AC3 encoded movies usually have very low volume. To fix this edit the /usr/share/xbmc/system/advancedsettings.xml file and add this inside the <advancedsettings>...</advancedsettings> tags:

<advancedsettings>
  ...
  <audio>
    <ac3downmixgain>48.0</ac3downmixgain>
  </audio>
</advancedsettings>

Change the value until it fits the volume you want and beware because althougt the option says ac3downmixgain it boosts the volume for all codecs.

speaker

Ref: http://forum.xbmc.org/showthread.php?tid=164929&pid=1421472#pid1421472

Fix no video problem in XBMC

Although is recommended using a dedicated media center distribution (raspbmc, openelec or xbian for example) because they come already configured, if you decide to install XBMC on your own in Raspbian you may have problems playing videos. If you don’t see video and it just plays the audio when opening a movie it may be caused because XBMC is trying to use hardware acceleration and you don’t have the MPEG-2 license in your Raspberry Pi.

xbmc-no-video

To use software decoding follow those steps:

  • Go to System -> Settings and then select the “Video” tab.
  • Change the “Settings level” in the lower left corner to “Expert”. This will reveal the “Acceleration” menu option.
  • Now go to the “Acceleration” menu option and change “Decoding method” to “Software”.

Settings.videos.acceleration

You can see a video doing those steps here.

If this doesn’t fix the problem by itself try adding this option to /boot/config.txt:

start_x=1

This enables the use of “_x” firmware files (start_x.elf) and should allow software codecs to work.

Ref: http://forum.xbmc.org/showthread.php?tid=170832

Configure Raspberry Pi Composite Video Output for old TVs

Raspberry Pi comes with the composite video output configured to NTSC by default and older TVs aren’t able to detect that and change the format to PAL for example. In that case in a PAL TV youl’ll see the image in black and white:

ntsc-signal-on-an-old-pal-tv

You can reconfigure the output mode using the “sdtv_mode” option in /boot/config.txt. This are the available options:

  • 0: Normal NTSC
  • 1: Japanese version of NTSC – no pedestal
  • 2: Normal PAL
  • 3: Brazilian version of PAL – 525/60 rather than 625/50, different subcarrier

So for my TV I configured it to 2:

sdtv_mode=2

There are more configuration options for composite video in the official RPiconfig documentation.