User Manual:IR control via evdev
This page is up-to-date as of MythTV version 0.27.6, the current release is 0.28.1
Lirc is typically no longer required for a range of common IR devices. IR support has been added in to the linux kernel using evdev (/dev/event/inputX) and works natively in mythbuntu14.04 and mythtv with little configuration.
The following information has been written based on Logitech myHarmony 'Microsoft MCE Keyboard' and 'Microsoft Windows Media Center SE' devices, with the Intel DN2820FYKH NUC built-in IR receiver. Using both of these MCE inputs means the most amount of available options.
The aim for my installation was to be able to interact with an FE in as few clicks as possible on the remote. Making use of MCE keyboard commands (ALT+..., WIN+..., CTRL+...) where the standard MCE Remote lacked. LIRC made this difficult due to how the NUC IR receiver was designed where some inputs would show on /dev/events/input3, and others to /dev/events/input4 depending on the exact command the remote sent. LIRC essentially had to monitor and function with 2 receivers and not the typical one. This guide does briefly touch on migration between lirc and evdev.
This is part of the core kernel packages so no installation work is needed here. The MCE Remote and MCE Keyboard are already known devices to the kernel so no learning configuration is needed. It would be worth noting that evdev is not out-of-the-box configured for the best IR experience. IR baud rate is slower than a non-IR device (wired/wireless keyboards for example), and evdev can respond too quickly resulting in things misbehaving. See below in IR-Keytable Change Timings section.
Depending on your hardware, the /dev/event/inputX event assignment may not be static between reboots. edev rules will need to be created to ensure the inputs stay the same.
ir-keytable package will likely need to be installed.
sudo apt-get install ir-keytable
Testing your inputs
Now that's installed, use the -t switch (test) to test what ir-keytable sees when you press buttons on your remote. Take note of the device name it uses. If you do not see any output when you press a key, then the ir-keytables will need to be told what to monitor with the -d switch (device).
ir-keytable -t -d /dev/event/input4
If this does not work or for more explanation see Modify key codes below.
Most likely, evdev has not configured anything special for the IR receiver input, so it's probably expecting a keyboard input to it. IR baud rates are slower than keyboard so evdev will need to be told to slow down it's magic to stop misbehaving. This can typically be found that when holding down a button on the remote, ir-keytables -t would show inconsistent/irregular key-up events. Since this is all timings based, if you get unlucky mythtv would act like the key is still held down even though it isnt. Pressing another key would reset this state and would return to expected behavior. You can configure ir-keytables if ghost or erratic keypresses exist, on a per-input level basis with with the following command (-D = delay, -P = period):
ir-keytable -D 500 -P 250 -d /dev/event/input3 ir-keytable -D 500 -P 250 -d /dev/event/input4
You should have noted the output gives the current values and the newly set values. Take note of the original values so you have a base to tweak from if the above example is not suitable.
Modify key codes
The keys on your remote will likely not map to the correct MythTV commands. There may be keys on the remote that do not work as normal keys, such as "Play", "Stop", "Next", "Prev". These may attempt to launch the internal music player. You can easily fix any keys that need changing using ir-keytable.
Run ir-keytable with no parameters to find some information. You can run as user or as root. Running as root gives extra information:
$ sudo ir-keytable Found /sys/class/rc/rc2/ (/dev/input/event17) with: Driver dib0700, table rc-dib0700-rc5 Supported protocols: NEC RC-5 RC-6 Enabled protocols: RC-5 Repeat delay = 500 ms, repeat period = 125 ms
Test the buttons using ir-keytable to see what they generate and make a note of the ones that need changing, Use the device name that you found above (/dev/input/event17):
$ sudo ir-keytable -t -d /dev/input/event17 Testing events. Please, press CTRL-C to abort.
With each remote button press you will get a scan code and an event that is generated. For example pressing stop generates something like this:
1444051290.995644: event MSC: scancode = 73c 1444051290.995644: event key down: KEY_STOP (0x0080) 1444051290.995644: event sync 1444051291.109014: event MSC: scancode = 73c 1444051291.109014: event sync 1444051291.222421: event MSC: scancode = 73c 1444051291.222421: event sync 1444051291.472911: event key up: KEY_STOP (0x0080) 1444051291.472911: event sync
With items like KEY_PLAY you may also see other things happening as Linux tries to launch the audio player.
Look for the scancode table file for your device. It will be found in /lib/udev/rc_keymaps/, for example in the above case it is at /lib/udev/rc_keymaps/dib0700_rc5. This contains all of the mappings for your remote, and may contain extra entries. Create a new file in your file system with overrides to the key map, for example to modify the above mentioned stop button to Escape for MythTV, use this:
Add all of your overrides to the file, and save it in a suitable place. The following command needs to be run after each system start. It also will need to be run after unplugging and replugging the remote receiver (assuming your override file is at ~/remote_rc5:
sudo ir-keytable -w ~/remote_rc5 -d /dev/input/event17
It is possible that your remote may come in as a different device on reboot of the system. Each of the commands above can be run with either -d /dev/input/event17 or -s rc2. Normally your remote will be assigned rc0 unless it is unplugged and replugged, so it may be more reliable to use rc0. The correct way to address this problem is with udev rules which is a complex subject discussed elsewhere.
evdev does not allow running of scripts like lirc does, so if a suspend script was called via a lirc keypress, then we need to handle that slightly differently. Thankfully Mythtv has the ability built in to tell when it's not in use. Mythweb is probably the easiest solution to configure this by configuring a 'Standby Mode' jumppoint keybind. This does need to be covered separately in another wiki page.
Mythbuntu has a number of areas to configure IR control. The initial installation allows configuration, as does 'Mythbuntu-Control-Center' GUI tool. Leave or set these settings back to 'no IR control' depending if your installing fresh or re-configuring an existing install.