Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Volume-Key-Selector install.sh #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions common/addon/Volume-Key-Selector/install.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# External Tools
chmod -R 0755 $MODPATH/common/addon/Volume-Key-Selector/tools

chooseport() {
chooseport_legacy() {
# Keycheck binary by someone755 @Github, idea for code below by Zappo @xda-developers
# Calling it first time detects previous input. Calling it second time will do what we want
[ "$1" ] && local delay=$1 || local delay=3
[ "$1" ] && local delay=$1 || local delay=19
local error=false
while true; do
timeout 0 $MODPATH/common/addon/Volume-Key-Selector/tools/$ARCH32/keycheck
Expand All @@ -14,12 +14,43 @@ chooseport() {
return 0
elif [ $sel -eq 41 ]; then
return 1
elif $error; then
abort "Volume key not detected!"
else
$error && abort "Volume key error!"
error=true
echo "Volume key not detected. Try again"
fi
done
}

chooseport() {
# Original idea by chainfire and ianmacd @xda-developers
[ "$1" ] && local delay=$1 || local delay=19
local error=false
while true; do
local count=0
while true; do
timeout $delay /system/bin/getevent -lqc 1 2>&1 > $TMPDIR/events &
sleep 0.5; count=$((count + 1))
if (`grep -q 'KEY_VOLUMEUP *DOWN' $TMPDIR/events`); then
return 0
elif (`grep -q 'KEY_VOLUMEDOWN *DOWN' $TMPDIR/events`); then
return 1
fi
[ $count -gt 6 ] && break
done
if $error; then
# abort "Volume key not detected!"
echo "Volume key not detected. Trying keycheck method"
export chooseport=chooseport_legacy VKSEL=chooseport_legacy
chooseport_legacy $delay
return $?
else
error=true
echo "Volume key not detected. Try again"
fi
done
}

# Keep old variable from previous versions of this
VKSEL=chooseport