Lirc for Creative LiveDrive
Foreword
I'm using my computer as main media center in my home. Most of music I listen and video I watch is played directly by my Linux media applications. Thanks to lirc package I can control my computer using remote control. It's a great thing especially for such a lazy person like me, I can do whatever I need with my computer not moving away from my couch. Lirc is offering support for wide range of infrared remote controls. I have Creative LiveDrive with RM-1500 remote control. Both devices were part of my Creative SoundBlaster Audigy 4 Pro sound card. KDE desktop environment has direct support for Lirc devices and thanks to this I'm able to remotely control any application that is using Linux system messaging bus DBus. What I especially love about remote control in Linux is that I'm not bound to some kind of default configuration I have to learn. I can setup my controls and choose applications I want to control by my self. Only my imagination and sky is the limit. Thats the main difference between Linux and other operating systems. You make Linux work as you like, not learn by heart how you should use your system.
I will try to share here my Lirc and remote control configuration that is coming from my main computer. Lirc is not the only remote control application available for Linux at the end you can find also short information about another applications I use to remote control my computer. Most of the provided here information should be applicable to any Linux distribution but some of the instruction are typical for distribution I use Gentoo Linux. If you have different remote control hardware you can still find some of the information provided here useful. I will start with kernel and system service configuration.
Kernel and system service configuration
My remote control is integrated with my sound card therefor I have to control it using sound card kernel module. To configure my kernel I had to enter kernel catalog and start menuconfig by running following commands in terminal:
cd /usr/src/linux make menuconfig
Below you will find the list of needed kernel modules for my lirc device.
Linux Kernel Configuration: Kernel modules configuration |
Loadable module support ---> [*] Module unloading Device Drivers ---> Input device support ---> [*] Event interface <M> Sound card support ---> <M> Advanced Linux Sound Architecture ---> [*] PCI sound devices ---> <M> Emu10k1 (SB Live!, Audigy, E-mu APS) |
As you can see the sound card support will be build as module. The module will be loaded by udev hardware allocation service and initialized during alsa sound system service start. After marking all necessary kernel modules I'm ready to recompile, install and use new kernel. I usually do it by running this commands in terminal:
cd /usr/src/linux make && make modules_install install
This is not over yet. To initialize remote control for Emu10k1 kernel module I had to pass additional parameter to kernel module. I did this by providing sound module configuration in /etc/modprobe.d/alsa.conf. Below you can find part of my alsa.conf file that is affecting Audigy 4 sound card configuration.
alias snd-card-0 snd-emu10k1 options snd-emu10k1 index=0 id=audigy4pro extin=0x3fcf extout=0x1fcf enable_ir=1 alias sound-slot-0 snd-emu10k1
The most important part is options line. Kernel module option enable_ir = 1 is enabling infrared red remote control for my sound card.
Now it's good time to reboot the machine with new kernel. After this the new kernel modules should be loaded and infrared remote control should be available. Unfortunately I found out this is not enough to make my Sound Blaster Audigy 4 Pro LiveDrive properly receive infrared signals coming from it's remote control. LiveDrive control LED wasn't lighting when I was pressing remote control buttons. After searching the Internet I found out that LiveDrive device need to be initialized with special command. The best way to do it is to write additional simple system service which will depend on alsa sound system service. I called this service audigy. Below you can see the service script which is making my remote control fully operational.
#!/sbin/runscript depend() { need alsasound } start() { ebegin "Initialising external I/O Hub" echo -e '\0360\0000\0040\0041\0141\0000\0000\0000\0177\0000\0367' > /dev/snd/midiC0D1 eend $? } stop() { ebegin "Nothing to Stop" eend $?
As you can see in this script my LiveDrive device is bound to device node /dev/snd/midiC0D1. The script itself is very basics it simply passes the initialization string using ASCI characters string in octal code. Now I can add this script to default run level to make it start on next system boot. To do it I need to run following command in terminal:
rc-update add audigy default
To make it start without the need of restarting my system I have to run following command in my terminal:
/etc/init.d/audigy start
After starting this service the LED on LiveDrive device started to light every time I pressed button on my remote control. Now we can move on to Lirc configuration.
Lirc Configuration
Before installing Lirc on Gentoo system you should provide a name of lirc devices in /etc/make.conf. This will make lirc install only components you need. In my system lirc configuration in /etc/make.conf looks like this:
LIRC_DEVICES="livedrive_midi"
To install lirc in Gentoo system you need to run this commands in terminal:
emerge -av sys-apps/lirc
Lirc installation, will provide system service which will let us start lirc daemon. Before starting this service we should configure it properly. First thing we need to do is to tell lirc service what type of device we want to use. We do it by appending LIRCD_OPTS options into /etc/conf.d/lircd file. Configuration for Audigy 4 Pro LiveDrive should look like this:
LIRCD_OPTS="-H livedrive_midi -d /dev/snd/midiC0D1"
Second thing we need to do is to provide a configuration file that will map core IR signals to our remote control buttons. On Lirc project page you will find a detailed instruction how to do it manually, but there is no need to. You should be able to easily find the configuration file for your remote control on Lirc page or somewhere in Internet. The configuration file should be saved as /etc/lirc/lircd.conf. Below you can see configuration for my devices.
############################################################## #RM-1500 For Audigy 4 Pro ############################################################## begin remote name Creative_RM-1500 bits 16 flags SPACE_ENC|CONST_LENGTH eps 30 aeps 100 header 9078 4671 one 663 1607 zero 663 497 ptrail 662 repeat 9078 2216 pre_data_bits 16 pre_data 0x8322 gap 106974 min_repeat 4 toggle_bit 0 begin codes Power 0x000000000000619E 1 0x0000000000008B74 2 0x0000000000008F70 3 0x000000000000906F 4 0x0000000000008A75 5 0x000000000000847B 6 0x0000000000007887 7 0x0000000000008976 8 0x000000000000837C 9 0x0000000000007788 0 0x000000000000807F CMSS 0x000000000000718E EAX 0x0000000000008C73 Mute 0x0000000000006E91 Vol_Down 0x000000000000639C Vol_Up 0x000000000000629D Up 0x0000000000007B84 Left 0x0000000000008778 Ok 0x000000000000817E Right 0x000000000000758A Down 0x0000000000008D72 Return 0x0000000000008E71 Start 0x0000000000008877 Cancel 0x0000000000007C83 Rec 0x000000000000738C Options 0x000000000000827D Display 0x0000000000007689 Previous 0x0000000000007F80 Play 0x0000000000007986 Next 0x0000000000007A85 Slow 0x0000000000007D82 Stop 0x000000000000857A Step 0x0000000000007E81 end codes end remote # # contributed by Stefan Br�ns # # brand: Creative Audigy 2 ZS Platinum LiveDrive # model no. of remote control: # devices being controlled by this remote: # begin remote name LiveDrive flags SPACE_ENC|CONST_LENGTH bits 16 eps 30 aeps 100 header 9000 4500 one 563 1687 zero 563 562 pre_data_bits 16 pre_data 0x8000 gap 108000 toggle_bit 0 repeat 9000 2250 frequency 38000 duty_cycle 33 begin codes mute 0x0000000000000040 vol+ 0x0000000000008080 vol- 0x0000000000008082 cmss 0x0000000000000080 end codes end remote begin remote name LiveDrive_Headphone bits 16 flags SPACE_ENC|CONST_LENGTH eps 30 aeps 100 header 9000 4500 one 563 1687 zero 563 562 repeat 9000 2250 pre_data_bits 16 pre_data 0x8000 gap 108000 toggle_bit 0 frequency 38000 duty_cycle 33 begin codes Headphone_out 0x4000 Headphone_in 0x4080 end codes end remote
As you can see my file has configuration for 3 devices. First one is my 33 button remote control. Second one is LiveDrive receiver which has 2 buttons and volume knob. The last one device is Hedphone monitor which will allow me to react on headphones plug in and out events. This ends my remote control configuration. Now I'm ready to use my lirc devices. I can start them by running following command in terminal:
/etc/init.d/lircd start
To make my lircd start as system service I have to run following command in terminal:
rc-update add lircd default
Now I can configure applications to use my lirc devices.
Applications configuration
There are two ways of controlling programs using lirc. First one is direct lirc support build into the application. To make my applications use lirc support I had to add lirc use flag to /etc/make.conf, then I can rebuild applications with the new use flag by running following command in terminal.
emerge --deep --update --newuse world
To check which of installed programs have direct lirc support you can use gentoolkit equery utility like this:
equery hasuse lirc [ Searching for USE flag lirc in all categories among: ] * installed packages [I--] [ ~] kde-base/kdeutils-meta-4.4.4 (4.4) [I--] [ ] dev-python/kaa-base-0.6.0 (0) [I--] [ ~] media-video/mplayer-1.0_rc4_p20100612 (0) [I--] [ ] media-video/vlc-1.0.6 (0) [I--] [ ~] media-plugins/audacious-plugins-2.3 (0) [I--] [ ~] media-plugins/banshee-community-extensions-1.6.1 (0) [I--] [ ~] media-tv/mythtv-0.23_p25073 (0)
As you can see on my system example there is wide range of programs that has direct lirc support. To make them use lirc you have to create a special ~/.lircrc configuration file in your home which will map program functions to remote control buttons. You can check what kind of program functions are available to user by running program help command or reading program documentation. Below you can find my .lircrc mapping file for MythTV media center, Audacious and Banshee sound players.
##################################################### #MythTv LiveDrive Configuration ##################################################### #Volume Down begin remote = LiveDrive button = vol- prog = mythtv config = [ repeat = 1 end #Volume Up begin remote = LiveDrive button = vol+ prog = mythtv config = ] repeat = 1 end #Mute begin remote = LiveDrive button = mute prog = mythtv config = | end #Show teletex/caption begin remote = LiveDrive button = cmms prog = mythtv config = T end ##################################################### #Audacious LiveDrive Configuration ##################################################### #Volume Down begin remote = LiveDrive button = vol- prog = audacious config = VOL_DOWN repeat = 1 end #Volume Up begin remote = LiveDrive button = vol+ prog = audacious config = VOL_UP repeat = 1 end #Mute begin remote = LiveDrive button = mute prog = audacious config = MUTE end # Playlist clear begin prog = audacious remote = LiveDrive button = cmss repeat = 0 delay = 0 config = PLAYLIST_CLEAR end ##################################################### #MythTV Creative RM-1500 Configuration ##################################################### begin remote = Creative_RM-1500 button = Up prog = mythtv config = Up repeat = 1 end begin remote = Creative_RM-1500 button = Down prog = mythtv config = Down repeat = 1 end begin remote = Creative_RM-1500 button = Left prog = mythtv config = Left end begin remote = Creative_RM-1500 button = Right prog = mythtv config = Right end #stop in mythmusic OR show osd begin remote = Creative_RM-1500 button = Stop prog = mythtv config = O end begin remote = Creative_RM-1500 button = Play prog = mythtv config = P end begin remote = Creative_RM-1500 button = Previous prog = mythtv config = Home end begin remote = Creative_RM-1500 button = Next prog = mythtv config = End end begin remote = Creative_RM-1500 button = Vol_Down prog = mythtv config = [ repeat = 1 end begin remote = Creative_RM-1500 button = Vol_Up prog = mythtv config = ] repeat = 1 end begin remote = Creative_RM-1500 button = Ok prog = mythtv config = Enter end begin remote = Creative_RM-1500 button = Mute prog = mythtv config = | end #Numer Codes begin remote = Creative_RM-1500 button = 1 prog = mythtv config = 1 end begin remote = Creative_RM-1500 button = 2 prog = mythtv config = 2 end begin remote = Creative_RM-1500 button = 3 prog = mythtv config = 3 end begin remote = Creative_RM-1500 button = 4 prog = mythtv config = 4 end begin remote = Creative_RM-1500 button = 5 prog = mythtv config = 5 end begin remote = Creative_RM-1500 button = 6 prog = mythtv config = 6 end begin remote = Creative_RM-1500 button = 7 prog = mythtv config = 7 end begin remote = Creative_RM-1500 button = 8 prog = mythtv config = 8 end begin remote = Creative_RM-1500 button = 9 prog = mythtv config = 9 end begin remote = Creative_RM-1500 button = 0 prog = mythtv config = 0 end #Show menu begin remote = Creative_RM-1500 button = Options prog = mythtv config = M end #Jump to bookmarked position begin remote = Creative_RM-1500 button = Return prog = mythtv config = K end #Cycle through aspect ratios begin remote = Creative_RM-1500 button = Display prog = mythtv config = W end #close/cancel/escape begin remote = Creative_RM-1500 button = Cancel prog = mythtv config = Esc repeat = 3 end #show teletext / captions begin remote = Creative_RM-1500 button = CMSS prog = mythtv config = T end #Show information (OK button is Enter) begin remote = Creative_RM-1500 button = Start prog = mythtv config = I end #adjust time stretch begin remote = Creative_RM-1500 button = Slow prog = mythtv config = A end #increase play speed begin remote = Creative_RM-1500 button = Step prog = mythtv config = U end #cycle through audio streams begin remote = Creative_RM-1500 button = EAX prog = mythtv config = + end begin remote = Creative_RM-1500 button = Power prog = mythtv config = Esc end begin remote = Creative_RM-1500 button = Rec prog = mythtv config = R end ##################################################### #Audacious Creative RM-1500 Configuration ##################################################### begin remote = Creative_RM-1500 button = Play prog = audacious config = PLAYPAUSE end begin remote = Creative_RM-1500 button = Stop prog = audacious config = STOP end begin remote = Creative_RM-1500 button = Options prog = audacious config = SHUFFLE end begin remote = Creative_RM-1500 button = Options prog = audacious config = SHUFFLE end begin remote = Creative_RM-1500 button = Return prog = audacious config = REPEAT end begin remote = Creative_RM-1500 button = Right prog = audacious config = FWD end begin remote = Creative_RM-1500 button = Left prog = audacious config = BWD end begin remote = Creative_RM-1500 button = Power prog = audacious config = QUIT end begin remote = Creative_RM-1500 button = Start prog = audacious config = LIST end begin remote = Creative_RM-1500 button = EAX prog = audacious config = PLAYLIST_ADD end begin remote = Creative_RM-1500 button = CMSS prog = audacious config = PLAYLIST_CLEAR end begin remote = Creative_RM-1500 button = Previous prog = audacious config = PREV end begin remote = Creative_RM-1500 button = Next prog = audacious config = NEXT endbegin remote = Creative_RM-1500 button = Vol_Down prog = audacious config = VOL_DOWN repeat = 1 end begin remote = Creative_RM-1500 button = Vol_Up prog = audacious config = VOL_UP repeat = 1 end begin remote = Creative_RM-1500 button = Mute prog = audacious config = MUTE end ##################################################### #Banshee LiveDrive Configuration ##################################################### #Volume Down begin remote = LiveDrive button = vol- prog = banshee config = volume-down repeat = 1 end #Volume Up begin remote = LiveDrive button = vol+ prog = banshee config = volume-up repeat = 1 end #Mute begin remote = LiveDrive button = mute prog = banshee config = toggle-mute end # Play begin prog = banshee remote = LiveDrive button = cmss repeat = 0 delay = 0 config = play end ##################################################### #Banshee Creative RM-1500 Configuration ##################################################### begin remote = Creative_RM-1500 button = Stop prog = banshee config = stop end begin remote = Creative_RM-1500 button = Play prog = banshee config = play end begin remote = Creative_RM-1500 button = Previous prog = banshee config = previous end begin remote = Creative_RM-1500 button = Next prog = banshee config = next end begin remote = Creative_RM-1500 button = Vol_Down prog = banshee config = volume-down repeat = 1 end begin remote = Creative_RM-1500 button = Vol_Up prog = banshee config = volume-up repeat = 1 end begin remote = Creative_RM-1500 button = Mute prog = banshee config = toggle-mute end
As you can see this file isn't complicated. For every remotely controlled function you have to create one entry closed between begin and end words. For every entry you must provide your remote controller name, it's button name, program name and program function that should be assigned to previously given button. Optionally you may defined repeat parameter if the function should be repeated when you hold down the button. This last parameter is useful mostly for volume controls. Number of available functions are dependent on lirc support implantation. As you can see on above example MythTV and Audacious has wide range of lirc functions while Banshee support is very basic.
Some of the applications are offering their own lirc support. XBMC best looking media center available for Linux is example of such application. To make it work with lirc you have to provide Lirc mapping configuration file in xml format and save it in your home as ~/.xbmc/userdata/Lircmap.xml. Below you can see my Lircmap.xml file.
<lircmap> <remote device="LiveDrive"> <volumeplus>vol+</volumeplus> <volumeminus>vol-</volumeminus> <mute>mute</mute> <power>cmss</power> </remote> <remote device="Creative_RM-1500"> <power>Power</power> <one>1</one> <two>2</two> <three>3</three> <four>4</four> <five>5</five> <six>6</six> <seven>7</seven> <eight>8</eight> <nine>9</nine> <zero>0</zero> <info>CMSS</info> <menu>EAX</menu> <mute>Mute</mute> <volumeminus>Vol_Down</volumeminus> <volumeplus>Vol_Up</volumeplus> <up>Up</up> <left>Left</left> <select>Ok</select> <right>Right</right> <down>Down</down> <back>Return</back> <start>Start</start> <clear>Cancel</clear> <record>Rec</record> <title>Options</title> <display>Display</display> <skipminus>Previous</skipminus> <play>Play</play> <pageplus>Step</pageplus> <pause>Slow</pause> <stop>Stop</stop> <skipplus>Next</skipplus> </remote> </lircmap>
This file provides a mapping of the keys on my remote controllers to XBMC button strings defined as xml tags. Full list of button string available in XBMC you can find here. Those button strings are mapped by default XBMC configuration to actions available in media center. I could create my own action mappings but I found this unnecessary as default configuration is working quite well for me.
The second method to setup lirc support in applications is using build into KDE desktop environment GUI LIRC settings utility. The is probably the easiest way. This KDE tool has direct support and easy wizards to set up most popular KDE applications including: Kaffeine media player, Konqueror web browser, KDE sound mixer, VLC media player, Amarok media player, KsCD audio CD player, Okular document browser and Dragon media player. If this is not enough you can use advanced setup for any programs that are using Linux system messaging bus DBus. This way I was able to remotely control additional applications like for example Kmplayer media player. Using this tool you can also assign remote controller functions for shutdown, reboot, hibernate and suspend system actions. Last but not least you can setup lunch program actions. This tool is so easy to use that I want be wasting my time to explain how to work with it. You can see this tool on some of the screenshots provided below.
The configuration of Lirc is not so hard it just require some time to write all those files. Most of them you can find in Internet. Lirc package is not the only way to remotely control your Linux application. I use other tools as well below you find more information.
Additional Information
Besides the infrared remote controller I also have a bluetooth Cordless Logitech Rumplepad 2 game pad. I use this pad to control my media center applications MythTV and XBMC. I also use it as remote pointing device. To control both media centers I had to build them with joystick support. For MythTV I additionally had to create a joystick configuration file in my home and save it as ~/.mythtv/joystickmenurc. Below you can see my joystick configuration file for mythtv.
devicename /dev/input/js0 button 0 Enter button 1 T button 2 P button 3 0 button 4 M button 5 K button 6 I button 7 A button 8 U button 9 Esc button 10 | button 11 Escape axis 1 -32767 0 Home axis 1 32767 0 End axis 2 32767 0 [ axis 2 -32767 0 ] axis 4 -32767 0 Right axis 4 0 32767 Left axis 5 -32767 0 Down axis 5 0 32767 Up
In this file I provide a joystick device node and mapping of my joystick buttons and axis to MythTV functions.
Controlling XBMC with my game pad does not require any additional configuration as XBMC comes with full support for Logitech Cordless RumplePad 2 game controller. My game pad was working in XBMC right away after media center installation.
To use my game pad as remote pointing device I had to additionally install QJoyPad application. This is program which lets user translate input events generated by joysticks into mouse actions and keystrokes in Linux X environment. This program comes with simple to use settings wizard which is helping user create many layout configurations. User can switch between defined configurations in runtime.
Prove that it's working
Sources
- Lirc Project Page
- Gentoo Wiki Lirc HowTo
- MythTV Wiki
- XBMC Lirc HowTo
- emu10k1 kernel module documentation
- man lircd
If you have found something wrong with the information provided above or maybe you just want to speak your mind about it, feel free to leave a comment.
All comments will show up on page after being approved. Sorry for such policy but I want to make sure that my site will be free of abusive or vulgar content. I don't mind being criticized just do it using right words.
Processing a comment.