/lib/udev/js-set-enum-leds is in joystick 1:1.4.9-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #!/bin/sh
# js-set-enum-leds: Set gamepad enumerator LEDS to match the js device number.
# Copyright © 2014 bri <bri@abrij.org>
#
# This program is free software; you can redistribute it and/or modify
# it 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.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# If the gamepad/joystick is bluetooth-capable, bluez may set the leds
# even before the gamepad is connected. In these cases please match what
# bluez will do (or may already have done if it is already running.)
# If the set_gamepad_leds function provided for convenience is to be used
# for a particular type of gamepad, the udev rule should provide the following
# postional parameters. See /lib/udev/rules.d/60-joystick for examples.
# A partial path string containing the common part of the names of affected
# led-class sysfs directories.
LEDGLOB=$1
# The number of the js device. These start at 0 but enumerator LEDs are
# 1-based. (Having at least one LED on lets user see controller is on.)
JSNUM=$2
set_gamepad_leds() {
for led in "$LEDGLOB"*; do
if [ -d $led ] && [ -w $led/brightness ] && [ "$1" ]; then
echo $1 > $led/brightness
shift 1
else
echo "set_gamepad_leds: wrong number of leds or values" 1>&2
exit -1
fi
done
}
# In addition it is assumed ID_MODEL will have been set appropriately by udev
# This is used to select the appropriate actions for the particular model.
case $ID_MODEL in
PLAYSTATION_R_3_Controller)
case $JSNUM in
0) set_gamepad_leds 1 0 0 0;
;;
1) set_gamepad_leds 0 1 0 0;
;;
2) set_gamepad_leds 0 0 1 0;
;;
3) set_gamepad_leds 0 0 0 1;
;;
4) set_gamepad_leds 1 0 0 1;
;;
5) set_gamepad_leds 0 1 0 1;
;;
6) set_gamepad_leds 0 0 1 1;
;;
*) set_gamepad_leds 0 0 0 0;
;;
esac
;;
*) echo "called with no matching model" 1>&2
esac
|