Recommended way to deal with intermittently connected Bluetooth devices?
I have a Playstation game controller that is connected to a Raspberry Pi. But after a while it might disconnect, and a while later, reconnect.
Currently I'm using evdev to create a listener for each device in `/dev/input`.
It seems like evdev doesn't pick up on events anymore after a disconnect+reconnect. Which makes sense.
What is the recommended way to deal with this situation?
- Should I continously scan for disconnects/reconnects of devices and destroy/recreate the listeners individually?
- Is there a mode where evdev will just grab whatever it can all the time through a central listener, deal with connects/disconnects, and let me filter out what I want?
My current code boils down to:
```
import asyncio
import evdev
self.inputs = [evdev.InputDevice(path) for path in evdev.list_devices()]
for device in self.inputs:
asyncio.ensure_future(self.print_events(device))
```
关闭于 2025-05-12 2 条评论