Skip to content

Commit

Permalink
allow multiple ID prefixes with pipe delimiter; support GearVR, Gear …
Browse files Browse the repository at this point in the history
…VR and Oculus Go with gearvr-controls
  • Loading branch information
machenmusik authored and dmarcos committed Mar 9, 2018
1 parent 51354f1 commit e399875
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/gearvr-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var GEARVR_CONTROLLER_MODEL_BASE_URL = 'https://cdn.aframe.io/controllers/samsun
var GEARVR_CONTROLLER_MODEL_OBJ_URL = GEARVR_CONTROLLER_MODEL_BASE_URL + 'gear_vr_controller.obj';
var GEARVR_CONTROLLER_MODEL_OBJ_MTL = GEARVR_CONTROLLER_MODEL_BASE_URL + 'gear_vr_controller.mtl';

var GAMEPAD_ID_PREFIX = 'Gear VR';
var GAMEPAD_ID_PREFIX = 'Gear VR|GearVR|Oculus Go';

/**
* Gear VR controls.
Expand Down
12 changes: 11 additions & 1 deletion src/utils/tracked-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,20 @@ function findMatchingController (controllers, filterIdExact, filterIdPrefix, fil
var i;
var matchingControllerOccurence = 0;
var targetControllerMatch = filterControllerIndex || 0;

var filterIdPrefixes;
if (filterIdPrefix && filterIdPrefix.indexOf('|') >= 0) {
filterIdPrefixes = filterIdPrefix.split('|');
}
for (i = 0; i < controllers.length; i++) {
controller = controllers[i];
// Determine if the controller ID matches our criteria
if (filterIdPrefixes) {
var matches = false;
for (var prefix in filterIdPrefixes) {
if (prefix && controller.id.indexOf(prefix) === -1) { matches = true; }
}
if (!matches) { continue; }
} else
if (filterIdPrefix && controller.id.indexOf(filterIdPrefix) === -1) { continue; }
if (!filterIdPrefix && controller.id !== filterIdExact) { continue; }

Expand Down

0 comments on commit e399875

Please sign in to comment.