OSDN Git Service

Merge "Remove system/extras/tests/bionic." am: 1205856a99
[android-x86/system-extras.git] / tests / workloads / capture.sh
1 # Capture and display input events and coordinates
2 #
3 # Usage: ./capture.sh
4 #
5
6 # do a throw-away adb in case the server is out-of-date
7 adb devices -l 2>&1 >/dev/null
8
9 while [ $# -gt 0 ]
10 do
11         case "$1" in
12         (-d) DEVICE=$2; shift;;
13         (*)
14                 echo Unknown option $1
15                 exit 1;;
16         esac
17         shift
18 done
19
20 if [ "$DEVICE" = "" ]; then
21         devInfo=$(adb devices -l | grep -v ^List | head -1)
22         set -- $devInfo
23         echo devInfo=$devInfo
24         DEVICE=$(echo $4 | sed 's/product://')
25 fi
26
27 function convert {
28         in=$1
29         max=$2
30         scale=$3
31         if [ $max -eq 0 ]; then
32                 echo $in
33         else
34                 ((out=in*scale/max))
35                 echo $out
36         fi
37 }
38
39
40 case $DEVICE in
41 (shamu|hammerhead|bullhead)
42         # no scaling necessary
43         xmax=0
44         ymax=0;;
45 (volantis)
46         xmax=3060
47         xscale=1500
48         ymax=2304
49         yscale=1950;;
50 (*)
51         echo "Error: No display information available for $DEVICE"
52         exit 1;;
53 esac
54
55 echo Capturing input for $DEVICE...
56 stdbuf -o0 adb shell getevent -t |
57         stdbuf -o0 grep "event.: 0003" |
58         stdbuf -o0 grep "0003 003[0156a9]" |
59         stdbuf -o0 tr ':[]\r' ' ' | while read line
60 do
61         set -- $line
62         code=$4
63         value=$((16#$5))
64         case $code in
65         (0035) x=$(convert $value $xmax $xscale);;
66         (0036) y=$(convert $value $ymax $yscale);;
67         (0030) tag="majorTouch";;
68         (0031) tag="minorTouch";;
69         (003a) tag="pressure";;
70         (0039) tag="trackingId";;
71         (--) echo unknown code=$code;;
72         esac
73         printf "%-10s %-4d  %-4d\n" $tag $x $y
74 done