################################################################################
# An example udev rules file for eventlircd.
#
# This rules file does not start eventlircd. Many applications only check for
# the lircd socket at application lauch. Therefore, it is better to start
# eventlircd in an init script so that eventlircd creates the lircd socket
# before any applications that use LIRC launch.
################################################################################

# eventlircd only does something for "add" and "remove" actions.
ACTION!="add|remove", GOTO="end"

# eventlircd only does something "input" subsystem devices.
SUBSYSTEM!="input", GOTO="end"

# eventlircd can only handle event devices.
KERNEL!="event[0-9]*", GOTO="end"

# eventlircd ignores devices created by eventlircd.
ATTRS{name}=="eventlircd", GOTO="end"

#-------------------------------------------------------------------------------
# Ask eventlircd to handle input event devices created by lircd. For this to
# work, lircd must be configured to output Linux input events and must be
# configured to output key names that conform to the LIRC namespace derived from
# the Linux key/button event names. This rule assumes that lircd performs all
# key mappings, so the rule does not provide a value for "eventlircd_evmap".
# For more information on lircd, see <http://www.lirc.org/>.
#-------------------------------------------------------------------------------
ATTRS{name}=="lircd", \
  ENV{eventlircd_enable}="true"

#-------------------------------------------------------------------------------
# Ask eventlircd to handle input event devices created by bdremoteng. For this
# to work, bdremoteng must be configured to output Linux input events and must
# be configured to output key names that conform to LIRC namespace derived
# from the Linux key/button event names. For more information on bdremoteng,
# see <http://code.google.com/p/bdremote-ng/>.
#-------------------------------------------------------------------------------
ATTRS{name}=="bdremoteng", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="bdremoteng.evmap"

#-------------------------------------------------------------------------------
# Ask eventlircd to handle input event devices created by wminput. This rule
# assumes that wminput performs all key mappings, so the rule does not provide a
# value for "eventlircd_evmap" For more information on wminput, see
# <http://abstrakraft.org/cwiid/>.
#-------------------------------------------------------------------------------
ATTRS{name}=="bdremoteng", \
  ENV{eventlircd_enable}="true"

#-------------------------------------------------------------------------------
# Ask eventlircd to handle input event devices created by ir-core (kernel).
#-------------------------------------------------------------------------------
SUBSYSTEMS=="rc", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="ircore.evmap"

#-------------------------------------------------------------------------------
# Ask eventlircd to handle power button.
#-------------------------------------------------------------------------------
SUBSYSTEMS=="acpi", ATTRS{hid}=="LNXPWRBN", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="power.evmap"

#-------------------------------------------------------------------------------
# Ask eventlircd to handle USB HID devices that show up as event devices and are
# known to be remote controls. For simplicity, the event map file names have the
# format <BUSTYPE>_<VENDOR>_<PRODUCT>.evmap.
#-------------------------------------------------------------------------------
SUBSYSTEMS=="usb", GOTO="begin-usb"
GOTO="end-usb"
LABEL="begin-usb"

ENV{ID_USB_INTERFACES}=="", IMPORT{program}="usb_id --export %p"

ENV{ID_VENDOR_ID}=="0bc7", ENV{ID_MODEL_ID}=="0006", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="03_$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.evmap"

ENV{ID_VENDOR_ID}=="0419", ENV{ID_MODEL_ID}=="0001", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="03_$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.evmap"

ENV{ID_VENDOR_ID}=="046e", ENV{ID_MODEL_ID}=="5577", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="03_$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.evmap"

ENV{ID_VENDOR_ID}=="05a4", ENV{ID_MODEL_ID}=="9881", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="03_$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.evmap"

# ENV{ID_VENDOR_ID}=="05ac", ENV{ID_MODEL_ID}=="8241", \
#   ENV{eventlircd_enable}="true", \
#   ENV{eventlircd_evmap}="03_$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.evmap"

ENV{ID_VENDOR_ID}=="0755", ENV{ID_MODEL_ID}=="2626", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="03_$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.evmap"

ENV{ID_VENDOR_ID}=="0766", ENV{ID_MODEL_ID}=="0204", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="03_$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.evmap"

ENV{ID_VENDOR_ID}=="147a", ENV{ID_MODEL_ID}=="e02d", \
  ENV{eventlircd_enable}="true", \
  ENV{eventlircd_evmap}="03_$env{ID_VENDOR_ID}_$env{ID_MODEL_ID}.evmap"

LABEL="end-usb"

LABEL="end"
