LIRC: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
No edit summary
(credit goes to FishOil, http://forum.xbmc.org/showthread.php?tid=189617)
Line 3: Line 3:


* http://www.lirc.org/
* http://www.lirc.org/
== How LIRC works ==
Understanding LIRC and XBMC
You push a button on your remote (lircd.conf), That button is seen by the XBMC translator (Lircmap.xml), XBMC starts the requsted command (remote.xml) 
Lets trace it backwards.
[color=#32CD32][b]<play>[/b][/color][color=#FF0000][b]Play[/b][/color][color=#32CD32][b]</play>[/b][/color] The one in RED is the [color=#FF0000][b]remote.xml [/b][/color]command
  [b][color=#32CD32]<play>[/color][/b][color=#1E90FF][b]KEY_GO[/b][/color][b][color=#32CD32]</play>[/color][/b] is the [color=#32CD32][b]Lircmap.xml[/b][/color] Translated name that points to [color=#1E90FF][b]lircd.conf KEY_GO[/b][/color] button
  [color=#1E90FF][b]KEY_GO[/b][/color] is the actual button name on the remote in [color=#1E90FF][b]lircd.conf[/b][/color]
XBMC performs a command [color=#FF0000][b]Play [/b][/color](remote.xml)
The lower case [color=#32CD32][b]play [/b][/color]in the angle brackets is the (Lircmap.xml) translated name
Then we go to the Lircmap.xml to see what Lirc button holds the value of the lowercase play above.
So we expect to see [color=#32CD32][b]<play>[/b][/color][color=#1E90FF][b]*******[/b][/color][color=#32CD32][b]</play>[/b][/color] with some value in between the angle brackets.
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
XBMC 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
[code]<keymap>
  <global>
    <remote>
      <play>Play</play>
          </remote>
</global>
</keymap>[/code]
Lircmap.xml
[code]
  <lircmap>
<remote device=""My-Remote-Name">
<play>KEY_GO</play>
</remote>
</lircmap>
[/code]
lircd.conf
[code]
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
[/code]


== lircmap.xml ==
== lircmap.xml ==

Revision as of 09:52, 23 March 2014

Template:Keyboard navigation LIRC is software that allows you to decode and send infra-red signals of most commonly used remote controls.

How LIRC works

Understanding LIRC and XBMC


You push a button on your remote (lircd.conf), That button is seen by the XBMC translator (Lircmap.xml), XBMC starts the requsted command (remote.xml)


Lets trace it backwards.

[color=#32CD32][b]<play>[/b][/color][color=#FF0000][b]Play[/b][/color][color=#32CD32][b]</play>[/b][/color] The one in RED is the [color=#FF0000][b]remote.xml [/b][/color]command

 [b][color=#32CD32]<play>[/color][/b][color=#1E90FF][b]KEY_GO[/b][/color][b][color=#32CD32]</play>[/color][/b] is the [color=#32CD32][b]Lircmap.xml[/b][/color] Translated name that points to [color=#1E90FF][b]lircd.conf KEY_GO[/b][/color] button
 [color=#1E90FF][b]KEY_GO[/b][/color] is the actual button name on the remote in [color=#1E90FF][b]lircd.conf[/b][/color]


XBMC performs a command [color=#FF0000][b]Play [/b][/color](remote.xml)

The lower case [color=#32CD32][b]play [/b][/color]in the angle brackets is the (Lircmap.xml) translated name

Then we go to the Lircmap.xml to see what Lirc button holds the value of the lowercase play above.

So we expect to see [color=#32CD32][b]<play>[/b][/color][color=#1E90FF][b]*******[/b][/color][color=#32CD32][b]</play>[/b][/color] with some value in between the angle brackets.

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

XBMC 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

[code]<keymap>

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

</keymap>[/code]

Lircmap.xml

[code]

 <lircmap>

<remote device=""My-Remote-Name">

<play>KEY_GO</play>

</remote>

</lircmap>

[/code]

lircd.conf

[code] 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 [/code]


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 XBMC 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">
               <XBMC_button>LIRC_button</XBMC_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.

XBMC button names

There are two type of XBMC_buttons in XBMC.

  • 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