Files

57 lines
2.1 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
# Gesture diagnostic. Two stages, each answering exactly one question.
#
# Stage 1: is the panel delivering events to us at all?
# Stage 2: which direction and how many contacts does lisgd see?
#
# Stage 2 is the important one. Each line reads:
# [swipe]: Cfg(f=1/s=3/e=0/d=0) <=> Evt(f=2/s=3/e=1/d=2)
# ^ what you configured ^ what actually happened
# f=fingers, s=direction, e=edge, d=distance. Direction enum:
# 0=DU (down-to-up) 1=UD 2=LR (left-to-right) 3=RL (right-to-left)
#
# If Cfg and Evt agree on s= but differ on f=, your panel reports more contacts
# than you configured -- add them to FINGER_COUNTS in the config.
set -eu
for c in /usr/local/etc/socktop-swipe.env "$(dirname "$0")/../config.env"; do
[ -r "$c" ] && . "$c" && break
done
: "${TOUCH_DEV:?no TOUCH_DEV configured}"
: "${SCREEN_W:=1024}"
: "${SCREEN_H:=600}"
: "${SWIPE_THRESHOLD:=80}"
: "${SWIPE_LENIENCY:=30}"
echo "=============================================================="
echo "STAGE 1 -- is the panel delivering events at all?"
echo "Touch and drag on the TOUCHSCREEN for the next 6 seconds..."
echo "=============================================================="
bytes=$(timeout 6 cat "$TOUCH_DEV" 2>/dev/null | wc -c)
echo
echo " read $bytes bytes from $TOUCH_DEV"
if [ "$bytes" -eq 0 ]; then
cat <<-EOF
-> NOTHING. Stage 2 cannot work. Check, in order:
* are you in the 'input' group? (id -nG | grep input; needs a relogin)
* is TOUCH_DEV the right device? (tools/find-device.sh)
EOF
exit 1
fi
echo " -> device is live."
echo
echo "=============================================================="
echo "STAGE 2 -- what does lisgd actually see?"
echo "All four directions are bound, for 1, 2 and 3 contacts."
echo "Swipe LEFT, RIGHT, UP, DOWN. Ctrl-C when done."
echo "=============================================================="
set --
for f in 1 2 3; do
for g in RL LR DU UD; do
set -- "$@" -g "$f,$g,*,*,R,echo \" >>> FIRED: ${f}-contact $g\""
done
done
exec lisgd -v -d "$TOUCH_DEV" -w "$SCREEN_W" -h "$SCREEN_H" \
-t "$SWIPE_THRESHOLD" -r "$SWIPE_LENIENCY" "$@"