~ubuntu-branches/ubuntu/quantal/joystick/quantal

« back to all changes in this revision

Viewing changes to debian/jscal-store

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-05-16 16:11:59 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100516161159-tf754mo83ojh1yqj
Tags: 20051019-11
evtest: flush standard output, thanks Florian Fainelli! Closes:
#581740.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
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.
 
8
 
 
9
if [ -z "$1" ]; then
 
10
    echo "Usage: $0 {device}"
 
11
    echo "Stores the device's calibration for future use."
 
12
    exit 1
 
13
fi
 
14
 
 
15
if [ ! -x /sbin/udevadm ]; then
 
16
    echo Storing joystick configuration requires udev! >&2
 
17
fi
 
18
 
 
19
ident=$(mktemp)
 
20
/sbin/udevadm info -a -n $1 | /usr/share/joystick/ident > $ident
 
21
. $ident
 
22
rm $ident
 
23
 
 
24
STORE=/var/lib/joystick/joystick.state
 
25
 
 
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
 
32
    else
 
33
        /usr/share/joystick/filter name="$NAME" serial="$SERIAL" vendor="$VENDOR" product="$PRODUCT" < $STORE > $STORE.new
 
34
    fi
 
35
fi
 
36
 
 
37
# Append the new calibration information
 
38
if [ -f $STORE.new ] && [ ! -z "$(cat $STORE.new)" ]; then
 
39
    echo >> $STORE.new
 
40
fi
 
41
if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then
 
42
    echo "DEVICE=\"$DEVICE\"" >> $STORE.new
 
43
fi
 
44
if [ ! -z "$NAME" ]; then
 
45
    echo "NAME=\"$NAME\"" >> $STORE.new
 
46
fi
 
47
if [ ! -z "$SERIAL" ]; then
 
48
    echo "SERIAL=\"$SERIAL\"" >> $STORE.new
 
49
fi
 
50
if [ ! -z "$VENDOR" ]; then
 
51
    echo "VENDOR=\"$VENDOR\"" >> $STORE.new
 
52
fi
 
53
if [ ! -z "$PRODUCT" ]; then
 
54
    echo "PRODUCT=\"$PRODUCT\"" >> $STORE.new
 
55
fi
 
56
jscal -p $1 | cut -d' ' -f-3 >> $STORE.new
 
57
jscal -q $1 | cut -d' ' -f-3 >> $STORE.new
 
58
 
 
59
if [ -f $STORE ]; then
 
60
    mv $STORE $STORE.old
 
61
fi
 
62
mv $STORE.new $STORE
 
63
rm -f $STORE.old