Use the standard build guide from the OpenElec wiki. After cloning the GIT repository, modify the lirc build script to build the correct module.
Open 'packages/sysutils/remote/lirc/build' and replace the following line for the userspace driver:
Update: I tried various things but for some reason I could not get the alsa support to be simply added to the standard build (this seems to be a bug in LIRC which should have been fixed upstream). You can try adding the line instead of replacing it (note the trailing slash!)
All done: now start the system build as you normally should:
PROJECT=Generic make release
Sit back and wait; on a Core2Duo system the build takes several hours and close to 9GB of space. Follow the guides to modify the lirc config in userspace, or modify the 'install' script to install the correct configuration into the read-only system build.
Updates Break LIRC!Your custom built OpenELEC will attempt to update itself with standard releases. You can disable automatic updates or place the LIRC binaries on the '/storage' mount where they will survive updates; just make sure you call the correct binaries. Note that this will only allow you to have updates as long as the binary compatability of OpenELEC does not change. It seems plausible that this will remain as such at least between large updates but if you want to be really sure you should switch to manual updates to prevent sudden breakage...
Audio SetupSome notes to set up the audio capture correctly as these seem to be scattered over the internet. First off, mute the capture for all inputs but the jack you connected the receiver to so only the correct input is enabled. On OpenELEC it seems like all inputs are muted by default so you only need to unmute the correct input from within '/storage/.config/autostart.sh':
# Select the correct input channel amixer set "Capture",0 cap # Set the volume of the capture amixer set "Capture",0 20In case you wonder which channel is the correct one or how loud it should be, use 'arecord'. You most likely will not have this program on OpenELEC but it is in fact identical to 'aplay': create a symlink to 'aplay' called 'arecord' and you are good to go.
Use 'arecord' to display the volume of the incoming signal (using the builtin VU), tweak to whatever your system needs:
arecord -vv -D hw:0 -c2 -r48000,l -f S16 > /dev/null
I experimented with the recording amplification until I had a near zero output when idle (2 to 3% on the VU) and 30% to 35% peak volume when holding a button down.
At first I had the volume tweaked so input would trigger 10% on the VU. At this point 'irrecord' seemed to work but it failed on the 'Toggle Bit' detection where you have to push a button as often as possible. Increasing the volume solved this (and simply opening the volume up to the max will break it again - calibrate it properly or 'irrecord' will fail!).
And for reference, this is how I start lircd from 'autostart.sh' in OpenELEC:
/storage/.bin/lircd --driver=audio_alsa --output=/var/run/lirc/lircd --pidfile=/var/run/lirc/lircd.pid -d hw@48000,l /storage/.config/lircd.conf
You could add '--uinput' to generate Linux input events besides standard lirc events. This effectively means the XBMC would not use LIRC events but something like keyboard strokes. It depends on personal preference but I still use the old fashioned LIRC events.