Thread: pickel dude
View Single Post
Old 10-09-2015, 08:06 AM   #13
spelufo
Member
spelufo began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Oct 2013
Device: Kobo H2O
OK, it turns out the previous script was totally wrong. Pickels coordinates are weird. The arguments tp pickel are from the top-left corner on the screen. The output is (Y,X) with coordinates from the top-right corner of the screen. Also, if you pass 0 0 0 0 as one of the rectangles it will take that rectangle as the whole screen, which is why I use 0 0 1 1 for the rectangle I don't care about.

Code:
#!/bin/sh

[ $# -gt 0 ] || {
        echo 'Usage: tap-actiond.sh COMMAND'
        echo '  Wait for a sequence of taps on the touch screen and exec COMMAND when they occur.'
        exit 0
}

FB_MODE="$(fbset | grep '^mode' | cut -d \" -f 2)"
FB_MODE="${FB_MODE%-*}"
FB_W="${FB_MODE%x*}"
FB_H="${FB_MODE#*x}"

w=$(( $FB_W / 4))
h=$(( $FB_H / 5))

waithit() {
        coords="$(( $1 * $w )) $(( $2 * $h )) $w $h"
        /usr/local/Kobo/pickel wait-for-hit $coords 0 0 1 1 &>/dev/null
}

listen=true
while $listen; do
        
        waithit 3 4
        [ $? -eq 1 ] || continue
        start=$(date +'%s')

        waithit 2 4
        [ $? -eq 1 ] || continue
        [ $(( $(date +'%s') - $start )) -lt 3 ] || continue

        waithit 1 4
        [ $? -eq 1 ] || continue
        [ $(( $(date +'%s') - $start )) -lt 3 ] || continue

        waithit 0 4
        [ $? -eq 1 ] || continue
        [ $(( $(date +'%s') - $start )) -lt 3 ] || continue

        listen=false    

done

exec $@
spelufo is offline   Reply With Quote