pybricks / support

Pybricks support and general discussion
MIT License
104 stars 6 forks source link

[Feature] Add a method to disconnect Xbox Controller #1663

Open PoweredUP-AC opened 1 month ago

PoweredUP-AC commented 1 month ago

Is your feature request related to a problem? Please describe. I wanted to make the hub and the Xbox controller shut down whenever the Xbox logo button is pressed. I assumed that hub.system.shutdown() would lead to controller being turned off the same way it does when the program ends, but it stays in pairing mode instead.

Describe the solution you'd like As disconnecting a controller with a dedicated method might be useful in some scenarios, I think that adding something like xbox.disconnect() is the correct way to do it.(there must be a better name though) This function should disconnect the conroller from the hub and turn it off (described above). It seems to me that this function needs to be called on system.shutdown(), too.

laurensvalk commented 1 month ago

Does the controller eventually turn off though?

As an alternative, you could perhaps end the program (raise SystemExit) instead of shutting the hub down. This should lead to a normal disconnect and the hub will automatically power off in a few minutes.

I assumed that hub.system.shutdown() would lead to controller being turned off the same way it does when the program ends

I would have assumed that too.

PoweredUP-AC commented 1 month ago

Xbox controller turns off by itself after some inbuilt cooldown, but it doesn't seem like a valid solution for this task. If the proposed method is not an easy thing to implement, I'd rather close this issue because of its minor importance