chrippa/ds4drv

Limit the number of simultaneous controllers

Opened this issue · 0 comments

Hi,
First of all thank you for this great library/module, pretty simple to use.

Use case :
As a dr4drv user I would like to be able to limit the number of simultaneous controllers (in my case limit to 1 at most), but still handle disconnections (allow new controllers at disconnection if the limit isn't reached).

More context about my use case :
We are using it at the DonkeyCar community to control RC Cars using PS4 controllers. I'm actually setting up a stand as part of a Makers event (called Nantes Makers Campus in France), we will let attendees play with several cars, so multiple PS4 controllers at the same time, each on connected to one rc-car. All rc-cars is running ds4drv an needs to be paired with only 1 controllers.

Implementation details :

  • Add a CLI argument called --controller-limit MAX_NUMBER_OF_CONTROLLERS
  • In the devices scanning loop if the limit is reached, wait for one device to be disconnected

I made a first implementation of this feature and will push a PR today, hope it's a good approach.

Thanks in advance.