dears
I have a USB gamepad that is not always detected at boot time, after 1 reboot out of 5, the device does not appear in /dev/input. If I unplug the device and plug it back in, then it suddenly appears.
I have tried the following code at boot time to detect the presence of the gamepad and if not to reset the USB, but that does not seem to work :
if [ -e "/dev/input/js0" ]; then
echo "/dev/input/js0 found!"
else
echo "/dev/input/js0 not found. Retrying..."
for ((i = 1; i <= 5; i++)); do
# restart USB
sudo systemctl restart udev
sleep 0.5
if [ -e "/dev/input/js0" ]; then
echo "/dev/input/js0 found after retry $i."
break
fi
done
fi
Any idea how I could force "retries" ? Alternatively if this would be due to timings, is it possible to add a "pause" somewhere in the boot sequence prior the PI checking for USB devices ?
thanks for your help
Best Regards
John
I have a USB gamepad that is not always detected at boot time, after 1 reboot out of 5, the device does not appear in /dev/input. If I unplug the device and plug it back in, then it suddenly appears.
I have tried the following code at boot time to detect the presence of the gamepad and if not to reset the USB, but that does not seem to work :
if [ -e "/dev/input/js0" ]; then
echo "/dev/input/js0 found!"
else
echo "/dev/input/js0 not found. Retrying..."
for ((i = 1; i <= 5; i++)); do
# restart USB
sudo systemctl restart udev
sleep 0.5
if [ -e "/dev/input/js0" ]; then
echo "/dev/input/js0 found after retry $i."
break
fi
done
fi
Any idea how I could force "retries" ? Alternatively if this would be due to timings, is it possible to add a "pause" somewhere in the boot sequence prior the PI checking for USB devices ?
thanks for your help
Best Regards
John
Statistics: Posted by jcoe2412 — Wed Mar 27, 2024 8:19 pm — Replies 0 — Views 28