Montag, 13. Juni 2011

Harmony One with iMON and XBMC - without Lirc

There are at least five remotes lying on my couch table, directing the TV, mediacenter, beamer, amplifier and so on. Time for a universal remote, and being a good swiss citizen, I've chosen a Logitech one (the Harmony One).

The configuration of the remote is hilarious! No way to store a configuration locally, no way to edit a configuration file for skipping the awful GUI. You'll loose a few hours with endless roundtrips configure-test-change ...

Nevertheless, the first setup was running more or less smoothly, hadn't there been this sluggish delay for the Keypad/Arrow (Left, Right, Up, Down): There's a one second delay between an event and the next, pressing continuously is not possible at all.

I've tried teaching the Harmony some IR commands using the original RM200 remote, but to no avail.

My media center runs XBMC under Ubuntu Natty, with a Soundgraph iMON receiver (15c2:0038). This iMON device offers an MCE mode as well, so I've set up the Harmony One with an MCE remote configuration.
Testing the remote resulted in ... no results. Starting with Linux Kernel 2.6.35, a new in kernel driver for iMON emerged, changing quite a lot in the Lirc/Remote business.
Unfortunately, the possibility for selecting an MCE mode for my iMON device dropped out of the new implementation as well. For a general introduction into the new kernel input layer, have a look at Jarod's Blog (Linux 2.6.35+ Remote Control Overview and Imon)

No longer being able to switch to an MCE mode like with the old lirc_imon module, I had to resort to using ir-keytable from the v4l-utils for setting an MCE compatible keycode/scancode table.

Surprisingly, the Keypad/Arrow buttons were working like a charm. No delays. Splendid.

The bottom line of all these changes concerning Lirc and the imon kernel module is this: I don't need lirc anymore and can use my remote under the linux input layer, with the new imon module.
Agreed, the way to a working remote under XBMC/Ubuntu Natty was challenging.
The following log might ease the transition for others ...

Configuring the Harmony One
  1. Create an MCE compatible remote in the Logitech Harmony Remote Software (e.g. Media Center PC/Microsoft/MCE Remote)
  2. Make sure all keys of the Harmony in the configuration are mapped to commands, with no duplicate commands
  3. Synch the changes to the remote
  4. Adjust your Activities as necessary
Setting Up an MCE Remote under Linux
The following changes were made under Ubuntu Natty.
  1. Remove the lirc package. Yay! (make a backup of the configs, just to be safe):
    sudo apt-get purge lirc
  2. Install the v4l-utils:
    sudo apt-get install v4l-utils
  3. Create a customised MCE keymap:
    sudo mkdir -p /etc/rc_keymaps ;
    sudo cp /lib/udev/rc_keymaps/imon_mce
    /etc/rc_keymaps
    • Edit the custom keymap and change keycodes if necessary. I had to change KEY_SELECT to KEY_OK, which was not present in the MCE keymap.
    • Add bindings for keys which were missing (like the 'Prev' key on the Harmony). For me this was:
      0x02000029 KEY_ESC
  4. Create an init script for loading the keymap:
    sudo vi /etc/init.d/mce-remote
    Add the following content:
    #!/bin/sh
    # Loads imon_mce keymap

    /usr/bin/ir-keytable -c -w /etc/rc_keymaps/imon_mce
    # Due to a bug in the ir-keytable version in Natty, set the keymap again:
    /usr/bin/ir-keytable -c -w /etc/rc_keymaps/imon_mce

    exit 0;
  5. Load keymap after boot (before LCD, if present)
    sudo update-rc.d mce-remote defaults 55 45
Voilà, MCE remote, without the lirc daemon.

Concerning point 5 and the LCD daemon: I had the keymap changes in rc.local at first, which was definitely too late and resulted in a lock up of the LCD daemon and XBMC.