File: xinput_calibrator_get_hal_calibration.sh

package info (click to toggle)
xinput-calibrator 0.7.5%2Bgit20140201-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, jessie, jessie-kfreebsd, stretch
  • size: 436 kB
  • ctags: 216
  • sloc: cpp: 2,292; sh: 80; makefile: 53
file content (74 lines) | stat: -rwxr-xr-x 2,477 bytes parent folder | download
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
# Get running calibration data from lshal
# (needed to recalibrate it, most easily fetchable from lshal)

export PATH=".:$PATH"
#FIND="hal-find-by-property"
CAPAB="hal-find-by-capability"
GET="hal-get-property"
BINARY="xinput_calibrator"

if [ "$(which $CAPAB)" = "" ]; then
    echo "Error: Can not find executable $CAPAB"
    exit 1
fi
if [ "$(which $GET)" = "" ]; then
    echo "Error: Can not find executable $GET"
    exit 1
fi


#udis=$($FIND --key input.x11_driver --string evtouch)
udis=$($CAPAB --capability input)

if [ "$udis" = "" ]; then
    echo "HAL Error: No input devices found (tested: info.capabilities 'input'))"
    exit 1
fi


echo "Trying all available input devices:"
# possibly multiple screens, iterate over each possibility
count=0
cmd=""
for udi in $udis; do
    name=$($GET --udi $udi --key info.product)
    minx=$($GET --udi $udi --key input.x11_options.minx 2> /dev/null)
    maxx=$($GET --udi $udi --key input.x11_options.maxx 2> /dev/null)
    miny=$($GET --udi $udi --key input.x11_options.miny 2> /dev/null)
    maxy=$($GET --udi $udi --key input.x11_options.maxy 2> /dev/null)

    # missing values ?
    if [ "$minx" = "" ] || [ "$maxx" = "" ] ||
        [ "$miny" = "" ] || [ "$maxy" = "" ]; then
        if [ "$minx" = "" ] && [ "$maxx" = "" ] &&
            [ "$miny" = "" ] && [ "$maxy" = "" ]; then
            # no calibration data available
            echo "\t'$name': no calibration data available"
        else
            # partial calibration data available ???
            echo "Error: '$name', only partial calibration data available (MinX='$minx' MaxX='$maxx' MinY='$miny' MaxY='$maxy'). All 4 current calibration values are need to recalibrate the device !"
        fi
    else
        count=$((count += 1))
        cmd="$BINARY --precalib $minx $maxx $miny $maxy"
        echo "\t'$name': values found, calibrate by running:"
        echo "$cmd"
    fi
done

if [ $count -gt 1 ]; then
    echo "Found multiple calibratable touchscreen devices, select one from above and execute the calibration program with the given parameters."
else
    if [ $count -eq 0 ]; then
        echo "Warning: No existing calibration data found, no parameters used."
        cmd="$BINARY"
    fi

    if [ "$(which $BINARY)" = "" ]; then
        echo "Error: can not find calibration program ($BINARY), please run it with the above parameters yourself."
    else
        echo "\nRunning calibration program..."
        $cmd
    fi
fi