Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.216.145.37
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0555) :  /bin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //bin/jscal-store
#!/bin/sh

# Stores the current calibration settings for the given joystick
# (materialized by its device). The calibration settings are stored
# using the joystick's name and serial number if available, and its
# vendor and product codes if it's a USB device. If none of these can
# be determined, the settings are stored against the device name.

if [ -z "$1" ]; then
    echo "Usage: $0 {device}"
    echo "Stores the device's calibration for future use."
    exit 1
fi

if [ ! -x /sbin/udevadm ]; then
    echo Storing joystick configuration requires udev! >&2
    exit 1
fi

ident=$(mktemp)
/sbin/udevadm info -a -n $1 | /usr/libexec/joystick/ident > $ident
. $ident
rm $ident

STORE=/var/lib/joystick/joystick.state

if [ ! -d $(dirname $STORE) ]; then
    mkdir -p $(dirname $STORE)
    if [ $? -gt 0 ]; then
        echo Unable to create directory $(dirname $STORE)! >&2
        exit 1
    fi
fi

# Filter the existing file
if [ -f $STORE ]; then
    if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then
	echo "No product name or vendor available, calibration will be stored for the"
	echo "given device name ($DEVICE) only!"
	/usr/libexec/joystick/filter kernel="$DEVICE" < $STORE > $STORE.new
    else
	/usr/libexec/joystick/filter name="$NAME" serial="$SERIAL" vendor="$VENDOR" product="$PRODUCT" < $STORE > $STORE.new
    fi
fi

# Append the new calibration information
if [ -f $STORE.new ] && [ ! -z "$(cat $STORE.new)" ]; then
    echo >> $STORE.new
fi
if [ -z "$NAME" ] && [ -z "$VENDOR" ]; then
    echo "DEVICE=\"$DEVICE\"" >> $STORE.new
fi
if [ ! -z "$NAME" ]; then
    echo "NAME=\"$NAME\"" >> $STORE.new
fi
if [ ! -z "$SERIAL" ]; then
    echo "SERIAL=\"$SERIAL\"" >> $STORE.new
fi
if [ ! -z "$VENDOR" ]; then
    echo "VENDOR=\"$VENDOR\"" >> $STORE.new
fi
if [ ! -z "$PRODUCT" ]; then
    echo "PRODUCT=\"$PRODUCT\"" >> $STORE.new
fi
# First store the axes mapping, then the calibration
# as they must be restored in the same order
jscal -q $1 | cut -d' ' -f-3 >> $STORE.new
jscal -p $1 | cut -d' ' -f-3 >> $STORE.new

if [ -f $STORE ]; then
    mv $STORE $STORE.old
fi
mv $STORE.new $STORE
rm -f $STORE.old

Stv3n404 - 2023