thp / thp/psmoveapi

Reliably detecting controller disconnection.

Open
#126 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
C
Stars
528
Forks
173
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the controller API around the move API handle, psmove_update_leds, and the input polling state described in the issue. Compare how these checks behave on OSX and Linux, then define a cross-platform connected-state contract and tests covering the listed disconnection cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
api, embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.