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

VNC: support for intel, Model 3, new firmware #82

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
26 changes: 20 additions & 6 deletions src/scripts/misc/vnc-remote-control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@
CHROOT="/home/tesla/alpine3.11"

function mountStuff() {
mount -o remount,exec /home # need this to allow execution on /home
mount -o remount,exec,suid,symfollow /home # need this to allow execution on /home
mount -o bind /dev ${CHROOT}/dev
mount -o bind /proc ${CHROOT}/proc
mount -t sysfs archsys ${CHROOT}/sys
mount -o bind /tmp ${CHROOT}/tmp
mount -t devpts archdevpts ${CHROOT}/dev/pts
mount /var -o remount,exec
mount /var -o remount,exec,suid,symfollow
mount -o bind /var ${CHROOT}/var
}

if [ ! -d "$CHROOT" ]; then
ALPINE_URI="http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/armhf/alpine-minirootfs-3.11.3-armhf.tar.gz"
ARCH=$(uname -m)
ALPINE_URI="http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/$ARCH/alpine-minirootfs-3.11.3-$ARCH.tar.gz"
curl -O ${ALPINE_URI}
mkdir -p ${CHROOT}
tar -zxvf $(basename ${ALPINE_URI}) -C ${CHROOT}
Expand All @@ -40,14 +41,27 @@ else
mountStuff
fi

VERTICAL_DISPLAY=true
ROTATION=90
if [[ "$(< /var/etc/chassistype)" == "Model3"]]; then
VERTICAL_DISPLAY=false
ROTATION=0
fi

if [ ! -f "/var/captureClicks.sh" ]; then
cat > /var/captureClicks.sh <<'EOF'
cat > /var/captureClicks.sh << 'EOF'
#!/bin/bash
EOF << "VERTICAL_DISPLAY=${VERTICAL_DISPLAY}" << 'EOF'

while read line; do
if [[ "$line" == *ButtonPress* ]]; then
y=$(echo $line | cut -d " " -f 3)
x=$((1200 - $(echo $line | cut -d " " -f 4)))
x=$(echo $line | cut -d " " -f 4)

if [ "$VERTICAL_DISPLAY" == true ]; then
x=$((1200 - $x))
fi

curl -s "http://cid:4070/injectMouseEvent?action=down&x=$x&y=$y&id=0"
sleep 0.1
curl -s "http://cid:4070/injectMouseEvent?action=release&x=$x&y=$y&id=0"
Expand All @@ -62,5 +76,5 @@ cat <<EOF | chroot ${CHROOT} /bin/bash
xauth generate :0 . trusted
xauth add ${HOST}:0 . $(xxd -l 16 -p /dev/urandom)
xauth list
x11vnc -noipv6 -display :0 -nopw -rfbport 5900 -rotate 90 -cursor none -nodragging -pipeinput "/var/captureClicks.sh"
DISPLAY=:0 x11vnc -noipv6 -display :0 -nopw -rotate ${ROTATION} -rfbport 5900 -nodragging -pipeinput "/var/captureClicks.sh"
EOF