Skip to content

Commit

Permalink
padconfig script wip
Browse files Browse the repository at this point in the history
  • Loading branch information
RogueM committed Jan 8, 2017
1 parent 56686f3 commit 326da67
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
126 changes: 126 additions & 0 deletions gamepads/padconfig.sh
@@ -0,0 +1,126 @@
#!/bin/bash

: <<'DISCLAIMER'
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
This script is licensed under the terms of the MIT license.
Unless otherwise noted, code reproduced herein
was written for this script.
- The Pimoroni Crew -
DISCLAIMER

# script control variables

FORCE=$1
GAMEPAD="picadehat-default"

# function define

confirm() {
if [ "$FORCE" == '-y' ]; then
true
else
read -r -p "$1 [y/N] " response < /dev/tty
if [[ $response =~ ^(yes|y|Y)$ ]]; then
true
else
false
fi
fi
}

prompt() {
read -r -p "$1 [y/N] " response < /dev/tty
if [[ $response =~ ^(yes|y|Y)$ ]]; then
true
else
false
fi
}

success() {
echo -e "$(tput setaf 2)$1$(tput sgr0)"
}

inform() {
echo -e "$(tput setaf 6)$1$(tput sgr0)"
}

warning() {
echo -e "$(tput setaf 1)$1$(tput sgr0)"
}

newline() {
echo ""
}

progress() {
count=0
until [ $count -eq $1 ]; do
echo -n "..." && sleep 1
((count++))
done
echo
}
sudocheck() {
if [ $(id -u) -ne 0 ]; then
echo -e "Install must be run as root. Try 'sudo ./$scriptname'\n"
exit 1
fi
}

sysclean() {
sudo apt-get clean && sudo apt-get autoclean
sudo apt-get -y autoremove &> /dev/null
}

sysupdate() {
if ! $UPDATE_DB; then
echo "Updating apt indexes..." && progress 3 &
sudo apt-get update 1> /dev/null || { warning "Apt failed to update indexes!" && exit 1; }
echo "Reading package lists..."
progress 3 && UPDATE_DB=true
fi
}

sysupgrade() {
sudo apt-get upgrade
sudo apt-get clean && sudo apt-get autoclean
sudo apt-get -y autoremove &> /dev/null
}

sysreboot() {
warning "Some changes made to your system require"
warning "your computer to reboot to take effect."
newline
if prompt "Would you like to reboot now?"; then
sync && sudo reboot
fi
}

: <<'MAINSTART'
Perform all global variables declarations as well as function definition
above this section for clarity, thanks!
MAINSTART

# copying gamepad configuration file

sudo service picadehatd stop
sudo rm /usr/bin/picadehatd
sudo cp $GAMEPAD /usr/bin/picadehatd
sudo chmod +x /usr/bin/picadehatd
sudo service picadehatd start

exit 0
5 changes: 5 additions & 0 deletions gamepads/picadehat-default 100755 → 100644
@@ -1,5 +1,10 @@
#!/usr/bin/env python

# Picade HAT default configuration
# maps all buttons, joystick and utility inputs
# as well as volume control on bcm13 and bcm26
# soft shutdown is supported

import time
import signal
import os
Expand Down
5 changes: 5 additions & 0 deletions gamepads/picadehat-no-vol 100755 → 100644
@@ -1,5 +1,10 @@
#!/usr/bin/env python

# Picade HAT basic configuration
# only maps buttons, joystick and utility inputs
# no volume control is implemented
# soft shutdown is supported

import time
import signal
import os
Expand Down
4 changes: 4 additions & 0 deletions gamepads/adafruit-pigrrl-pcb → gamepads/pigrrl-default 100755 → 100644
@@ -1,5 +1,9 @@
#!/usr/bin/env python

# Adafruit PiGRRL PCB default configuration
# maps buttons to GPIO for connection to PiTFT
# or mounting back to back to a Raspberry Pi Zero

import time
import signal
import os
Expand Down

0 comments on commit 326da67

Please sign in to comment.