setup.sh 1.3 KB

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/env bash
  2. # Per-boot device-permission grant for SteamOS (read-only rootfs -> no persistent udev rule).
  3. # Run ONCE PER BOOT from Desktop Mode: sudo ./setup.sh
  4. #
  5. # Opens, for this boot only (nothing on the read-only FS changes -- re-run after a reboot):
  6. # * /dev/ttyACM* -- the nRF (ReversePuck) CDC link
  7. # * the Deck controller's usbfs node -- so the app's libusb DeckSource can detach + read it
  8. # (28DE:1205); this is what lets it take the pad from Steam
  9. # /dev/input/event* is already granted to the active session (logind ACL) for the --evdev fallback.
  10. set -e
  11. shopt -s nullglob
  12. for f in /dev/ttyACM*; do chmod a+rw "$f" && echo "opened CDC $f"; done
  13. # Find the Steam Deck controller (Valve 28DE:1205) usbfs node and open it for libusb.
  14. opened=0
  15. for dd in /sys/bus/usb/devices/*; do
  16. [ -r "$dd/idVendor" ] || continue
  17. if [ "$(cat "$dd/idVendor" 2>/dev/null)" = "28de" ] &&
  18. [ "$(cat "$dd/idProduct" 2>/dev/null)" = "1205" ]; then
  19. busnum=$(cat "$dd/busnum"); devnum=$(cat "$dd/devnum")
  20. node=$(printf "/dev/bus/usb/%03d/%03d" "$busnum" "$devnum")
  21. chmod a+rw "$node" && echo "opened controller usbfs $node ($dd)" && opened=1
  22. fi
  23. done
  24. [ "$opened" = 1 ] || echo "WARNING: Deck controller 28DE:1205 not found on USB (is it the built-in pad?)"
  25. echo "done (this boot only)."