LIRC: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
(44 intermediate revisions by 7 users not shown)
Line 1: Line 1:
==Lircmap.xml==
 
=== Definitions ===
{{mininav|[[Remote controls]]}}
'''A custom Lircmap.xml''' - This file merely defines the translation, bridging a '''LIRC_button''' to a '''XBMC_button'''. The file is literally named '''Lircmap.xml''' and is stored in the [[userdata]] directory. Do not confuse the '''Lircmap.xml''' with [[Keymap.xml]].
 
<section begin="intro" />[[w:LIRC|LIRC]] (Linux Infrared Remote Control) is an open source package that allows users to receive and send infrared signals with a Linux-based computer system.<section end="intro" />
 
* http://www.lirc.org/
 
= Overview of LIRC =
 
== Historical Information ==
Modern Linux kernels "unify" input signals from any input device (keyboard, mouse, remote control, touchscreen, etc.) via the [https://www.kernel.org/doc/html/v4.15/input/input_uapi.html Linux User API Input Subsystem], or UAPI.
 
Prior to the input subsystem, Infrared Remote (IR) controls were integrated to Linux via LIRC.
 
Kodi came into being before UAPI existed, and thus relied exclusively on LIRC.  Thus, when UAPI '''arrived''', Kodi and IR remotes looked like this:
<pre>
          ----------      --------------      ---------------
          |        |--->---| Linux UAPI |-->---| Application |
          |        |      --------------      ---------------
--->------|        |
IR remote | kernel |
          |        |
          |        |      ------------        ---------------
          |        |---->--| lirc    |---->---| Kodi        |
          |        |      ------------        ---------------
          ----------
</pre>
As the UAPI matured, LIRC adopted the ability to use both pathways - UAPI ''and'' LIRC, allowing for:
<pre>
          ----------      --------------      ---------------
          |        |--->---| Linux UAPI |-->---| Application |
          |        |      --------------      ---------------
--->------|        |          |
IR remote | kernel |          v
          |        |          |
          |        |      ------------        ---------------
          |        |---->--| lirc    |---->---| Kodi        |
          |        |      ------------        ---------------
          ----------
</pre>
However, Kodi (to this day) still relies on the to-the-right-of-the-kernel aspects of LIRC. '''This is why LIRC setup can be so confusing.'''
 
{{tip|When LIRC is in use, Kodi '''only''' requires the use of <code>lircd</code>.}}
 
If setting LIRC up with Linux, one needs to focus on using one path from the kernal to LIRC (via UAPI, or via LIRC's kernel device driver).  Modern Linux kernels should focus on using the UAPI sequence.  As Kodi continues to evolve, using the UAPI layer directly allows it to take advantage of non-IR-remote input controls, say an eyeball tracker, or voice controller.
 
{{notice|raw=This page assumes the UAPI ->  LIRC -> Kodi route. If the older (and should be discontinued approach) is used, it is called out.}}
 
== How LIRC works with Kodi ==
 
To help understand how Kodi interacts with LIRC, consider the following scenario:
 
: You push a button on your remote (LIRC config file <code>lircd.conf</code>), That button is seen by the Kodi translator (Kodi LIRC mapping file <code>Lircmap.xml</code>), Kodi starts the requested command (Kodi remote control mapping file <code>remote.xml</code>).
 
Let's trace it:
 
* You press: {{color|#1E90FF|'''KEY_GO'''}} is the actual button name on the remote in {{color|#1E90FF|'''lircd.conf'''}}
 
* LIRC "sees" the remote code, which is translated by the {{color|#32CD32|'''Lircmap.xml'''}} in Kodi's LIRC mapping file:
** And maps: {{color|#1E90FF|'''KEY_GO'''}}
** Into the Kodi remote control command of: '''{{color|#32CD32|<play>}}'''
 
* Finally, Kodi using the {{color|#FF0000|'''remote.xml'''}} file:
** Takes the  '''{{color|#32CD32|<play>}}'''
** and executes the internal {{color|#FF0000|'''Play'''}} command inside of Kodi.
 
Whatever value is there is the REAL name of our button on the remote as defined in lircd.conf. Remember, we can map any button to any function. The actual name of the button could be STOP if we wanted to (kinda dumb but it could be) The REAL button name on the remote is NOT required to have anything to logically do with the name of the command you want to perform
 
 
Just to illustrate we called it the KEY_GO button
 
So to sum it up
 
* Kodi sent a command ''(Remember we are going in reverse)'' called Play
 
* That Play command is tied to the Lircmap.xml <play></play>
 
* That Lircmap.xml <play></play> is tied to the real button on the remote that is called KEY_GO in lircd.conf
 
 
'''<code>remote.xml:</code>'''
<source lang="xml">
<keymap>
  <global>
    <remote>
      <play>Play</play>
    </remote>
  </global>
</keymap>
</source>
 
 
'''<code>Lircmap.xml:</code>'''
<source lang="xml">
<lircmap>
  <remote device="My-Remote-Name">
    <play>KEY_GO</play>
  </remote>
</lircmap>
</source>
 
=== Stale LIRCD conf file ===
 
'''<code>lircd.conf:</code>'''
<source lang="bash">
begin remote
 
  name  "My-Remote-Name"
  bits            5
  flags RC6|CONST_LENGTH
  eps            30
  aeps          100
 
  header      2662  836
  one          452  429
  zero          452  429
  pre_data_bits  32
  pre_data      0x1BFF83DF
  gap          106001
  toggle_bit_mask 0x8000
  rc6_mask    0x100000000
 
      begin codes
          KEY_GO            0x0F
 
      end codes
 
end remote
</source>
 
= Installation =
Generally, lirc is installed as a dependency by any system that requires it when installing Kodi.
 
 
== Re-installing LIRC ==
TODO - clarify new vs. old dependencies
 
If for whatever reason you have to install/reinstall lirc, note that the manual says systemctl should be configured to enable/start lircd.socket, and lircd.socket will start lircd.service itself.  This is NOT the case if you're installing for Kodi: Kodi will open its own socket, so you should enable *only* lircd.service for it to function properly.
 
== lircmap.xml ==
{{see also|Userdata}}
 
'''A custom Lircmap.xml''' - This file merely defines the translation, bridging a '''LIRC_button''' to a '''XBMC_button'''. The file is literally named '''Lircmap.xml''' and is stored in the [[userdata]] directory. Do not confuse the '''Lircmap.xml''' with [[Keyboard.xml]].


'''LIRC_Button''' - what your lircd.conf calls the physical button on your remote control.  
'''LIRC_Button''' - what your lircd.conf calls the physical button on your remote control.  
   
   
'''XBMC_button''' - an XBMC internal button title.  
'''XBMC_button''' - an Kodi internal button title.  


'''device name''' - is defined in your lircd.conf file in the "name" field.  
'''device name''' - is defined in your lircd.conf file in the "name" field.  
Line 11: Line 151:
This information can be had using the test application "irw" and then hitting some buttons. More on this in the [[Lirc and Lircmap.xml#Testing Lirc Output]] section below.
This information can be had using the test application "irw" and then hitting some buttons. More on this in the [[Lirc and Lircmap.xml#Testing Lirc Output]] section below.


=== File Format ===
=== File format ===
Lircmap.xml format is as follows:
Lircmap.xml format is as follows:


  <lircmap>
<source lang="xml">
        <remote device="devicename">
<lircmap>
                <XBMC_button>LIRC_button</XBMC_button>
  <remote device="devicename">
                ...
      <Kodi_button>LIRC_button</Kodi_button>
        </remote>
        ...
  </lircmap>
  </remote>
</lircmap>
</source>


==== Device Name ====
=== Device name ===
The device name is defined in your lircd.conf file in the "name" field. This information can be had using the test application "irw" and then hitting some buttons. More on this in the [[Lirc and Lircmap.xml#Testing Lirc Output]] section below.
The device name is defined in your lircd.conf file in the "name" field. This information can be had using the test application "irw" and then hitting some buttons. More on this in the [[Lirc and Lircmap.xml#Testing Lirc Output]] section below.


==== XBMC_Button Names ====
=== Kodi button names ===
There are two type of XBMC_buttons in XBMC.  
There are two type of Kodi_buttons in Kodi.  


* Predefined Buttons are labeled using their button title such as:
* Predefined Buttons are labelled using their button title such as:
   <left>
   <left>
   <right>
   <right>
Line 45: Line 187:
  FYI : obc stands for original button code and is a legacy of the old xbox IR remote system
  FYI : obc stands for original button code and is a legacy of the old xbox IR remote system


== Lirc Configuration ==
== Testing Lirc Output ==
=== Information ===
A complete Lirc configuration document is currently beyond the scope of this manual. More information on LIRC is available on the offical website www.lirc.org
 
=== Testing Lirc Output ===
use the command 'irw' to test your LIRC configuration
use the command 'irw' to test your LIRC configuration


Line 63: Line 201:
If you wish to redefine the button names it can be done in /etc/lircd.conf
If you wish to redefine the button names it can be done in /etc/lircd.conf


= Examples =
* [http://www.loggn.de/linux-ubuntu-lirc-xbmc-mit-logitech-harmony-steuern-lircmap-xml-und-keyboard-xml/ HOW-TO - Ubuntu/Linux – LIRC – control Kodi with Logitech Harmony remote – Lircmap.xml and Keyboard.xml]
* [http://www.loggn.de/arch-linux-lirc-konfiguration-mit-mce-rc6-ir-und-lircmap-xml-fuer-xbmc-logitech-harmony/ HOW-TO - Arch Linux - LIRC Version 0.9.0, Kernel 3.2 and new Lircmap.xml for XBMC]
{{Gotham updated}}
[[Category:Manual]]
[[Category:Linux]]
[[Category:Linux]]
[[Category:Remotes]]
[[Category:Remotes]]
[[Category:Supplemental tools]]

Revision as of 13:57, 2 June 2019

Home icon grey.png   ▶ Remote controls ▶ LIRC

LIRC (Linux Infrared Remote Control) is an open source package that allows users to receive and send infrared signals with a Linux-based computer system.

Overview of LIRC

Historical Information

Modern Linux kernels "unify" input signals from any input device (keyboard, mouse, remote control, touchscreen, etc.) via the Linux User API Input Subsystem, or UAPI.

Prior to the input subsystem, Infrared Remote (IR) controls were integrated to Linux via LIRC.

Kodi came into being before UAPI existed, and thus relied exclusively on LIRC. Thus, when UAPI arrived, Kodi and IR remotes looked like this:

          ----------       --------------      ---------------
          |        |--->---| Linux UAPI |-->---| Application |
          |        |       --------------      ---------------
--->------|        |
IR remote | kernel |
          |        |
          |        |       ------------        ---------------
          |        |---->--| lirc     |---->---| Kodi        |
          |        |       ------------        ---------------
          ----------

As the UAPI matured, LIRC adopted the ability to use both pathways - UAPI and LIRC, allowing for:

          ----------       --------------      ---------------
          |        |--->---| Linux UAPI |-->---| Application |
          |        |       --------------      ---------------
--->------|        |           |
IR remote | kernel |           v
          |        |           |
          |        |       ------------        ---------------
          |        |---->--| lirc     |---->---| Kodi        |
          |        |       ------------        ---------------
          ----------

However, Kodi (to this day) still relies on the to-the-right-of-the-kernel aspects of LIRC. This is why LIRC setup can be so confusing.

Tip Tip: When LIRC is in use, Kodi only requires the use of lircd.

If setting LIRC up with Linux, one needs to focus on using one path from the kernal to LIRC (via UAPI, or via LIRC's kernel device driver). Modern Linux kernels should focus on using the UAPI sequence. As Kodi continues to evolve, using the UAPI layer directly allows it to take advantage of non-IR-remote input controls, say an eyeball tracker, or voice controller.

Emblem-important-yellow.png This page assumes the UAPI -> LIRC -> Kodi route. If the older (and should be discontinued approach) is used, it is called out.

How LIRC works with Kodi

To help understand how Kodi interacts with LIRC, consider the following scenario:

You push a button on your remote (LIRC config file lircd.conf), That button is seen by the Kodi translator (Kodi LIRC mapping file Lircmap.xml), Kodi starts the requested command (Kodi remote control mapping file remote.xml).

Let's trace it:

  • You press: KEY_GO is the actual button name on the remote in lircd.conf
  • LIRC "sees" the remote code, which is translated by the Lircmap.xml in Kodi's LIRC mapping file:
    • And maps: KEY_GO
    • Into the Kodi remote control command of: <play>
  • Finally, Kodi using the remote.xml file:
    • Takes the <play>
    • and executes the internal Play command inside of Kodi.

Whatever value is there is the REAL name of our button on the remote as defined in lircd.conf. Remember, we can map any button to any function. The actual name of the button could be STOP if we wanted to (kinda dumb but it could be) The REAL button name on the remote is NOT required to have anything to logically do with the name of the command you want to perform


Just to illustrate we called it the KEY_GO button

So to sum it up

  • Kodi sent a command (Remember we are going in reverse) called Play
  • That Play command is tied to the Lircmap.xml <play></play>
  • That Lircmap.xml <play></play> is tied to the real button on the remote that is called KEY_GO in lircd.conf


remote.xml:

<keymap>
  <global>
    <remote>
      <play>Play</play>
    </remote>
  </global>
</keymap>


Lircmap.xml:

<lircmap>
  <remote device="My-Remote-Name">		
    <play>KEY_GO</play>
  </remote>
</lircmap>

Stale LIRCD conf file

lircd.conf:

begin remote

  name  "My-Remote-Name"
  bits            5
  flags RC6|CONST_LENGTH
  eps            30
  aeps          100

  header       2662   836
  one           452   429
  zero          452   429
  pre_data_bits   32
  pre_data       0x1BFF83DF
  gap          106001
  toggle_bit_mask 0x8000
  rc6_mask    0x100000000

      begin codes
          KEY_GO             0x0F

      end codes

end remote

Installation

Generally, lirc is installed as a dependency by any system that requires it when installing Kodi.


Re-installing LIRC

TODO - clarify new vs. old dependencies

If for whatever reason you have to install/reinstall lirc, note that the manual says systemctl should be configured to enable/start lircd.socket, and lircd.socket will start lircd.service itself. This is NOT the case if you're installing for Kodi: Kodi will open its own socket, so you should enable *only* lircd.service for it to function properly.

lircmap.xml

A custom Lircmap.xml - This file merely defines the translation, bridging a LIRC_button to a XBMC_button. The file is literally named Lircmap.xml and is stored in the userdata directory. Do not confuse the Lircmap.xml with Keyboard.xml.

LIRC_Button - what your lircd.conf calls the physical button on your remote control.

XBMC_button - an Kodi internal button title.

device name - is defined in your lircd.conf file in the "name" field.

This information can be had using the test application "irw" and then hitting some buttons. More on this in the Lirc and Lircmap.xml#Testing Lirc Output section below.

File format

Lircmap.xml format is as follows:

<lircmap>
   <remote device="devicename">
      <Kodi_button>LIRC_button</Kodi_button>
        ...
   </remote>
</lircmap>

Device name

The device name is defined in your lircd.conf file in the "name" field. This information can be had using the test application "irw" and then hitting some buttons. More on this in the Lirc and Lircmap.xml#Testing Lirc Output section below.

Kodi button names

There are two type of Kodi_buttons in Kodi.

  • Predefined Buttons are labelled using their button title such as:
  <left>
  <right>
  <title>
  <menu>

These buttons are predefined in keymap.xml and handle all functions needed for a working system. For a complete list of buttons see keymap.xml#Remote Buttons.

  • Customized buttons are for people who require more buttons than are defined by default. For example;
  <obc1>BUTTON1</obc1>
  ...
  <obc254>BUTTON254</obc254>
Note : These obc buttons must be defined in keymap.xml under the [[<universalremote>]] heading
FYI : obc stands for original button code and is a legacy of the old xbox IR remote system

Testing Lirc Output

use the command 'irw' to test your LIRC configuration

  xbmc@xbmclinux:~$ irw
  0000000000040004 00 ARROW_UP Cyp_Se_WitheHome
  0000000000040004 00 VOLUME_UP Cyp_Se_WitheHome
  0000000000040004 00 NUMPAD_6 Cyp_Se_WitheHome
  0000000000040004 00 INFO Cyp_Se_WitheHome

In this example Cyp_Se_WitheHome is the device name ARROW_UP, VOLUME_UP, NUMPAD_6, INFO are button names

If you wish to redefine the button names it can be done in /etc/lircd.conf

Examples