MiniMyth from minimyth.org
LIRC devinput: Using a remote control that appears as keyboard
Introduction

Some remote controls appear as keyboard devices rather than remote control devices. Specifically, they appear as one or more event input devices. MiniMyth can treat an event input device as either a remote (handled by LIRC) or a keyboard (handled by Xorg). Because MiniMyth is better integrated and tested with LIRC than with Xorg as input, I believe that it is better to treat these event input devices as remotes rather than keyboards.

Remote Controls that Generate Media Center Edition Keyboard Shortcuts

One family of remote controls that appear as keyboard devices is the family of remote controls that generate Media Center Edition keyboard shortcuts rather than remote codes. MiniMyth has built-in support for this family of remote controls. However, your remote control must be auto-detected by MiniMyth for it to work.

If you have one of these remotes but MiniMyth does not detect it, then please let us know the remote control vendor and model, the output of 'lsusb' with the remote control connected, and the output of 'cat /proc/bus/input/devices' with the remote control connected.

Configuration

If your remote control is not already known to MiniMyth and does not generate Media Center Edition keyboard shortcuts, then treating it as a remote will require some manual configuration. Specifically, you will need to provide MiniMyth with the name of the LIRC driver that handles event input devices, the path to the event input device that corresponds to your remote control, the 'lircd.conf' file that maps remote control key presses to key names, and (if needed) the 'lircrc' file that maps key names to per-application actions.

LIRC handles input event devices such as keyboards using the devinput driver. You can configure LIRC to use the devinput driver by adding MM_LIRC_DRIVER='devinput' to your MiniMyth configuration file.

In order to provide LIRC with the path to the event input device that corresponds to your remote control, you must determine the path. You can determine the event input device that corresponds to your remote control by connecting to your MiniMyth system as user 'root' using either telnet or ssh and looking at the output of the command

cat /proc/bus/input/devices

In this output, each input device has a separate record. Each record is separated by a blank line and each field is on its own line. You should be able to recognize the record(s) associated with your device by looking at the name field (the field that starts with 'N:'). If your device is recognized as a keyboard event input device, then the handler field (the field that starts with 'H:') will contain the entries 'kbd' and 'eventX', where X is a number. The 'eventX' corresponds to the remote control's device file system entry '/dev/input/eventX'. Therefore, your can configure LIRC to use the device associated with your remote control by adding MM_LIRC_DEVICE='/dev/input/eventX' to your MiniMyth configuration file.

In order to provide MiniMyth with an 'lircd.conf' file that maps remote control key presses to key names, you must determine the mapping. Determining the mapping is two step process: (1) use the standard keyboard map (which is built-in to MiniMyth) to determine the standard key name(s) that are generated when a key is pressed, and (2) modify the standard keyboard map so that the key name that is generated corresponds to the key pressed.

In order to accomplish step (1), start by rebooting your MiniMyth system. If all goes well, lircd should start. You can check that it started by connecting to your MiniMyth system as user 'root' using either telnet or ssh and running the command

ps x ocmd | grep lircd

If 'lircd' is running, then you should see the output

/usr/sbin/lircd --device=/dev/input/eventX --driver=devinput ..

In addition, it is a good idea to stop mythfrontend (or mythwelcome) so that the remote key presses do not confuse mythfrontend (or mythwelcome), You can stop mythfrontend (or mythwelcome) by connecting to your MiniMyth system as user 'root' using either telnet or ssh and running the command

mm_command x_stop

Now, you can determine the standard key name(s) that are generated when a key is pressed. You can do this by connecting to your MiniMyth system as user 'root' using either telnet or ssh, running the command

irw

successively pressing each key on the remote control and noting the output. When you press a remote control key, you should see a output that has the form

0000000000010039 00 KEY_SPACE devinput

The key name is the word to the left of 'devinput'. In the above example, the key name is 'KEY_SPACE'.

Most remote controls that appear as keyboards will generate one key name output per key press. However, some remote controls (such as remote controls that output Media Center Edition keyboard shortcuts) may generate multiple key name outputs per key press. If none of the keys on your remote control generates more than one key name output per key press, then you will only need to create a custom 'lircd.conf' file. If some of the keys on your remote control generate more than one key name output per key press, then you will need to create a custom 'lircd.conf' file and a custom 'lircrc' file.

In order to accomplish step (2), you will need to create a custom 'lircd.conf' file for your remote control. First, get a copy of the 'lircd.conf' file with the standard keyboard map. The '/etc/lirc/lircd.conf.d/devinput' file on your MiniMyth system contains the standard keyboard map. You can download this file from your MiniMyth system using the HTTP access to the MiniMyth system. Second, delete all the key name entries from the standard keyboard 'lircd.conf' file that are not needed by your remote control. If your remote control does not generate more than one key name output per key press for any keys, then you should change the key names in the 'lircd.conf' file to key names that most closely correspond to their function as this will enable the 'lircd.conf' file to work with MiniMyth's built-in 'lircrc' files. If your remote control does generate more than one key name output per key press for some keys, then there is no reason to change the key names in the 'lircd.conf' file as you will need to create a custom 'lircd.conf' file anyway. If you want more information on the 'lircd.conf' file format, you can find it here.

If your remote control does generate more than one key name output per key press for some keys, then you will need to create a custom 'lircrc' file. The reason is that the MiniMyth built-in 'lircrc' files expect one key name per key press, and there is no way to use 'lircd.conf' to map multiple key names to a single key name. The '/etc/lirc/lircrc' file on your MiniMyth system contains a list of file names that are the MiniMyth built-in 'lircrc' files. You can download these files from your MiniMyth system using the HTTP access to the MiniMyth system. Once you have downloaded the MiniMyth built-in 'lircrc' files, you can concatenate them into a single 'lircrc' file. After that, you will need to edit this 'lircrc' file, replacing, each 'button = {key_name} line with the one or more 'button = {key_name}' lines for the one or more key names that correspond to the action. For example, if the remote control's fast foward key generates the key name sequence KEY_LEFTCTRL KEY_LEFTSHIFT KEY_F, then you will want to replace each 'button = KEY_FORWARD' line with the lines 'button = KEY_LEFTCTRL', 'button = KEY_LEFTSHIFT' and 'button = KEY_F'. If you want more information on the lircrc file format, you can find it here.

Now that you have a custom 'lircd.conf' and (if needed) a custom 'lircrc' file, you can use the 'MM_LIRC_FETCH_LIRCD_CONF' and 'MM_LIRC_FETCH_LIRCRC' variables to tell MiniMyth to fetch the files at boot time.

If your remote control was not known to MiniMyth and you took the time to create the 'lircd.conf' file and (if needed) the 'lircrc' file, then please follow the instructions under MM_LIRC_AUTO_ENABLED for letting us know so that others can benefit from your efforts.

Some remote controls appear as multiple keyboards. If your remote control appears as multiple keyboard event input devices, then there will be multiple records corresponding to your remote control in the output of the command

cat /proc/bus/input/devices

each with a different eventX value. If your remote control appears as multiple keyboard event input devices, then you will need to repeat the steps for creating the 'lircd.conf' and 'lircrc' for each event input device. Additionally, as MiniMyth's manual configuration only supports configuring one LIRC device, you will only be able to use one of the event input devices created by your remote control until your remote control is known to MiniMyth.