Skip to content

Commit

Permalink
bring in line with aframevr#2505
Browse files Browse the repository at this point in the history
  • Loading branch information
machenmusik committed Apr 24, 2017
1 parent 304d64b commit 70add4e
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/components/vive-tracker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var registerComponent = require('../core/component').registerComponent;
var bind = require('../utils/bind');
var getGamepadsByPrefix = require('../utils/tracked-controls').getGamepadsByPrefix;
var checkControllerPresentAndSetup = require('../utils/tracked-controls').checkControllerPresentAndSetup;
var emitIfAxesChanged = require('../utils/tracked-controls').emitIfAxesChanged;

var VIVE_CONTROLLER_MODEL_OBJ_URL = 'https://cdn.aframe.io/controllers/vive/vr_controller_vive.obj';
Expand Down Expand Up @@ -59,7 +59,7 @@ module.exports.Component = registerComponent('vive-tracker', {
this.lastControllerCheck = 0;
this.previousButtonValues = {};
this.bindMethods();
this.getGamepadsByPrefix = getGamepadsByPrefix; // to allow mock
this.checkControllerPresentAndSetup = checkControllerPresentAndSetup; // to allow mock
this.emitIfAxesChanged = emitIfAxesChanged; // to allow mock
},

Expand Down Expand Up @@ -87,21 +87,7 @@ module.exports.Component = registerComponent('vive-tracker', {

checkIfControllerPresent: function () {
var data = this.data;
var gamepads = this.el.sceneEl.systems['tracked-controls'].controllers;
var seenIndex = 0;
var controllerIndex = -1;
for (var i = 0; i < gamepads.length; i++) {
if (gamepads[i].id.indexOf(GAMEPAD_ID_PREFIX) < 0 || gamepads[i].hand) { continue; }
if (seenIndex === data.index) { controllerIndex = seenIndex; }
seenIndex++;
}
var isPresent = controllerIndex >= 0;
if (isPresent === this.controllerPresent) { return; }
this.controllerPresent = isPresent;
if (isPresent) {
this.injectTrackedControls(controllerIndex);
this.addEventListeners();
} else { this.removeEventListeners(); }
this.checkControllerPresentAndSetup(this, GAMEPAD_ID_PREFIX, { hand: '', index: data.index });
},

play: function () {
Expand Down

0 comments on commit 70add4e

Please sign in to comment.