4
echo "Usage: $0 {device}"
5
echo "Restores the device's calibration."
9
if [ ! -x /sbin/udevadm ]; then
10
echo Restoring joystick configuration requires udev! >&2
14
STORE=/var/lib/joystick/joystick.state
16
if [ ! -f $STORE ]; then
17
echo No saved joystick configuration\(s\) to restore! >&2
27
# Backup original $IFS (Internal Field Separator) variable
29
# Set $IFS to newline only as output from @@PREFIX@@/share/joystick/ident might contain spaces
33
for ATTRIBUTE in $( /sbin/udevadm info -a -n $1 | @@PREFIX@@/share/joystick/ident ); do
34
ID=$( echo "$ATTRIBUTE" | cut -f 1 -d = )
35
VALUE=$( echo "$ATTRIBUTE" | cut -f 2 -d \" )
37
"DEVICE" ) DEVICE="$VALUE" ;;
38
"NAME" ) NAME="$VALUE" ;;
39
"SERIAL" ) SERIAL="$VALUE" ;;
40
"VENDOR" ) VENDOR="$VALUE" ;;
41
"PRODUCT" ) PRODUCT="$VALUE" ;;
45
# Restore original $IFS
48
# Retrieve the applicable commands
49
if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then
50
# Use the device name only
51
cat $STORE | @@PREFIX@@/share/joystick/extract kernel="$DEVICE" | while read COMMAND; do
55
cat $STORE | @@PREFIX@@/share/joystick/extract name="$NAME" serial="$SERIAL" vendor="$VENDOR" product="$PRODUCT" | while read COMMAND; do