Last active
February 18, 2023 04:23
-
-
Save drew-wallace/08d41a61e03ab2e959d0fb8c3f14980b to your computer and use it in GitHub Desktop.
Set up Raspberry Pi for PC streaming with Parsec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo raspi-config | |
# Change password (1) | |
# Change hostname if you want (2) | |
# Change locale/timezone/keyboard/wifi region in Localisation (4) | |
# Enable ssh in Interfacing (5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "gpu_mem=128 | |
audio_pwm_mode=2 | |
display_default_lcd=1" | sudo tee -a /boot/config.txt | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get dist-upgrade -y | |
sudo apt-get install -y vim git python-dev python-setuptools | |
sudo easy_install rpi.gpio | |
git clone https://github.com/craic/pi_power.git | |
sed -i 's/ green_constant()/ # green_constant()/g` pi_power/pi_power_leds.py | |
sed -i 's/# yellow_constant()/yellow_constant()/g` pi_power/pi_power_leds.py | |
sed -i 's/exit 0/\/home\/pi\/pi_power_leds.py \&\nexit 0/g' /etc/rc.local | |
sed -i 's/exit 0/\/home\/pi\/pi_power.py \&\nexit 0/g' /etc/rc.local | |
sudo reboot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# fix wifi | |
sudo apt-get install -y build-essential dkms bc vim libncurses5-dev | |
git clone https://github.com/notro/rpi-source.git | |
cd rpi-source | |
chmod +x rpi-source | |
sudo ./rpi-source | |
cd .. | |
git clone https://github.com/brandon-bailey/rtl8822bu.git | |
cd rtl8822bu | |
sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile | |
sed -i 's/CONFIG_PLATFORM_ARM_RPI = n/CONFIG_PLATFORM_ARM_RPI = y/g' Makefile | |
sudo make | |
sudo make install | |
#sudo sed -i 's/iface eth0 inet manual/iface eth0 inet dhcp/g' /etc/network/interfaces | |
#sudo sed -i 's/iface wlan0 inet manual/iface wlan0 inet dhcp/g' /etc/network/interfaces | |
#sudo echo 'network={\n\tssid="SSID-GOES-HERE"\n\tpsk="WIFI-PASSWORD-GOES-HERE"\n}' >> /etc/wpa_supplicant/wpa_supplicant.conf | |
sudo reboot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get install -y python3 python3-pip | |
git clone https://github.com/pimoroni/python-multitouch.git | |
cd python-multitouch/library | |
sudo python3 setup.py install | |
cd | |
cat << 'EOF' > touchpad | |
#!/usr/bin/env python3 | |
import struct | |
import time | |
import math | |
import glob | |
import uinput | |
import pyudev | |
import os | |
from ft5406 import Touchscreen, TS_PRESS, TS_RELEASE, TS_MOVE | |
from math import floor | |
def read_and_emulate_mouse(event, touch): | |
global startX | |
global startY | |
global startTime | |
global mouse | |
if event == TS_PRESS: | |
# print("Got Press", touch) | |
(startX, startY) = touch.position | |
startTime = time.time() | |
# if event == TS_RELEASE: | |
# print("Got release", touch) | |
# if event == TS_MOVE: | |
# print("Got move", touch) | |
(x, y) = touch.position | |
(last_x, last_y) = touch.last_position | |
movement = math.sqrt(pow(x - startX, 2) + pow(y - startY, 2)) | |
if movement < 20: | |
if event == TS_RELEASE: | |
duration = time.time() - startTime | |
if duration > 1: | |
print("Right click") | |
mouse.emit(uinput.BTN_RIGHT, 1) | |
mouse.emit(uinput.BTN_RIGHT, 0) | |
(startX, startY) = touch.position | |
else: | |
print("Left click") | |
mouse.emit(uinput.BTN_LEFT, 1) | |
mouse.emit(uinput.BTN_LEFT, 0) | |
(startX, startY) = touch.position | |
else: | |
mouse.emit(uinput.REL_X, x - last_x, syn=False) | |
mouse.emit(uinput.REL_Y, y - last_y) | |
if __name__ == "__main__": | |
global mouse | |
os.system("modprobe uinput") | |
#os.system("chmod 666 /dev/hidraw*") | |
os.system("chmod 666 /dev/uinput*") | |
mouse = uinput.Device([ | |
uinput.BTN_LEFT, | |
uinput.BTN_RIGHT, | |
uinput.REL_X, | |
uinput.REL_Y, | |
]) | |
ts = Touchscreen() | |
for touch in ts.touches: | |
touch.on_press = read_and_emulate_mouse | |
touch.on_release = read_and_emulate_mouse | |
touch.on_move = read_and_emulate_mouse | |
ts.run() | |
while True: | |
try: | |
pass | |
except KeyboardInterrupt: | |
ts.stop() | |
exit() | |
EOF | |
chmod +x touchpad | |
cat << 'EOF' > hotcorners | |
#!/usr/bin/env python3 | |
import struct | |
import time | |
import math | |
import glob | |
from ft5406 import Touchscreen, TS_PRESS, TS_RELEASE, TS_MOVE | |
from math import floor | |
from subprocess import call | |
import rpi_backlight as bl | |
def read_and_emulate_mouse(event, touch): | |
global startX | |
global startY | |
global startTime | |
global shouldRun | |
if event == TS_PRESS: | |
# print("Got Press", touch) | |
(startX, startY) = touch.position | |
startTime = time.time() | |
# if event == TS_RELEASE: | |
# print("Got release", touch) | |
# if event == TS_MOVE: | |
# print("Got move", touch.position) | |
(x, y) = touch.position | |
(last_x, last_y) = touch.last_position | |
movement = math.sqrt(pow(x - startX, 2) + pow(y - startY, 2)) | |
# top left: brightness | |
if startX < 10 and startY > 469 and x <= 200: | |
call(["amixer", "cset", "numid=1", "--", str(floor(x/2)) + '%']) | |
# bottom left: volume | |
if startX < 10 and startY < 10 and x <= 244: | |
bl.set_brightness(x + 11) | |
# top right: quit parsec | |
if startX > 788 and startY < 10: | |
if movement < 20 and event == TS_RELEASE and (time.time() - startTime) >= 3: | |
call(["killall", "parsec"]) | |
call(["killall", "screen"]) | |
call(["./touchscreen"]) | |
shouldRun = False | |
exit() | |
if startX > 788 and startY > 469: | |
if movement < 20 and event == TS_RELEASE and (time.time() - startTime) >= 3: | |
call(["killall", "screen"]) | |
call(["screen", "-dm", "-S", "jcdriver", "./go/bin/jcdriver"]) | |
if __name__ == "__main__": | |
global shouldRun | |
shouldRun = True | |
ts = Touchscreen() | |
for touch in ts.touches: | |
touch.on_press = read_and_emulate_mouse | |
touch.on_release = read_and_emulate_mouse | |
touch.on_move = read_and_emulate_mouse | |
ts.run() | |
while shouldRun: | |
try: | |
pass | |
except KeyboardInterrupt: | |
ts.stop() | |
exit() | |
ts.stop() | |
exit() | |
EOF | |
chmod +x hotcorners | |
sudo pip3 install python-uinput pyudev rpi_backlight | |
cat << 'EOF' > touchscreen | |
#!/bin/bash | |
lcd=$(cat /boot/config.txt | awk -F '[=]' '/display_default_lcd/{print $2}' | awk '{print $1}') | |
if [ $lcd -eq 1 ]; then | |
xinput enable "FT5406 memory based driver" | |
sudo killall python3 | |
else | |
xinput enable "pointer:python-uinput" | |
fi | |
EOF | |
chmod +x touchscreen | |
cat << 'EOF' > start-touchscreen | |
#!/bin/bash | |
lcd=$(cat /boot/config.txt | awk -F '[=]' '/display_default_lcd/{print $2}' | awk '{print $1}') | |
if [ $lcd -eq 0 ]; then | |
xinput disable "FT5406 memory based driver" | |
sudo ./touchpad & | |
fi | |
EOF | |
chmod +x start-touchscreen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get install -y binutils bison libudev-dev screen | |
# install gvm | |
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) | |
source /home/pi/.gvm/scripts/gvm | |
# install go | |
gvm install go1.4 | |
gvm use go1.4 | |
export GOROOT_BOOTSTRAP=$GOROOT | |
gvm install go1.8 | |
gvm use go1.8 --default | |
mkdir -p ~/go/src | |
cat << "EOF" >> ~/.profile | |
export PATH=$PATH:/usr/local/go/bin | |
export GOPATH=$HOME/go | |
EOF | |
source ~/.profile | |
# cat /proc/bus/input/devices | |
cd ~/go/src | |
git clone https://github.com/riking/joycon.git | |
cd joycon/prog4 | |
go get ./... | |
cd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "3" | sudo select-editor | |
sudo apt-get install -y --no-install-recommends xserver-xorg xinit | |
sudo apt-get install -y --no-install-recommends raspberrypi-ui-mods lxterminal gvfs | |
sudo apt-get install -y xvkbd xinput | |
mkdir Desktop | |
cat << 'EOF' > keyboard | |
#!/bin/bash | |
xvkbd -no-keypad -geometry 800x200+0+250 | |
EOF | |
chmod +x keyboard | |
cat << 'EOF' > Desktop/Keyboard.desktop | |
[Desktop Entry] | |
Name=Keyboard | |
Comment=Keyboard launcher | |
Icon=/usr/share/pixmaps/openbox.xpm | |
Exec=/home/pi/keyboard | |
Type=Application | |
Encoding=UTF-8 | |
Terminal=false | |
Categories=None; | |
EOF | |
cat << 'EOF' > hdmi_out | |
#!/bin/bash | |
sudo sed -i 's/display_default_lcd=1/display_default_lcd=0/g' /boot/config.txt | |
sudo amixer cset numid=3 2 | |
sudo reboot | |
EOF | |
chmod +x hdmi_out | |
cat << 'EOF' > Desktop/HDMI_Out.desktop | |
[Desktop Entry] | |
Name=HDMI Out | |
Comment=Toggle HDMI output on | |
Icon=/usr/share/pixmaps/openbox.xpm | |
Exec=/home/pi/hdmi_out | |
Type=Application | |
Encoding=UTF-8 | |
Terminal=false | |
Categories=None; | |
EOF | |
cat << 'EOF' > lcd_out | |
#!/bin/bash | |
sudo sed -i 's/display_default_lcd=0/display_default_lcd=1/g' /boot/config.txt | |
sudo amixer cset numid=3 1 | |
sudo reboot | |
EOF | |
chmod +x lcd_out | |
cat << 'EOF' > Desktop/LCD_Out.desktop | |
[Desktop Entry] | |
Name=LCD Out | |
Comment=Toggle LCD output on | |
Icon=/usr/share/pixmaps/openbox.xpm | |
Exec=/home/pi/lcd_out | |
Type=Application | |
Encoding=UTF-8 | |
Terminal=false | |
Categories=None; | |
EOF | |
echo "@/home/pi/start-touchscreen" | tee -a .config/lxsession/LXDE-pi/autostart | |
sudo reboot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -z $1 || -z $2 ]]; then | |
echo 'Need Parsec username and password like this: ./6-parsec username password' | |
exit 1 | |
fi | |
#install Parsec | |
wget https://s3.amazonaws.com/parsec-build/package/parsec-rpi.deb | |
sudo dpkg -i parsec-rpi.deb | |
echo "${1} | |
${2} | |
y | |
0" | parsec | |
# sign into parsec and save credentials | |
cat << 'EOF' > .parsec/controller.txt | |
050000007e0500000820000001000000,Joy-Con(s),platform:Linux,x:b3,a:b0,b:b1,y:b2,back:b8,guide:b10,start:b9,dpleft:b16,dpdown:b15,dpright:b17,dpup:b14,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3, | |
EOF | |
cat << 'EOF' > start-parsec | |
#!/bin/bash | |
echo "y | |
1" | parsec | |
EOF | |
chmod +x start-parsec | |
cat << 'EOF' > parsec | |
#!/bin/bash | |
lcd=$(cat /boot/config.txt | awk -F '[=]' '/display_default_lcd/{print $2}' | awk '{print $1}') | |
if [ $lcd -eq 1 ]; then | |
sudo ./touchpad & | |
fi | |
xinput disable "FT5406 memory based driver" | |
./start-parsec & | |
sudo ./hotcorners & | |
sudo screen -dm -S jcdriverScreen ./go/bin/jcdriver | |
sleep 1 | |
xinput disable "pointer:python-uinput" | |
EOF | |
chmod +x parsec | |
cat << 'EOF' > Desktop/Parsec.desktop | |
[Desktop Entry] | |
Name=Parsec | |
Comment=My custom Parsec launcher | |
Icon=/usr/share/pixmaps/openbox.xpm | |
Exec=lxterminal -t "Running all the things" --working-directory=/home/pi/ -e ./parsec | |
Type=Application | |
Encoding=UTF-8 | |
Terminal=false | |
Categories=None; | |
EOF |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-std=c11 -D_POSIX_C_SOURCE=199309L | |
#!/bin/bash | |
# setup bluetooth for joycons | |
bluetoothctl -a | |
scan on | |
pair <joycon L mac address> | |
pair <joycon R mac address> | |
trust <joycon L mac address> | |
trust <joycon R mac address> | |
quit | |
mkdir -p ~/scripts | |
cat << 'EOL' >> ~/scripts/autopair | |
#!/bin/bash | |
bluetoothctl << EOF | |
connect <joycon L mac address> | |
connect <joycon R mac address> | |
EOF | |
EOL | |
chmod +x ~/scripts/autopair | |
(sudo crontab -l ; echo "@reboot /home/pi/scripts/autopair") | sudo crontab - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment