3
# Stores the current calibration settings for the given joystick
4
# (materialized by its device). The calibration settings are stored
5
# using the joystick's name and serial number if available, and its
6
# vendor and product codes if it's a USB device. If none of these can
7
# be determined, the settings are stored against the device name.
10
echo "Usage: $0 {device}"
11
echo "Stores the device's calibration for future use."
15
if [ ! -x /sbin/udevadm ]; then
16
echo Storing joystick configuration requires udev! >&2
20
/sbin/udevadm info -a -n $1 | /usr/share/joystick/ident > $ident
24
STORE=/var/lib/joystick/joystick.state
26
# Filter the existing file
27
if [ -f $STORE ]; then
28
if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then
29
echo "No product name or vendor available, calibration will be stored for the"
30
echo "given device name ($DEVICE) only!"
31
/usr/share/joystick/filter kernel="$DEVICE" < $STORE > $STORE.new
33
/usr/share/joystick/filter name="$NAME" serial="$SERIAL" vendor="$VENDOR" product="$PRODUCT" < $STORE > $STORE.new
37
# Append the new calibration information
38
if [ -f $STORE.new ] && [ ! -z "$(cat $STORE.new)" ]; then
41
if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then
42
echo "DEVICE=\"$DEVICE\"" >> $STORE.new
44
if [ ! -z "$NAME" ]; then
45
echo "NAME=\"$NAME\"" >> $STORE.new
47
if [ ! -z "$SERIAL" ]; then
48
echo "SERIAL=\"$SERIAL\"" >> $STORE.new
50
if [ ! -z "$VENDOR" ]; then
51
echo "VENDOR=\"$VENDOR\"" >> $STORE.new
53
if [ ! -z "$PRODUCT" ]; then
54
echo "PRODUCT=\"$PRODUCT\"" >> $STORE.new
56
jscal -p $1 | cut -d' ' -f-3 >> $STORE.new
57
jscal -q $1 | cut -d' ' -f-3 >> $STORE.new
59
if [ -f $STORE ]; then