###############################################################################
# BRLTTY - A background process providing access to the console screen (when in
#          text mode) for a blind person using a refreshable braille display.
#
# Copyright (C) 1995-2009 by The BRLTTY Developers.
#
# BRLTTY comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version. Please see the file LICENSE-GPL for details.
#
# Web Page: http://mielke.cc/brltty/
#
# This software is maintained by Dave Mielke <dave@mielke.cc>.
###############################################################################

# udev rules file for brltty

SUBSYSTEM=="usb_device", GOTO="brltty_usb_begin"
SUBSYSTEM=="usb", KERNEL!="*:*", GOTO="brltty_usb_begin"
GOTO="brltty_end"

LABEL="brltty_usb_begin"

# Alva
ENV{PRODUCT}=="6b0/1/*", ENV{BRLTTY_DRIVER}="al", GOTO="brltty_usb_run"
ENV{PRODUCT}=="798/640/*", ENV{BRLTTY_DRIVER}="al", GOTO="brltty_usb_run"
ENV{PRODUCT}=="798/680/*", ENV{BRLTTY_DRIVER}="al", GOTO="brltty_usb_run"

# Baum
ENV{PRODUCT}=="403/fe70/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="403/fe71/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="403/fe72/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="403/fe73/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="403/fe74/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="403/fe75/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="403/fe76/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="403/fe77/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2000/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2001/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2002/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2007/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2008/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2009/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2010/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2011/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2014/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2015/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/2016/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"
ENV{PRODUCT}=="904/3000/*", ENV{BRLTTY_DRIVER}="bm", GOTO="brltty_usb_run"

# EuroBraille
ENV{PRODUCT}=="c251/1122/*", ENV{BRLTTY_DRIVER}="eu", GOTO="brltty_usb_run"
ENV{PRODUCT}=="c251/1124/*", ENV{BRLTTY_DRIVER}="eu", GOTO="brltty_usb_run"

# FreedomScientific
ENV{PRODUCT}=="f4e/100/*", ENV{BRLTTY_DRIVER}="fs", GOTO="brltty_usb_run"
ENV{PRODUCT}=="f4e/111/*", ENV{BRLTTY_DRIVER}="fs", GOTO="brltty_usb_run"
ENV{PRODUCT}=="f4e/112/*", ENV{BRLTTY_DRIVER}="fs", GOTO="brltty_usb_run"

# HandyTech
ENV{PRODUCT}=="921/1200/*", ENV{BRLTTY_DRIVER}="ht", GOTO="brltty_usb_run"
ENV{PRODUCT}=="403/6001/*", ENV{BRLTTY_DRIVER}="ht", GOTO="brltty_usb_run"

# HIMS
ENV{PRODUCT}=="45e/930a/*", ENV{BRLTTY_DRIVER}="hm", GOTO="brltty_usb_run"

# Papenmeier
ENV{PRODUCT}=="403/f208/*", ENV{BRLTTY_DRIVER}="pm", GOTO="brltty_usb_run"

# Pegasus
ENV{PRODUCT}=="4242/1/*", ENV{BRLTTY_DRIVER}="pg", GOTO="brltty_usb_run"

# Seika
ENV{PRODUCT}=="10c4/ea60/*", ENV{BRLTTY_DRIVER}="sk", GOTO="brltty_usb_run"

# Voyager
ENV{PRODUCT}=="798/1/*", ENV{BRLTTY_DRIVER}="vo", GOTO="brltty_usb_run"

GOTO="brltty_end"

LABEL="brltty_usb_run"
ENV{BRLTTY_DEVICE}="usb:$sysfs{serial}"
GOTO="brltty_run"

LABEL="brltty_run"
ENV{BRLTTY_PID_FILE}="/var/run/brltty.$kernel.pid"
ACTION=="add", GOTO="brltty_add"
ACTION=="remove", GOTO="brltty_remove"
GOTO="brltty_end"

LABEL="brltty_add"
SYMLINK+="brltty/$env{BRLTTY_DRIVER}-$env{BRLTTY_DEVICE}"
RUN+="/bin/brltty -E -P$env{BRLTTY_PID_FILE}"
GOTO="brltty_end"

LABEL="brltty_remove"
RUN+="/bin/sh -c 'kill -TERM `cat $env{BRLTTY_PID_FILE}`'"
GOTO="brltty_end"

LABEL="brltty_end"
