Home | History | Annotate | Download | only in workloads
      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|ariel)
     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 ':[]
' ' ' | while read line
     61 do
     62 	set -- $line
     63 	code=$4
     64 	value=$((16#$5))
     65 	case $code in
     66 	(0035) x=$(convert $value $xmax $xscale);;
     67 	(0036) y=$(convert $value $ymax $yscale);;
     68 	(0030) tag="majorTouch";;
     69 	(0031) tag="minorTouch";;
     70 	(003a) tag="pressure";;
     71 	(0039) tag="trackingId";;
     72 	(--) echo unknown code=$code;;
     73 	esac
     74 	printf "%-10s %-4d  %-4d\n" $tag $x $y
     75 done
     76