From 408cf577f5002e0bc0e402bd2ae67656a61d2a79 Mon Sep 17 00:00:00 2001 From: Cameron Brown Date: Tue, 17 Sep 2024 18:39:52 -0400 Subject: [PATCH] scripts/hw: Add 8bitdoo ultimate wireless controller install script, rename hw installers to 'hw' --- .github/workflows/ci.yaml | 2 +- scripts/hw/install_8bitdoo_udev | 58 +++++++++++++++++++ .../install_bvtsdk | 0 .../install_flycap | 0 .../install_sylphase_sonar | 0 .../install_udev_rules | 0 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 scripts/hw/install_8bitdoo_udev rename scripts/{hardware_installers => hw}/install_bvtsdk (100%) rename scripts/{hardware_installers => hw}/install_flycap (100%) rename scripts/{hardware_installers => hw}/install_sylphase_sonar (100%) rename scripts/{hardware_installers => hw}/install_udev_rules (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index eb948e194..7ce58df4d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,7 +50,7 @@ jobs: - name: Install BlueView Sonar SDK run: | cd $GITHUB_WORKSPACE/catkin_ws/src/mil - ./scripts/hardware_installers/install_bvtsdk --pass ${{ secrets.ZOBELISK_PASSWORD }} + ./scripts/hw/install_bvtsdk --pass ${{ secrets.ZOBELISK_PASSWORD }} ls mil_common/drivers/mil_blueview_driver echo $PWD - name: Install system dependencies diff --git a/scripts/hw/install_8bitdoo_udev b/scripts/hw/install_8bitdoo_udev new file mode 100755 index 000000000..81f544879 --- /dev/null +++ b/scripts/hw/install_8bitdoo_udev @@ -0,0 +1,58 @@ +#!/bin/bash + +# 8bitdoo Ultimate Wireless Controller installation script, by Robert Michael Smith +# Original source: https://gist.github.com/loopyd/a7ccbf37e27580ccbed859c26aa0a167 + +# Block script from running as non-root user +if [ "$EUID" -ne 0 ]; then + echo "Please run as root" + exit 1 +fi +# Blacklist Nintendo Switch Pro Controller Driver +echo blacklist hid_nintendo | tee /etc/modprobe.d/notendo.conf + +# Install xboxdrv +apt-get update +if ! dpkg -s 'xboxdrv' &>/dev/null; then + apt-get install -y xboxdrv +fi + +# Create udev rules +if [ ! -f '/etc/udev/rules.d' ]; then + mkdir -p '/etc/udev/rules.d' +fi +udev_rules='/etc/udev/rules.d/99-8bitdo-ultimate.rules' +if [ -f $udev_rules ]; then + sudo rm $udev_rules +fi +echo 'SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="2dc8", ATTR{idProduct}=="3106", ATTR{manufacturer}=="8BitDo", RUN+="/bin/systemctl start 8bitdo-ultimate-xinput@2dc8:3106"' | tee $udev_rules +echo 'SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="2dc8", ATTR{idProduct}=="3109", ATTR{manufacturer}=="8BitDo", RUN+="/bin/systemctl stop 8bitdo-ultimate-xinput@2dc8:3106"' | tee -a $udev_rules + +# Reload udev rules +udevadm control --reload-rules +udevadm trigger + +# Create systemd service +service_file='/etc/systemd/system/8bitdo-ultimate-xinput@.service' +if [ -f $service_file ]; then + rm $service_file +fi +echo '[Unit]' | tee $service_file +echo 'Description=8BitDo Ultimate Controller XInput mode xboxdrv daemon' | tee -a $service_file +echo '' | tee -a $service_file +echo '[Service]' | tee -a $service_file +echo 'Type=simple' | tee -a $service_file +echo 'ExecStart=/usr/bin/xboxdrv --mimic-xpad --silent --type xbox360 --device-by-id %i --force-feedback --detach-kernel-driver' | tee -a $service_file + +systemctl daemon-reload + +# Now install jstest-gtk to test the controller, which also installs all the joystick dependencies +# This fixes: +# - /dev/input/js0 not found +if ! dpkg -s 'jstest-gtk' &>/dev/null; then + apt-get install -y jstest-gtk +fi + +# Now open jstest-gtk and test the controller, remap the axis / buttons, then exit +# Save the configuration using the command: +# sudo jscal-store /dev/input/js0 diff --git a/scripts/hardware_installers/install_bvtsdk b/scripts/hw/install_bvtsdk similarity index 100% rename from scripts/hardware_installers/install_bvtsdk rename to scripts/hw/install_bvtsdk diff --git a/scripts/hardware_installers/install_flycap b/scripts/hw/install_flycap similarity index 100% rename from scripts/hardware_installers/install_flycap rename to scripts/hw/install_flycap diff --git a/scripts/hardware_installers/install_sylphase_sonar b/scripts/hw/install_sylphase_sonar similarity index 100% rename from scripts/hardware_installers/install_sylphase_sonar rename to scripts/hw/install_sylphase_sonar diff --git a/scripts/hardware_installers/install_udev_rules b/scripts/hw/install_udev_rules similarity index 100% rename from scripts/hardware_installers/install_udev_rules rename to scripts/hw/install_udev_rules