Skip to content

Reliably detecting controller disconnection. #126

Open

Description

@whitingjp

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?

Activity

  1. thp commented on Sep 26, 2014

    @thp
    Owner

    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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions