MOSS: a small, mostly 3D-printed litter-picking rover. Cleaner streets, one maker at a time.
Python
teleop launcher and flight check accept any /dev/input/js*: the pad on its cable keeps js1 after the dongle's js0
metroxddc333ab2995
diff --git a/tools/moss-teleop.sh b/tools/moss-teleop.shindex 89bfce9..b06b96f 100755--- a/tools/moss-teleop.sh+++ b/tools/moss-teleop.sh@@ -49,10 +49,12 @@ fiecho " none"echo "== 1/5 gamepad =="-if [ ! -e /dev/input/js0 ]; then- echo "NO PAD (no /dev/input/js0) - receiver plugged into the rover? if plugged but invisible: replug it, else sudo reboot"; exit 1+# any /dev/input/js*: the pad on its cable (an Xbox 360 pad to the kernel) keeps the number after the+# dongle's, and SDL numbers the pads it can see from 0 whatever the js number (MOSS_PAD_INDEX picks)+if ! ls /dev/input/js* >/dev/null 2>&1; then+ echo "NO PAD (no /dev/input/js*) - receiver or cable plugged into the rover? if plugged but invisible: replug it, else sudo reboot"; exit 1fi-echo " js0 present (if the pad is mute: button UNDER the pad, then move a stick)"+echo " pad(s): $(for j in /dev/input/js*; do n=$(basename $j); printf '%s=%s ' "$n" "$(cat /sys/class/input/$n/device/name 2>/dev/null | tr ' ' '_')"; done)(dongle mute: button UNDER the pad, then move a stick; cable: MOSS_PAD_LAYOUT=xinput)"echo "== 2/5 MOSS board =="PORT=$(ls /dev/serial/by-id/*QT_Py* 2>/dev/null | head -1)diff --git a/tools/moss_preflight.py b/tools/moss_preflight.pyindex 5376efc..deef8a0 100755--- a/tools/moss_preflight.py+++ b/tools/moss_preflight.py@@ -626,8 +626,16 @@ def check_wrist(ctx: dict) -> None:def check_gamepad(ctx: dict) -> None:section("gamepad")- if _exists(JS_PATH):- verdict(True, "gamepad", f"{JS_PATH} present (if mute: button under the pad, then move a stick)")+ pads = sorted(glob.glob("/dev/input/js*")) # any number: the pad on its cable keeps js1 after the dongle's js0+ if pads:+ names = []+ for j in pads:+ try:+ with open(f"/sys/class/input/{os.path.basename(j)}/device/name", encoding="utf-8") as f:+ names.append(f"{os.path.basename(j)}={f.read().strip()}")+ except OSError:+ names.append(os.path.basename(j))+ verdict(True, "gamepad", ", ".join(names) + " (dongle mute: button under the pad, then move a stick; cable = Xbox 360 pad: MOSS_PAD_LAYOUT=xinput)")returnusb = _usb_devices()if PAD_SHANWAN in usb: