Difference between revisions of "LIRC"

From ArchWiki
Jump to: navigation, search
(Buttons processed several times when pressed)
(remove gibberish, see talk)
 
(178 intermediate revisions by 43 users not shown)
Line 1: Line 1:
{{i18n|LIRC}}
+
[[Category:Other hardware]]
[[Category:Other hardware (English)]]
+
[[ja:LIRC]]
[[Category:Audio/Video (English)]]
+
This article covers setup and usage of [http://lirc.org/ LIRC] "Linux Infrared Remote Control" with serial or USB infrared devices.
LIRC stands for "Linux Infrared Remote Control", a program to use infrared devices (like your remote control from your TV) with linux.
 
  
This article covers using LIRC with serial or USB infrared devices.
+
LIRC is a daemon that can translate key presses on a supported remote into program specific commands.  In this context, the term, "program specific" means that a key press can do different things depending on which program is running and taking commands from LIRC.
  
==Installation==
+
* User hits a button on the remote causing it to transmit an IR or RF signal.
 +
* The signal is received by the receiver connected to the Linux box.
 +
* The kernel (via the correct module) use presents pulse data from the remote on a device like /dev/lirc0, /dev/input/eventX, /dev/ttyUSBX or /dev/ttyS0.
 +
* {{ic|/usr/bin/lircd}} uses the information from {{ic|/etc/lirc/lircd.conf.d/foo.conf}} to convert the pulse data into button press information.
 +
* Programs that use LIRC translate the button press info from {{ic|/usr/bin/lircd}} into user-defined actions according to {{ic|~/.lircrc}} or to program-specific mappings.
  
First install LIRC with pacman:
+
== Installation ==
  
# pacman -S lirc
+
[[Install]] the {{Pkg|lirc}} package.
  
This will also install the lirc-utils package as a dependency.
+
== Configuration ==
  
==Serial receivers==
+
{{Note|This section is a quick summary. Complete documentation is available [http://lirc.sourceforge.net/lirc.org/html/index.html upstream].}}
  
Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device is not connected to ttyS0, you will have to either change the module-options or [[LIRC#Building_the_LIRC_serial_module_for_another_ttySx|rebuild the LIRC module]]If your device is connected to ttyS0, you can [[LIRC#Loading|skip this step]]
+
{{ic|/etc/lirc/lircd.conf.d/foo.conf}} is the system-wide configuration translating scancodes --> keysThis directory may contain multiple conf files and each one is specific to each remote control/receiver on the system. These files are user-created config files and not directly supplied by {{Pkg|lirc}}.
  
To change the options for the lirc_serial module, you edit {{filename|/etc/modprobe.d/modprobe.conf}} and add this line:
+
The definition of scancodes to keymaps is required to allow LIRC to manage a remote.  Users have several options to obtain one.
  
options lirc_serial io=0x2f8 irq=3
+
=== Upstream provided ===
  
You should change the values after io and irq to reflect you serial port settings, the values above may work for you if you are using ttyS1 (COM2) to connect your IR-device. But you will find the correct values by checking dmesg:
+
Identify which remote/receiver is to be used and see if there is a known config for it.  One can use {{ic|irdb-get}} to search the [http://lirc-remotes.sourceforge.net/remotes-table.html remotes database] or simply browse to the URL and do the same.
  
$ dmesg | grep ttyS
+
An example using {{ic|irdb-get}} to find a config file for a Streamzap remote:
  
===Building the lirc_serial module for another ttySx===
+
$ irdb-get find stream
 
+
atiusb/atiusb.lircd.conf
Update abs
+
digital_stream/DTX9900.lircd.conf
 
+
snapstream/Firefly-Mini.lircd.conf
  # abs
+
  streamzap/PC_Remote.lircd.conf
 
+
streamzap/streamzap.lircd.conf
Copy the LIRC files to a directory you choose yourself:
+
  x10/atiusb.lircd.conf
 
+
  $ cp /var/abs/extra/system/lirc /some/dir
+
  $ irdb-get download streamzap/streamzap.lircd.conf
 
+
  Downloaded sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/streamzap/streamzap.lircd.conf as streamzap.lircd.conf
  $ cd /some/dir
 
 
 
Edit the PKGBUILD in that directory.
 
 
 
Replace the line:
 
 
 
  ./configure --enable-sandboxed --prefix=/usr \
 
    --with-driver=all \\
 
    return 1[/code]
 
 
 
with:
 
  
./configure --enable-sandboxed --prefix=/usr \
+
Once identified, copy the needed conf to {{ic|/etc/lirc/lircd.conf.d/}} to allow the daemon to initialize support for it.
    --with-driver=com2 \
 
    || return 1[/code]
 
  
Where you replace com2 with the com-port you need.
+
# cp streamzap.lircd.conf /etc/lirc/lircd.conf.d/
  
Build and install the package:
+
=== User created ===
  
$ makepkg
+
Users with unsupported hardware will need to either find a config file someone else has created (i.e. google) or create one. Creating one is fairly straightforward using {{ic|/usr/bin/irrecord}} which guides users along the needed process.  If using a detected remote, invoke it like so:
# pacman -U lirc-version.pkg.tar.gz
 
  
===Loading===
+
# irrecord --device=/dev/lirc0 MyRemote
  
Now try to load the serial module:
+
The program will instruct users to begin hitting keys on the remote in an attempt to learn it, ultimately mapping out every button and its corresponding scancode.  The process should take no more than 10 minutes.  When finished, save the resulting file to {{ic|/etc/lirc/lircd.conf.d/foo.conf}} and proceed.
  
# modprobe lirc_serial
+
{{Note|Consider sending the finished config file to the email address mentioned in the program so it can be made available to others.}}
  
If this produces an error which says your serial port is not ready, you have the problem that your serial port support is build into the kernel and not as a module (in the default arch kernel it is build into the kernel)
+
=== Optional files ===
  
If it is built into the kernel you will have to do the following (remember that it is built into the kernel, you will need to make some changes later too)
+
Depending on the application using LIRC, the following are optional.  For example, {{Pkg|mplayer}} and {{Pkg|mythtv}} use the these files to define key maps and actions.  Some other programs such as {{Pkg|kodi}} for example do not make use of this at all but do have an internal system to achieve these mappings.  Users should consult the documentation for the specific application to know if modifications to {{ic|~/.lircrc}} are needed.
  
You will have to release the serial port:
+
* {{ic|~/.lircrc}} - File containing an '''include''' statement pointing to each program's lirc map, i.e., {{ic|~/.lirc/foo}}, {{ic|~/.lirc/bar}}, etc.
 +
* {{ic|~/.lirc/foo}} - User-level config translating of keys --> actions.  Is specific to each remote and to application foo.
  
# setserial /dev/ttySx uart none
+
== Usage ==
  
(Replace x with your port number)
+
[[Start]] {{ic|lircd.service}} and [[enable]] it to run at boot time/shutdown (recommended).
  
Load the module again:
+
Test the remote using {{ic|/usr/bin/irw}}, which simply echos anything received by LIRC when users push buttons on the remote to stdout.
  
# modprobe lirc_serial
+
Example:
 
 
Now it should not show any errors, and the modules lirc_serial should be listed in lsmod
 
 
 
==USB receivers including most onboard devices==
 
This outlines the general procedure, the mceusb module which is used by many devices is used as an example.
 
 
 
# modprobe mceusb
 
 
 
Start the LIRC daemon:
 
 
 
$ /etc/rc.d/lircd start
 
 
 
Test it with irw, it will output the commands received by the IR receiver that match your {{filename|lircd.conf}} file. So start irw, point your remote and start pressing buttons.
 
  
 
  $ irw
 
  $ irw
Line 99: Line 76:
 
  000000037ff07bf2 01 Home mceusb
 
  000000037ff07bf2 01 Home mceusb
  
The above procedure however has been simplified and may not work that easily. One of the reasons the lircd daemon may not be working is because it expects to be run at startup and needs root permissions because it will create device nodes in {{filename|/dev}}. Try "man lircd" for more information.
+
If {{ic|irw}} gives no output, double check the config files in {{ic|/etc/lirc/lircd.conf.d/}} for errors.
  
Continue with [[#Making a configuration file]]
+
== Program Specific Configuration ==
  
=== Setup a HID device with LIRC ===
+
{{Merge|LIRC#Optional|or the other way around}}
Some remotes are supported in the kernel where they are treated as a keyboard and mouse.  Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC.  LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard.  As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{filename|lirc.conf}} files become standard HID devices.
 
  
Some HID remotes actually simulate a USB infrared keyboard and mouseThese remotes show up as two devices so you need to add two LIRC devices to {{filename|lircd.conf}}.
+
LIRC has the ability to allow for different programs to use the same keypress and result in unique commandsIn other words, one can setup different programs to respond differently to a given key press.
  
First we need the {{filename|/dev/input}} device for our remote:
+
* Decide which programs are to use LIRC commands.
  
  $ cat /sys/class/rc/rc0
+
{{Note|Common programs include: {{Pkg|mplayer}}, {{Pkg|mythtv}}, {{Pkg|totem}}, {{Pkg|vlc}}, and {{Pkg|kodi}} but not all programs will use this particular method to map keys.  {{Pkg|kodi}} for example, implements LIRC in a non-standard way.  Users must edit {{ic|~/.xbmc/userdata/Lircmap.xml}} which is a unique xml file, rather than the LIRC standard files the rest of the programs use.  Interested users should consult [[Kodi#Using a remote control]].}}
  
One of the files should be input''#'', where the number matches the event''#'' of the device.  (To clarify you can check that directory, it will have an event''#'' file.
+
* Create the expected files showing LIRC where the various program-specific maps reside:
  
{{Note|If you have more than one ir device then there may be multiple directories under {{filename|/sys/class/rc}}Under event''#'' <code>cat name</code> to verify which device you are looking at.}}
+
$ mkdir ~/.lirc
 +
  $ touch ~/.lircrc
  
then go to {{filename|/dev/input/by-id}}
+
* Populate {{ic|~/.lirc}} with the program specific config files named for each program.
  
  $ ls -l /dev/input/by-id
+
Example:
  
You should find a file that symlinks to the input''#'' above, and possibly others with a similar names for mouse events.
+
$ ls ~/.lirc
 +
mplayer
 +
mythtv
 +
vlc
  
  lrwxrwxrwx 1 root root  9 10月 14 06:43 usb-3353_3713-event-if00 -> ../event9
+
{{Tip|Many pre-made files unique to each remote/program are available via googling. Providing an exhaustive listing of keymaps for each program is beyond the scope of this article.}}
  lrwxrwxrwx 1 root root 10 10月 14 06:43 usb-3353_3713-event-if01 -> ../event10
 
  
Here 'usb-3353_3713-event-if00' and 'usb-3353_3713-event-if01' are the Linux input device event for our HID device, one for the keyboard, another for the mouse.
+
* Edit {{ic|~/.lircrc}} to contain an '''include''' statement pointing to {{ic|~/.lirc/foo}} and repeat for each program that is to be controlled by LIRC.
  
Then, we need to edit {{filename|/etc/conf.d/lircd.conf}}.  This file contains the parameters for LIRC daemon
+
Example:
 
+
{{hc|~/.lircrc|
  #
+
include "~/.lirc/mplayer"
  #Parameters for daemon
+
include "~/.lirc/mythtv"
  #
+
include "~/.lirc/vlc"
 
+
}}
  LIRC_DEVICE="/dev/input/by-id/usb-3353_3713-event-if00"
 
  LIRC_DRIVER="devinput"
 
  LIRC_EXTRAOPS=""
 
  LIRC_CONFIGFILE="/etc/lirc/lircd.conf"
 
 
 
{{Note|Here we set up a LIRC device with the id 3353_3713, you should replace it with your own device input event name, whatever it is.}}
 
 
 
The latest version of the config file for HID remotes exists in the LIRC git repository [http://lirc.git.sourceforge.net/git/gitweb.cgi?p=lirc/lirc;a=blob_plain;f=remotes/devinput/lircd.conf.devinput;hb=HEAD].  Simply save it as {{filename|/etc/lirc/lircd.conf}}.
 
 
 
In order to launch the LIRC daemon for HID remote, You must enable evdev module first
 
# modprobe evdev
 
 
 
{{Note|LIRC 0.8.6 has changed the default socket location from {{filename|/dev/lircd}} to {{filename|/var/run/lirc/lircd}}, but many applications still look for the socket in the old location. Since lirc-utils 0.8.6-3 the {{filename|/etc/rc.d/lircd}} script creates a symlink from {{filename|/dev/lircd}} to the {{filename|/var/run/lirc/lircd}} socket when it starts the lircd daemon and removes the link when the daemon is stopped.}}
 
 
 
==Making a configuration file==
 
 
 
You need a configuration file for your remote control copied or symlinked to {{filename|/etc/lirc/lircd.conf}}. A number of devices have already been included with the lirc package, they can be found in {{filename|/usr/share/lirc/remotes}}. If your specific device is not included, the LIRC site offers configuration files for a large number of extra [http://lirc.sourceforge.net/remotes/ devices].
 
 
 
If your device does not already have a config file, you can create it yourself with the command:
 
 
 
# irrecord -d /dev/lirc0 /tmp/my_remote
 
 
 
Just follow the instructions. The resulting file, {{filename|/tmp/my_remote}}, should then be copied to {{filename|/etc/lirc/lircd.conf}}. If you want to use several remotes, you repeat the irrecord step with each remote and different filenames, and then concatenate all the resulting files into {{filename|/etc/lirc/lircd.conf}}:
 
 
 
# cat /tmp/my_remote /tmp/my_remote2 /tmp/my_remote3 > /etc/lirc/lircd.conf
 
 
 
{{Note|As of lirc-0.8.6 the default location of lircd, lircmd and lircrcd config files was moved to {{filename|/etc/lirc/lircd.conf}}, {{filename|/etc/lirc/lircmd.conf}} and {{filename|/etc/lirc/lircrc}}. If the config files are not found in that location, they are still searched at the old location in {{filename|/etc/.}}}}
 
 
 
===Testing===
 
 
 
First start the lircd daemon:
 
 
 
# /etc/rc.d/lircd start
 
 
 
A good way to see if LIRC is running is to run irw.
 
 
 
$ irw
 
 
 
When you press a button, you should see something like this:
 
 
 
0000000000000001 00 play sony2
 
0000000000000001 01 play sony2
 
0000000000000001 02 play sony2
 
0000000000000001 03 play sony2
 
 
 
In this case the remote is called sony2, the button is called play, and LIRC has seen it 4 times.
 
 
 
==Run LIRC at bootup==
 
 
 
Remember if you had to execute the setserial command while [[LIRC#Loading|loading]] the module?
 
 
 
If so, [[LIRC#Your serial port support is compiled into the kernel|your serial port support is compiled into the kernel]]
 
 
 
===Your serial port support is compiled as a module in the kernel===
 
 
 
This is rather easy: you will just have to add lirc_serial to the modules list and lircd to the daemons list in {{filename|/etc/rc.conf}}
 
 
 
===Your serial port support is compiled into the kernel===
 
 
 
This is more complicated, you cannot just add the lirc_serial to the modules list in {{filename|/etc/rc.conf}}, as the serial port should be released first.
 
 
 
So I created a custom startup script to fix this problem.
 
 
 
{{file|name=/etc/rc.d/start_lirc|content=<nowiki>
 
#!/bin/bash
 
#/etc/rc.d/start_lirc
 
#releases ttySx and loads lirc_serial module
 
 
. /etc/rc.conf
 
. /etc/rc.d/functions
 
 
case "$1" in
 
  start)
 
    stat_busy "release ttySx"
 
    setserial /dev/ttySx uart none
 
    #load lirc module
 
    modprobe lirc_serial
 
    stat_done
 
    ;;
 
  stop)
 
    stat_busy "unload lirc module"
 
    rmmod lirc_serial
 
    stat_done
 
    ;;
 
  restart)
 
    $0 stop
 
    $0 start
 
    ;;
 
  *)
 
    echo "usage: $0 {start|stop|restart}"
 
esac
 
exit 0
 
</nowiki>}}
 
 
 
Now load the daemons: add "start_lirc" and "lircd" to the daemons list in {{filename|/etc/rc.conf}}
 
 
 
==Program specific configuration==
 
 
 
===Generate your own lircrc with Mythbuntu's lircrc-generator===
 
 
 
'''mythbuntu-lircrc-generator''' is intended to be started from a system with LIRC installed. It requires that you  choose a remote via the LIRC package or have a {{filename|lircd.conf}} handy prior to running. It will then produce a sane {{filename|.lircrc}} for the current user.
 
 
 
[http://aur.archlinux.org/packages.php?ID=33849 Mythbuntu's Lirc/Lircrc Generator is available on AUR]<br/>
 
[http://manpages.ubuntu.com/manpages/intrepid/man1/mythbuntu-lirc-generator.1.html Man page]
 
 
 
===Enable LIRC support in xine===
 
 
 
Now LIRC works, but you have no program that can communicate with LIRC.  This section will explain how to make xine work, but you can use xmms and mplayer (and probably a lot of other programs too) to work with LIRC.
 
 
 
====Compile xine with LIRC support====
 
Download the xine-ui [http://cvs.archlinux.org/cgi-bin/viewcvs.cgi/*checkout*/multimedia/xine-ui/PKGBUILD?rev=HEAD&cvsroot=Current&only_with_tag=CURRENT&content-type=text/plain pkgbuild]{{Linkrot|2011|09|05}} from the cvs tree.
 
 
 
Add " --enable-lirc" to the {{filename|./configure}} line
 
 
 
Compile:
 
 
 
$ makepkg
 
 
 
Uninstall old xine-ui and install the new one
 
 
 
# pacman -R xine-ui
 
# pacman -U xine-filename.pkg.tar.gz
 
 
 
====Configure xine to use LIRC====
 
 
 
Let xine produce a default {{filename|.lircrc}} file.  In your home directory, type:
 
 
$ xine --keymap=lirc>.lircrc
 
 
 
Now, in order to have a functioning xine+lirc, edit the {{filename|.lircrc}} file to your preferences.
 
 
 
However, you may choose to configure LIRC to control more than just xine. If this is the case, you will need to manually edit the {{filename|.lircrc}} file, and add elements.
 
 
 
Xine-ui
 
Mplayer
 
Totem
 
Vlc
 
Rhythmbox
 
 
 
All work with LIRC, but you must enable LIRC support in the program in some cases, such as VLC. Simply copy the vlc packagebuild and edit it so that "--enable-lirc" is one of the compile options for VLC not FFMPEG!
 
 
 
===Configure Amarok2 to use LIRC===
 
 
 
Depending on your controller model, the following configuration works with Amarok2-svn. This configuration file will work with the MCEUSB controller.
 
 
 
{{File|name=~/.lircrc|content=##amarok2
 
 
 
begin
 
button = Play
 
prog  = irexec
 
repeat = 0
 
config = qdbus org.mpris.amarok /Player Play
 
end
 
 
 
begin
 
button = Pause
 
prog  = irexec
 
repeat = 0
 
config = qdbus org.mpris.amarok /Player Pause
 
end
 
 
 
begin
 
button = Stop
 
prog  = irexec
 
repeat = 0
 
config = qdbus org.mpris.amarok /Player Stop
 
end
 
 
 
begin
 
button = Skip
 
prog  = irexec
 
repeat = 0
 
config = qdbus org.mpris.amarok /Player Next
 
end
 
 
 
begin
 
button = Replay
 
prog  = irexec
 
repeat = 0
 
config = qdbus org.mpris.amarok /Player Prev
 
end}}
 
 
 
===Configure Audacious(2) to use LIRC===
 
Depending on your controller model, the following configuration works with all versions of Audacious, including the mercurial builds. This configuration file will work with the MCEUSB controller.
 
 
 
{{File|name=~/.lircrc|content=##audacious
 
 
 
begin
 
    prog = audacious
 
    button = Play
 
    config = PLAY
 
    repeat = 0
 
end
 
 
 
begin
 
    prog = audacious
 
    button = Pause
 
    config = PAUSE
 
    repeat = 0
 
end
 
  
begin
+
== Troubleshooting ==
    prog = audacious
 
    button = Stop
 
    config = STOP
 
    repeat = 0
 
end
 
  
begin
+
=== Remote functions as a keyboard ===
    prog = audacious
+
==== When using Xorg ====
    button = Skip
 
    config = NEXT
 
    repeat = 0
 
end
 
  
begin
+
Xorg detects some remotes, such as the Streamzap USB PC Remote, as a Human Interface Device (HID) which means some or all of the keys will show up as  key strokes as if entered from the physical keyboard.  This behavior will present problems if LIRC is to be used to manage the device. 
    prog = audacious
+
To disable, create the following file and restart X:
    button = Replay
 
    config = PREV
 
    repeat = 0
 
end
 
  
begin
+
{{hc|/etc/X11/xorg.conf.d/90-streamzap.conf|
    prog = audacious
+
Section "InputClass"
    button = VolUp
 
    config = VOL_UP
 
    repeat = 1
 
end
 
 
 
begin
 
    prog = audacious
 
    button = VolDown
 
    config = VOL_DOWN
 
    repeat = 1
 
end}}
 
 
 
Additionally, there are other values that may be set according to the model set forth above. This was taken from the lirc.c file from audacious-plugins source code:
 
 
 
{{File|name=lirc.c|content=PLAY
 
STOP
 
PAUSE
 
PLAYPAUSE
 
NEXT
 
PREV
 
SHUFFLE
 
REPEAT
 
FWD
 
BWD
 
VOL_UP
 
VOL_DOWN
 
QUIT
 
MUTE
 
BAL_LEFT
 
BAL_RIGHT
 
BAL_CENTER
 
LIST
 
PLAYLIST_CLEAR
 
PLAYLIST_ADD}}
 
 
 
==Device Specific Examples==
 
=== X10 ===
 
There is a dedicated wiki page with information about [[X10]]
 
 
 
===Asus DH Deluxe series motherboard===
 
Check the output of:
 
<pre>$ cat /dev/usb/hiddevX</pre>
 
 
 
where X is 0,1 or bigger, and press some buttons on remote.
 
If you can see reply, device works fine, follow steps:<br>
 
 
 
1. In file {{filename|/etc/conf.d/lircd.conf}} add:<br>
 
<pre>LIRC_DRIVER="dvico"</pre>
 
2. Reload LIRC:
 
<pre>/etc/rc.d/lircd restart</pre>
 
 
 
===ASRock ION series (Nuvoton) quickstart===
 
 
 
$ ln -s /usr/share/lirc/remotes/lirc_wb677/lircd.conf.wb677 /etc/lirc/lircd.conf
 
$ /etc/rc.d/lircd restart
 
 
 
===Streamzap PC Remote (USB)===
 
{{Note|Xorg now auto recognizes this remote as a keybaord!}}
 
To disable this behavior, add the following to {{Filename|/etc/X11/xorg.conf.d/90-streamzap.conf}}:
 
<pre>Section "InputClass"
 
 
   Identifier "Ignore Streamzap IR"
 
   Identifier "Ignore Streamzap IR"
 
   MatchProduct "Streamzap"
 
   MatchProduct "Streamzap"
 
   MatchIsKeyboard "true"
 
   MatchIsKeyboard "true"
 
   Option "Ignore" "true"
 
   Option "Ignore" "true"
EndSection</pre>
+
EndSection}}
  
#Install both packages (lirc lirc-utils)
+
Do not forget to alter the {{ic|MatchProduct}} property according to one shown in {{ic|Name}} from output of
#Modprobe both kernel mods (lirc_dev and streamzap) (add these to your MODULES array in {{filename|/etc/rc.conf}} to survive a reboot)
+
$ cat /proc/bus/input/devices | grep -e IR
#Create your {{filename|/etc/lirc/lircd.conf}} (for this remote, copy {{filename|/usr/share/lirc/remotes/streamzap/lircd.conf.streamzap}} to {{filename|/etc/lirc/lircd.conf}})
+
For example {{ic|WinFast}} for {{ic|<nowiki>N: Name="cx88 IR (WinFast DTV2000 H rev."</nowiki>}}
#Start lircd via /etc/rc.d/lircd start (add lircd to your DAEMONS array in {{filename|/etc/rc.conf}} to survive a reboot)
 
#Test the remote/lirc with irw
 
  
$ irw
+
==== On an ARM device not using Xorg ====
00000000000028cc 00 CH_UP Streamzap_PC_Remote
+
Blacklist the offending modules by creating {{ic|/etc/modprobed.d/streamzap.conf}} to suppress this behavior. An example is provided for the Streamzap remote.
00000000000028ce 00 CH_DOWN Streamzap_PC_Remote
+
  install ir_sharp_decoder /bin/false
00000000000028c8 00 8 Streamzap_PC_Remote
+
  install ir_xmp_decoder /bin/false
00000000000028c5 00 5 Streamzap_PC_Remote
+
  install ir_rc5_decoder /bin/false
00000000000028d2 00 OK Streamzap_PC_Remote
+
  install ir_nec_decoder /bin/false
00000000000028d1 00 LEFT Streamzap_PC_Remote
+
  install ir_sony_decoder /bin/false
  00000000000028d1 01 LEFT Streamzap_PC_Remote
+
  install ir_mce_kbd_decoder /bin/false
  00000000000028d1 00 LEFT Streamzap_PC_Remote
+
  install ir_jvc_decoder /bin/false
  00000000000028d3 00 RIGHT Streamzap_PC_Remote
+
  install ir_rc6_decoder /bin/false
  00000000000028d3 00 RIGHT Streamzap_PC_Remote
+
  install ir_sanyo_decoder /bin/false
  00000000000028d3 00 RIGHT Streamzap_PC_Remote
 
  00000000000028d3 00 RIGHT Streamzap_PC_Remote
 
  00000000000028d4 00 DOWN Streamzap_PC_Remote
 
  00000000000028d4 00 DOWN Streamzap_PC_Remote
 
  00000000000028d4 00 DOWN Streamzap_PC_Remote
 
  
{{Note|When the batteries in this remote are low, it may stop working even though the red LED on the received still flashes when you hit buttons!}}
+
=== Changing default configuration ===
  
==Troubleshooting==
+
Users not getting any output from {{ic|irw}} may have the default configuration in {{ic|/etc/lirc/lirc_options.conf}} incorrectly setup (or might have been overwritten by an update).
  
===Buttons processed several times when pressed===
+
First, check if {{ic|/dev/lirc0}} is present:
Problem in module ir_core which processes IR commands with LIRC at the same time. Simply blacklist it by creating the following file:
 
  
{{file|name=/etc/modprobe.d/remote_blacklist.conf|content=
+
$ mode2 --driver default --device /dev/lirc0
# Prevent processing button several times when pressed
 
blacklist ir_core
 
}}
 
  
 +
Watch the output while pressing buttons on the remote. If output is present, edit {{ic|/etc/lirc/lirc_options.conf}} changing the  '''driver''' and '''device''' appropriately.
  
If you use an MCEUSB remote [http://web.archiveorange.com/archive/v/Xn95HB4UeE0buA5Py0S4 this] bug could also cause most presses to be registered twice. Confirm with:
+
If no output is presented, the task becomes locating the correct driver/device combination. First check what combination lirc detected by default. Run {{ic|ir-keytable}} from the {{Pkg|v4l-utils}} package. and check the output. It will look similar to this:
  
<pre>
+
  Found /sys/class/rc/rc0/ (/dev/input/event5) with:
echo none +lirc > /sys/class/rc/rc0/protocols
+
        Driver ite-cir, table rc-rc6-mce
</pre>
+
        Supported protocols: unknown other lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 sharp xmp
 +
        Enabled protocols: lirc
 +
        Extra capabilities: <access denied>
  
This fix, however, is wiped at boot. Fix this by either adding the line to an /etc/rc.d/ script (I use lircd) or write another one that is called at boot time.
+
In this case, lirc automatically detected {{ic|/dev/input/event5}} as the IR device, which uses the {{ic|devinput}} driver. Check if this combination is working by running:
  
Note that any changes to an existing /etc/rc.d init script might be overwritten when the packages providing them are updated or removed.
+
$ mode2 --driver devinput --device /dev/input/event5
  
===After upgrading or installing Arch, an existing configuration stopped working===
+
Now try pressing buttons on the remote. If there is no output, try different driver and device combinations.  Once a working combination has been identified, change '''driver''' and '''device''' in {{ic|/etc/lirc/lirc_options.conf}} appropriately.
====Kernel module change====
 
As of kernel 2.6.36, LIRC modules have been included in the kernel. Arch's ''lirc'' package has included the older kernel modules, which work with ''lircd'' without any additional configuration. However, a recent update removed those older modules, which results in the stock kernel modules being used. Unfortunately, these kernel modules treat the remote as a keyboard by default, which is incompatible for lircd. To correct this, put the following line to {{filename|/etc/rc.local}}:
 
{{File|name=/etc/rc.local|content=echo lirc > /sys/class/rc/rc0/protocols}}
 
You may also run that command as root to enable LIRC for your current session.
 
  
{{Note|It is also a good idea to remove the old LIRC kernel module from your MODULES array in {{filename|/etc/rc.conf}}, as it is no longer present.}}
+
==== Example ====
  
==External Resources==
+
An example configuration for a MCE RC6 compatible receiver:
http://www.mythtv.org/wiki/Category:Remote_Controls -- MythTV wiki main LIRC article
+
{{hc|/etc/lirc/lirc_options.conf|2=[lircd]
 +
nodaemon        = False
 +
driver          = default
 +
device          = /dev/lirc0
 +
output          = /var/run/lirc/lircd
 +
pidfile        = /var/run/lirc/lircd.pid
 +
plugindir      = /usr/lib/lirc/plugins
 +
permission      = 666
 +
allow-simulate  = No
 +
repeat-max      = 600
  
http://www.mythtv.org/wiki/MCE_Remote -- MythTV wiki on MCE remotes
+
[lircmd]
 +
uinput          = False
 +
nodaemon        = False
 +
}}
  
http://en.gentoo-wiki.com/wiki/LIRC -- Gentoo wiki LIRC how-to
+
== See also ==
  
http://aur.archlinux.org/packages.php?ID=33849 -- Lirc/Lircrc Configuration Generator
+
* [http://lirc.sourceforge.net/lirc.org/html/index.html Upstream documentation]
 +
* [http://lirc-remotes.sourceforge.net/remotes-table.html Remotes database]
 +
* [http://sf.net/p/lirc Project site]
 +
* [http://lirc.org/html/configuration-guide.html Upstream Configuration Guide]
 +
* [http://www.mythtv.org/wiki/Category:Remote_Controls MythTV Wiki:Remotes article]
 +
* [http://lirc-remotes.sourceforge.net/remotes-table.html Official list of supported hardware]
 +
* [https://github.com/graysky2/streamzap Linux Streamzap config files]

Latest revision as of 13:57, 18 September 2017

This article covers setup and usage of LIRC "Linux Infrared Remote Control" with serial or USB infrared devices.

LIRC is a daemon that can translate key presses on a supported remote into program specific commands. In this context, the term, "program specific" means that a key press can do different things depending on which program is running and taking commands from LIRC.

  • User hits a button on the remote causing it to transmit an IR or RF signal.
  • The signal is received by the receiver connected to the Linux box.
  • The kernel (via the correct module) use presents pulse data from the remote on a device like /dev/lirc0, /dev/input/eventX, /dev/ttyUSBX or /dev/ttyS0.
  • /usr/bin/lircd uses the information from /etc/lirc/lircd.conf.d/foo.conf to convert the pulse data into button press information.
  • Programs that use LIRC translate the button press info from /usr/bin/lircd into user-defined actions according to ~/.lircrc or to program-specific mappings.

Installation

Install the lirc package.

Configuration

Note: This section is a quick summary. Complete documentation is available upstream.

/etc/lirc/lircd.conf.d/foo.conf is the system-wide configuration translating scancodes --> keys. This directory may contain multiple conf files and each one is specific to each remote control/receiver on the system. These files are user-created config files and not directly supplied by lirc.

The definition of scancodes to keymaps is required to allow LIRC to manage a remote. Users have several options to obtain one.

Upstream provided

Identify which remote/receiver is to be used and see if there is a known config for it. One can use irdb-get to search the remotes database or simply browse to the URL and do the same.

An example using irdb-get to find a config file for a Streamzap remote:

$ irdb-get find stream
atiusb/atiusb.lircd.conf
digital_stream/DTX9900.lircd.conf
snapstream/Firefly-Mini.lircd.conf
streamzap/PC_Remote.lircd.conf
streamzap/streamzap.lircd.conf
x10/atiusb.lircd.conf

$ irdb-get download streamzap/streamzap.lircd.conf 
Downloaded sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/streamzap/streamzap.lircd.conf as streamzap.lircd.conf

Once identified, copy the needed conf to /etc/lirc/lircd.conf.d/ to allow the daemon to initialize support for it.

# cp streamzap.lircd.conf /etc/lirc/lircd.conf.d/

User created

Users with unsupported hardware will need to either find a config file someone else has created (i.e. google) or create one. Creating one is fairly straightforward using /usr/bin/irrecord which guides users along the needed process. If using a detected remote, invoke it like so:

# irrecord --device=/dev/lirc0 MyRemote

The program will instruct users to begin hitting keys on the remote in an attempt to learn it, ultimately mapping out every button and its corresponding scancode. The process should take no more than 10 minutes. When finished, save the resulting file to /etc/lirc/lircd.conf.d/foo.conf and proceed.

Note: Consider sending the finished config file to the email address mentioned in the program so it can be made available to others.

Optional files

Depending on the application using LIRC, the following are optional. For example, mplayer and mythtv use the these files to define key maps and actions. Some other programs such as kodi for example do not make use of this at all but do have an internal system to achieve these mappings. Users should consult the documentation for the specific application to know if modifications to ~/.lircrc are needed.

  • ~/.lircrc - File containing an include statement pointing to each program's lirc map, i.e., ~/.lirc/foo, ~/.lirc/bar, etc.
  • ~/.lirc/foo - User-level config translating of keys --> actions. Is specific to each remote and to application foo.

Usage

Start lircd.service and enable it to run at boot time/shutdown (recommended).

Test the remote using /usr/bin/irw, which simply echos anything received by LIRC when users push buttons on the remote to stdout.

Example:

$ irw
000000037ff07bfe 00 One mceusb
000000037ff07bfd 00 Two mceusb
000000037ff07bfd 01 Two mceusb
000000037ff07bf2 00 Home mceusb
000000037ff07bf2 01 Home mceusb

If irw gives no output, double check the config files in /etc/lirc/lircd.conf.d/ for errors.

Program Specific Configuration

Merge-arrows-2.pngThis article or section is a candidate for merging with LIRC#Optional.Merge-arrows-2.png

Notes: or the other way around (Discuss in Talk:LIRC#)

LIRC has the ability to allow for different programs to use the same keypress and result in unique commands. In other words, one can setup different programs to respond differently to a given key press.

  • Decide which programs are to use LIRC commands.
Note: Common programs include: mplayer, mythtv, totem, vlc, and kodi but not all programs will use this particular method to map keys. kodi for example, implements LIRC in a non-standard way. Users must edit ~/.xbmc/userdata/Lircmap.xml which is a unique xml file, rather than the LIRC standard files the rest of the programs use. Interested users should consult Kodi#Using a remote control.
  • Create the expected files showing LIRC where the various program-specific maps reside:
$ mkdir ~/.lirc
$ touch ~/.lircrc
  • Populate ~/.lirc with the program specific config files named for each program.

Example:

$ ls ~/.lirc
mplayer
mythtv
vlc
Tip: Many pre-made files unique to each remote/program are available via googling. Providing an exhaustive listing of keymaps for each program is beyond the scope of this article.
  • Edit ~/.lircrc to contain an include statement pointing to ~/.lirc/foo and repeat for each program that is to be controlled by LIRC.

Example:

~/.lircrc
include "~/.lirc/mplayer"
include "~/.lirc/mythtv"
include "~/.lirc/vlc"

Troubleshooting

Remote functions as a keyboard

When using Xorg

Xorg detects some remotes, such as the Streamzap USB PC Remote, as a Human Interface Device (HID) which means some or all of the keys will show up as key strokes as if entered from the physical keyboard. This behavior will present problems if LIRC is to be used to manage the device. To disable, create the following file and restart X:

/etc/X11/xorg.conf.d/90-streamzap.conf
Section "InputClass"
  Identifier "Ignore Streamzap IR"
  MatchProduct "Streamzap"
  MatchIsKeyboard "true"
  Option "Ignore" "true"
EndSection

Do not forget to alter the MatchProduct property according to one shown in Name from output of

$ cat /proc/bus/input/devices | grep -e IR

For example WinFast for N: Name="cx88 IR (WinFast DTV2000 H rev."

On an ARM device not using Xorg

Blacklist the offending modules by creating /etc/modprobed.d/streamzap.conf to suppress this behavior. An example is provided for the Streamzap remote.

install ir_sharp_decoder /bin/false
install ir_xmp_decoder /bin/false
install ir_rc5_decoder /bin/false
install ir_nec_decoder /bin/false
install ir_sony_decoder /bin/false
install ir_mce_kbd_decoder /bin/false
install ir_jvc_decoder /bin/false
install ir_rc6_decoder /bin/false
install ir_sanyo_decoder /bin/false

Changing default configuration

Users not getting any output from irw may have the default configuration in /etc/lirc/lirc_options.conf incorrectly setup (or might have been overwritten by an update).

First, check if /dev/lirc0 is present:

$ mode2 --driver default --device /dev/lirc0

Watch the output while pressing buttons on the remote. If output is present, edit /etc/lirc/lirc_options.conf changing the driver and device appropriately.

If no output is presented, the task becomes locating the correct driver/device combination. First check what combination lirc detected by default. Run ir-keytable from the v4l-utils package. and check the output. It will look similar to this:

 Found /sys/class/rc/rc0/ (/dev/input/event5) with:
       Driver ite-cir, table rc-rc6-mce
       Supported protocols: unknown other lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 sharp xmp
       Enabled protocols: lirc
       Extra capabilities: <access denied>

In this case, lirc automatically detected /dev/input/event5 as the IR device, which uses the devinput driver. Check if this combination is working by running:

$ mode2 --driver devinput --device /dev/input/event5

Now try pressing buttons on the remote. If there is no output, try different driver and device combinations. Once a working combination has been identified, change driver and device in /etc/lirc/lirc_options.conf appropriately.

Example

An example configuration for a MCE RC6 compatible receiver:

/etc/lirc/lirc_options.conf
[lircd]
nodaemon        = False
driver          = default
device          = /dev/lirc0
output          = /var/run/lirc/lircd
pidfile         = /var/run/lirc/lircd.pid
plugindir       = /usr/lib/lirc/plugins
permission      = 666
allow-simulate  = No
repeat-max      = 600

[lircmd]
uinput          = False
nodaemon        = False

See also