HOW-TO:Gyration USB remote in Ubuntu for XBMC using Lirc

This is a configuration for using a Gyration USB media remote reviewed here. This method uses two instances of lircd that are manually configured to start using /etc/rc.local. The files that are affected are:

Credit goes to the random anonymous bits and pieces I've found on the Interwebs along with my own experimentation using hexdump -C to look at the character device files while pressing buttons.

Important Note
This configuration was set up initially on XBMC 9.10. Starting with 9.11, however, instead of ~/.xbmc/userdata/Keymap.xml, multiple keymaps can be stored in the directory ~/.xbmc/userdata/keymaps/ in which all xml files will be parsed. The old configuration, however, still works. I will work on setting this up using the newer format and will edit this once it's ready.

Please review information on the newer Keymap.xml.

Also, please note that this method renders the mouse function on the remote unusable. It appears that as soon as two lircd processes are talking to each other, the mouse device stops reporting data altogether. I have no idea if there is a way to fix this. Instead, try using HOW-TO: Gyration USB remote in Ubuntu for XBMC using evrouter.

Install Lirc
First, install the lirc package. The installer will ask you what hardware you have so it can use the correct config file. What you select here will be overwritten later in this guide, so it really doesn't matter what you select.

Disable lircd automatic startup
We do not want to use Ubuntu's init scripts and config files, therefore we need to tell it not to start up automatically. Here is the command which changes the symbolic link in /etc/rc2.d/:

Back up files
Back up your old files that we are about to overwrite. These commands assume you are logged in as the user that is starting xbmc.

Edit /etc/rc.local
Put these lines in /etc/rc.local:

Edit /etc/lirc/lircd.conf
Here is /etc/lirc/lircd.conf

Create Keymap.xml
Here is ~/.xbmc/userdata/Keymap.xml

Create Lircmap.xml
Here is ~/.xbmc/userdata/Lircmap.xml

Testing
Make sure lircd is not running: Start lircd using /etc/rc.local: We use the irw command to test. It comes with the lirc package. This is me pressing various buttons, then holding the volume up. Notice that the repeating key shows incrementing numbers. You should get a blank line that will print the key name as configured in lircd.conf when that button is pressed.