Using Hauppauge MCE remote with Arch Linux
Recently I shut down my Windows Media Center PC and it felt like the end of an era. I was no longer using its TV recording capabilities but mostly using it in my son’s room as a media receiver. Needless to say it seemed a bit of a waste so I finally just pulled it down and we have been using a Sony SMPN-100 that can easily be moved around the house wherever it is needed.
Fast forward a few weeks my son decided he wanted his own computer. I had the old Media Center machine sitting in a closet providing a nice home for a bunch of dust and a few spiders so it made sense to pull it out of mothballs. I knew it would easily plug into his TV as that is how it spent a majority of its life so I went about getting it reconfigured. I have recently switched my personal system over to Arch Linux so I thought it would be a good time to reload his machine with Arch and install XBMC on the machine so he could also have a media center when he is not playing Minecraft.
I quickly had Arch and XBMC up and running. Next I had the IR receiver and my old Hauppauge MCE remote hooked up and then trouble began. It would seem that the newer Linux kernels have baked in support for IR remotes out of the box which is definitely a plus, but there is not much documentation out there about getting it working correctly. Even without installing the lirc daemon the remote somewhat worked with XBMC but not as I would have expected. I spent the better part of two days attempting to get it working as my remote of old. I googled, I read forums and every blog post I could find about lirc and getting it setup with XBMC. There may have been a little grumbling and swearing thrown in for good measure. No matter what I tried, running irw it seemed to pick the remote up as a keyboard.
Since my remote apparently had an identity crisis I decided to try a different approach; if the remote wanted to be a keyboard that was fine with me. The trick is finding the key map for the remote and reprogram in such a way it did what I wanted it to do. First I needed to find out what driver it was using for the remote by running ir-keytable.
Found /sys/class/rc/rc0/ (/dev/input/event5) with:
Driver mceusb, table rc-rc6-mce
Supported protocols: NEC RC-5 RC-6 JVC SONY LIRC other
Enabled protocols: RC-6
The important part here is to find out what key table the remote is using, in this case I am using the rc6-mce key table. Next I copied the key table in /etc/rc_keymaps/rc6_mce into my home folder and basically the next part is trial and error. I ran ir-keytable -t (which operates much like irw) and pushed the button I wanted to map starting with the OK button to find the key code. I would then push the button that worked in XBMC to find out what that key code was and then Ctrl-C out of ir-keytable and fire up an editor to modify the rc6_mce key map file in my area. I changed the KEY_OK to KEY_ENTER in this case and saved the rc6_mce file. Next I ran sudo ir-keytable -c to clear the current table and then reprogram the buttons with sudo ir-keytable -w ~/rc6_mce which loads my new key map. I tested to make sure it worked as expected and I was happy to have my OK button back. OK indeed.
Basically just rinse and repeat for any key you want to map on the remote. Once I was happy with my results, I copied the rc6_mce keymap from my home folder back to /etc/rc_keymaps so it would be reloaded at boot. I made a backup of the original rc6_mce key map file just to be on the safe side.
Hopefully that will save someone a little bit of time and heart ache.