Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tracker: Environment variable to choose camera
  • Loading branch information
thp committed Aug 7, 2012
1 parent adc7a3a commit 363f67a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README
Expand Up @@ -19,6 +19,18 @@ Advanced features:
* Orientation: Rotation tracking using gyro and accelerometer


Environment variables:

PSMOVE_TRACKER_CAMERA

If set, this is the camera that will be used when using
psmove_tracker_new() instead of using auto-detection

Example: export PSMOVE_TRACKER_CAMERA=2 # Will use the 3rd camera




|- Windows notes ----------- -- - -
| If you are using MinGW from the Qt SDK, you have to replace the file
| libbthprops.a in mingw\lib\ with the file of the same name from the
Expand Down
4 changes: 4 additions & 0 deletions include/psmove_tracker.h
Expand Up @@ -42,6 +42,10 @@ extern "C" {
/* For now, we only allow 1 controller to be tracked */
#define PSMOVE_TRACKER_MAX_CONTROLLERS 2

/* Name of the environment variable used to pick a camera */
#define PSMOVE_TRACKER_CAMERA_ENV "PSMOVE_TRACKER_CAMERA"


/* Opaque data structure, defined only in psmove_tracker.c */
struct _PSMoveTracker;
typedef struct _PSMoveTracker PSMoveTracker;
Expand Down
13 changes: 13 additions & 0 deletions src/psmove_tracker.c
Expand Up @@ -263,6 +263,19 @@ PSMoveTracker *psmove_tracker_new() {
}
#endif

char *camera_env = getenv(PSMOVE_TRACKER_CAMERA_ENV);
if (camera_env) {
char *end;
long camera_env_id = strtol(camera_env, &end, 10);
if (*end == '\0' && *camera_env != '\0') {
camera = (int)camera_env_id;
#ifdef PSMOVE_DEBUG
fprintf(stderr, "[PSMOVE] Using camera %d (%s is set)\n",
camera, PSMOVE_TRACKER_CAMERA_ENV);
#endif
}
}

return psmove_tracker_new_with_camera(camera);
}

Expand Down

0 comments on commit 363f67a

Please sign in to comment.