Thursday, August 9, 2012

devinput + Antec Veris / iMon remote used in XBMC

So I upgraded a friends XBMC system which runs on Ubuntu to 12.04 the other day and ran into the troubles with the changes in Lircd + devinput.  Luckily once I switched Lircd to devinput via:
sudo dpkg-reconfigure lirc
things generally worked but I was missing a few buttons, like one that opened the menu to delete things or enable subtitles.

This was using a Harmony/Logitech 800 remote to emulate the remote that came with the Antec Veris case.  When using irw or ir-keytables I could not see any buttons being hit when hitting the 'info', 'guide' or channel up or down.   I found notes about recompiling lirc due to it missing some scan codes (ref: https://bugs.launchpad.net/ubuntu/+source/lirc/+bug/1029604 or http://lirc.sourceforge.net/remotes/devinput/lircd.conf.devinput ) but I didn't really want to get into that and block future apt upgrades of lirc.  After quite awhile I found mention of /lib/udev/rc_keymaps and found imon_pad and imon_mce:
/lib/udev/rc_keymaps$ ls imon_*
-lrta-rw-r--r-- 1 root root 1756 Feb 10 15:58 imon_mce
-rw-r--r-- 1 root root 2742 Aug 8 21:22 imon_pad
my system was using the imon_pad file as found via dmesg:
~$ dmesg | grep imon | grep Registered
[   22.450927] Registered IR keymap rc-imon-pad

and I looked in there and noticed the buttons I wanted where not listed, specially BTN_RIGHT and BTN_LEFT which I have as 'info' and 'guide'.  So I used the old file from lircd prior to devinput and took the codes/names and merged it with imon_pad so I could have all the scan codes.  This was done by taking /usr/share/lirc/remotes/imon/lircd.conf.imon-pad editing it so I was left with a file that only had lines like:


          KEY_EXIT                 0x288195B7
          KEY_POWER                0x289115B7
          KEY_RECORD               0x298115B7
          KEY_PLAY                 0x2A8115B7
          SlowMotion               0x29B195B7
          KEY_REWIND               0x2A8195B7
          KEY_PAUSE                0x2A9115B7
          KEY_FASTFORWARD          0x2B8115B7
          KEY_PREVIOUS             0x2B9115B7
          KEY_STOP                 0x2B9715B7
          KEY_NEXT                 0x298195B7
          KEY_ESC                  0x2BB715B7
          Eject                    0x299395B7
          ... etc ...

This block of codes was the top one for this system, there is another block with longer codes but we want the ones that look similar to the /lib/udev/rc_keymaps/imon_pad .  Note this file is reversed, as in the name is there then the code so that has to be changed, plus the codes use upper case hex (AB instead of ab) I did this via a quick bit of cli perl:
cat keys_codes1 | perl -ne '@a = split; print lc($a[1]) . " " . $a[0] . "\n";' > key_codes2
then take that key_codes2 file and merge with imon_pad, sort and remove the dups between the two via:
cat /lib/udev/rc_keymaps/imon_pad /tmp/key_codes2 | sort  | uniq > /tmp/key_codes3
Now backup the original imon_pad and copy over key_codes3
sudo cp /lib/udev/rc_keymaps/imon_pad /lib/udev/rc_keymaps/imon_pad-bkupsudo cp /tmp/key_codes3 /lib/udev/rc_keymaps/imon_pad

Now you will have all the buttons mapped and accessible via lircd, so you can run 'irw' and see them all after a reboot (or restart of lirc and the imon module).  However at this point I found BTN_MENU was repeating, so you may need to edit /lib/udev/rc_keymaps/imon_pad and remove this line:
0x2ba3d5b7 KEY_MENU
You will see two other KEY_MENU lines in addition to that but leave those in place.

The last step is specific to XBMC, as I assume the above might help MythTV users too.  But for XBMC, if you are coming from an older kernel and previously used lircd without devinput you need to adjust your Lircmap.xml, this is in ~/.xbmc/userdata/ the only change here is to take out the device="Antec_Veris_RM200" and replace it so it looks like:
<remote device="devinput">
Once this is complete and things are restarted, I did a reboot to ensure it would all work after the next power outage, you should now have a fully working remote within XBMC.

Files to save doing all the steps:

1 comment:

BrianE said...

Also, after updating another system to 12.04 you need to have the package 'ir-keytable' installed to have the above file imon_pad available.