Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reliably detecting controller disconnection. #126

Open
whitingjp opened this issue Sep 17, 2014 · 1 comment
Open

Reliably detecting controller disconnection. #126

whitingjp opened this issue Sep 17, 2014 · 1 comment

Comments

@whitingjp
Copy link
Contributor

So it would be good to have a simple cross platform method for determining if the current controller is still connected to the machine. To the best of my knowledge such a thing does not currently exist. Disconnected can mean a bunch of different things, so I'll enumerate the ones I know of:

  • Controller out of bluetooth 'sight' (out of range, or shielded)
  • Controller turned off manually or out of battery
  • Controller unresponsive (broken)

I didn't find a concrete way of implementing it that was reliable on both OSX and Linux. The Current implementation of controller disconnection in Sportsfriends looks something like this:

bool connected = true;
if(!data.moves[i].api)
    connected = false;
else if(!data.moves[i].canUpdateLEDs)
    connected = false;
data.moves[i].timeSincePoll += dT;
if(data.moves[i].timeSincePoll > 1)
    connected = false;

So, to explain what is going on, for a controller to be seen as connected we must check:

  • We have a valid move api handle for controller.
  • We are able to successfully call psmove_update_leds on controller.
  • We have successfully pulled input data from the controller within the last second.

Anything shy of those requirements doesn't seem to be robust enough.

This is of course a fair bit of a faff to go through, and as far as I can see these are all things that we might be able to handle on the api side. Thoughts?

@thp
Copy link
Owner

thp commented Sep 26, 2014

Being able to read data from the controller, especially as it comes in with a high frequency, should be good. Maybe it also needs some holddown timer, i.e. if within 1 second, mark as "questionable", after 4 seconds (when the LEDs would go off) mark as "disconnected".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants