Next Previous Contents

8. Setting up a remote control.

MythTV does not have native remote control receiver and decoder software built-in. Instead, remote control functions are implemented by cooperating with lirc, the Linux Infrared Remote Control program. lirc handles the IR hardware and passes keystrokes to MythTV, which then acts as if the user had pressed the keys on the keyboard. The file keys.txt describes the keys used to control MythTV.

Compilation of lirc is outside the scope of this document.

You can dispense with lirc altogether by purchasing an IR keyboard and a learning remote control. The IR keyboard receiver plugs into your PC and you would train your learning remote to emulate the various keystrokes from keys.txt of your IR keyboard. Using this method removes lirc entirely from the picture - your remote will be sending keypresses that your PC "sees" on the keyboard port.

The "Big Picture" for lirc is that there are a few different things that fit together.

First, lirc has a portion which is connected to an IR receiver. The IR receiver senses the pulses and sends them to the lirc daemon. The lircd loads a file called lircd.conf which instructs it how interpret the IR pulses that it received and convert them to a human-readable name.

For example, the hardware may receive pulses may correlate to "Channel Up". The lircd.conf file will then contain a line that looks something like this:

          ChannelUp                0x0000000000001020

The lircd.conf file can have multiple remote controls defined.

The second part is lircrc, which takes the name of the button which was pressed ("ChannelUp") in the above example, and associates that to an action to be performed by a program using the remote control. So in MythTV, ChannelUp means one thing, while in mplayer it means something different. lircrc gives you the flexibility of taking the name of the button and having it perform different actions depending on which program you're using at the time.

NOTE: The definitions in lircd.conf come from the user community, and there is no standard for the common button names. One lircd.conf file may contain a definition for a button called "ChannelUp", while another may contain a definition for "Chan+". Your lircrc file must therefore be configured appropriately, or it won't work.

Look for pre-made lircd.conf configuration files at http://lirc.sourceforge.net/remotes/. If you find one of your remotes either on the website or on your system, download or copy the file, name it lircd.conf and put it in your /etc directory. If you couldn't find your remote, you must make your own lircd.conf file.

To make your own lircd.conf file

$ irrecord myremote

Follow the on-screen directions to train your remote and define keys. If your remote ends up working well, you should consider submitting your lircd.conf file back to the lirc developers. Once finished:

$ su
# cp myremote /etc/lircd.conf

now try to start lircd again:

# /usr/local/sbin/lircd

This takes care of the lircd portion, which "listens" for the IR signals. If everything went well, the install script for lircd put an appropriate configuration file for your remote into /etc/lircd.conf This file maps the buttons on the remote control to the IR pulses coming from the receiver.

The next step is to convert those signals into something that can be used to control MythTV. MythTV now includes native support for lirc and can interact directly with it.

$ cd mythtv/contrib/config_files/lirc
$ cp lircrc.example ~/.lircrc
or
$ cp lircrc.example.pinnaclestudiopctv ~/.lircrc
if you've got a Pinnacle Studio PCTV remote.
$ irw
Start pressing the keys on your remote; irw will print the name of the button as it is defined in your /etc/lircd.conf. If you don't see anything at this point, you need to troubleshoot further by going back to the lirc home page and investigating from there.

If it is working, then press CTRL-C to abort the program. Once you know that your remote is working, you can either recompile MythTV with native lirc support by enabling it in configure or you need to run the irxevent program, which takes the key presses and sends them to MythTV. If you use native lirc support, you don't need to run irxevent. If you are going to use irxevent, then you need to run it like this:

$ irxevent &
If irxevent isn't running, then MythTV will not respond to your remote control unless you're using native lirc support.

8.1 Additional information for lirc

Take a look at the lircrc.example files in the contrib/configfiles/ directory. In my case, (Pinnacle Studio card) the channel up and down functions weren't working, due to the fact that the button names were different than the default lircrc.example file that came with MythTV.

The lircrc.example file has this:

begin
    prog = irxevent
    button = ChannelUp
    config = Key Up CurrentWindow
end

begin
    prog = irxevent
    button = ChannelDown
    config = Key Down CurrentWindow
end
but the /etc/lircd.conf that comes in the lircd package defines the buttons for the Pinnacle Studio PCTV as:
          channel+                 0x0000000000000017
          channel-                 0x000000000000001C
rather than "ChannelUp" and "ChannelDown". I added the following to my /home/[yourusername]/.lircrc file:
begin
    prog = irxevent
    button = channel+
    repeat = 3
    config = Key Up CurrentWindow
end

begin
    prog = irxevent
    button = channel-
    repeat = 3
    config = Key Down CurrentWindow
end
which took care of basic functionality. Because the PCTV Studio remote has additional buttons, look at the contrib/config_files/lirc/lircrc.example.pinnaclestudiopctv for an example of how to define additional buttons, and how to debug potential button name conflicts between the lircrc.example file and how your remote defines the button names.

By examining the button names defined in /etc/lircd.conf and using the irw program to make sure that your remote is working, you can create the appropriate mappings in .lircrc to get excellent remote functionality with MythTV.

Note the repeat = parameter. This informs the irxevent program to pass through every third keypress. By default, lirc will only send one keypress to the application, even if you're holding down the key. The actual repeat = number will vary from system to system, so experiment and see which value works best for you.


Next Previous Contents