org.lirc.util
Class LIRCMap

java.lang.Object
  |
  +--org.lirc.util.LIRCMap

public class LIRCMap
extends java.lang.Object

Maps remote control buttons to Strings. The mapping can be saved to and read from a file with the following format: (a subset of the .lircrc file format, see the LIRC documentation):

# comment

begin
button = button_name
[remote = remote_name]
[repeat = positive integer]
[config = string]
[config = string]
...
end

Empty lines and lines starting with "#" are ignored.

button is the name of the button that this section concerns.

remote is the name of the remote control that this section concerns. If this line is omitted all remotes will be matched.

repeat specifies how repeat events will be matched. A value of 0 means that no repeat events will be matched, i.e. only the first event is matched when a button is held down. A value n > 0 means that every n:th event is reported, i.e. every event for which repeat % n == 0. If the repeat line is omitted only the first event will be reported, i.e. repeat = 0

config lines specify the strings that will be mapped to the event. If several config strings are specified they will be cycled through. This lets you implement toggle buttons etc.

Example:
begin
button = power
config = on
config = off
end

begin
button = vol+
repeat = 1
config = volup
end

begin
button = four
remote = RM-D90
repeat = 5
config = left
end

Version:
$Revision: 1.7 $
Author:
Bjorn Bringert (bjorn@mumblebee.com)

Inner Class Summary
protected static class LIRCMap.Entry
          The entries in this map.
 
Constructor Summary
LIRCMap()
          Creates a new empty LIRCMap.
LIRCMap(java.lang.String program)
          Creates a new empty LIRCMap.
LIRCMap(java.lang.String program, java.io.File file)
          Reads a LIRCMap from a file.
 
Method Summary
protected  void add(LIRCMap.Entry e)
          Adds an Entry.
 void add(java.lang.String button, java.lang.String remote, int repeat, java.lang.String value)
          Adds a value mapping to this map.
 void add(java.lang.String button, java.lang.String remote, int repeat, java.lang.String[] values)
          Adds a value mapping to this map.
 java.lang.String get(LIRCEvent e)
          Gets the String that matches a LIRCEvent.
 void load(java.io.File file)
          Loads settings from a file.
 void load(java.io.Reader reader)
          Loads settings from a Reader.
 void load(java.lang.String filename)
          Loads settings from a file.
static void main(java.lang.String[] args)
          For testing.
 void store(java.io.File file)
          Writes this LIRCMap to a file.
 void store(java.lang.String filename)
          Writes this LIRCMap to a file.
 void store(java.io.Writer writer)
          Writes this LIRCMap to a Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LIRCMap

public LIRCMap()
Creates a new empty LIRCMap.

LIRCMap

public LIRCMap(java.lang.String program)
Creates a new empty LIRCMap.

LIRCMap

public LIRCMap(java.lang.String program,
               java.io.File file)
        throws java.io.IOException
Reads a LIRCMap from a file. Same as:
LIRCMap map = new LIRCMap(program);
map.load(file);
Method Detail

load

public void load(java.lang.String filename)
          throws java.io.IOException
Loads settings from a file.

load

public void load(java.io.File file)
          throws java.io.IOException
Loads settings from a file.

load

public void load(java.io.Reader reader)
          throws java.io.IOException
Loads settings from a Reader.

store

public void store(java.lang.String filename)
           throws java.io.IOException
Writes this LIRCMap to a file.

store

public void store(java.io.File file)
           throws java.io.IOException
Writes this LIRCMap to a file.

store

public void store(java.io.Writer writer)
           throws java.io.IOException
Writes this LIRCMap to a Writer.

get

public java.lang.String get(LIRCEvent e)
Gets the String that matches a LIRCEvent.
Parameters:
e - The event
Returns:
A String or null if there is no match

add

public void add(java.lang.String button,
                java.lang.String remote,
                int repeat,
                java.lang.String value)
Adds a value mapping to this map.
Parameters:
button - The button to match
remote - The remote value
repeat - The repeat value
value - The value to map to the parameters

add

public void add(java.lang.String button,
                java.lang.String remote,
                int repeat,
                java.lang.String[] values)
Adds a value mapping to this map.
Parameters:
button - The button to match
remote - The remote value
repeat - The repeat value
values - The values to map to the parameters

add

protected void add(LIRCMap.Entry e)
Adds an Entry.
Parameters:
e - The Entry to add

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
For testing. Loads a config file, dumps the setup to stdout, connects to the LIRC daemon and prints the commands matched by the events received.