Skip to content

Commit 3f3a2d1

Browse files
committed
accommodate both names for Vive controllers: old 'OpenVR Gamepad' and new 'OpenVR Controller'
update docs
1 parent 84eb48d commit 3f3a2d1

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

‎docs/components/hand-controls.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ handles hand animations and poses.
4646

4747
## Assets
4848

49-
- [Left hand model](https://cdn.aframe.io/controllers/oculus-hands/leftHand.json)
50-
- [Right hand model](https://cdn.aframe.io/controllers/oculus-hands/rightHand.json)
49+
- [Left hand model](https://cdn.aframe.io/controllers/oculus-hands/v2/leftHand.json)
50+
- [Right hand model](https://cdn.aframe.io/controllers/oculus-hands/v2/rightHand.json)

‎docs/components/tracked-controls.md‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,21 @@ the entity, observes buttons state and emits appropriate events.
1818

1919
## Example
2020

21+
Note that due to recent browser-specific changes, Vive controllers may be returned
22+
by the Gamepad API with id values of either "OpenVR Gamepad" or "OpenVR Controller",
23+
so using idPrefix for Vive / OpenVR controllers is recommended.
24+
2125
```html
22-
<a-entity tracked-controls="controller: 0; id: OpenVR Gamepad"></a-entity>
26+
<a-entity tracked-controls="controller: 0; idPrefix: OpenVR"></a-entity>
2327
```
2428

2529
## Value
2630

27-
| Property | Description | Default Value |
28-
|-------------|----------------------------------------------------------------|------------------|
29-
| controller | Index of the controller in array returned by the Gamepad API. | 0 |
30-
| id | Selects the controller returned by the Gamepad API. | OpenVR Gamepad |
31+
| Property | Description | Default Value |
32+
|-------------|-------------------------------------------------------------- --|------------------------|
33+
| controller | Index of the controller in array returned by the Gamepad API. | 0 |
34+
| id | Selects the controller from the Gamepad API using exact match. | Match none by default! |
35+
| idPrefix | Selects the controller from the Gamepad API using prefix match. | undefined |
3136

3237
## Events
3338

‎src/components/tracked-controls.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports.Component = registerComponent('tracked-controls', {
1414
schema: {
1515
controller: {default: 0},
1616
id: {default: 'Match none by default!'},
17+
idPrefix: {default: undefined},
1718
rotationOffset: {default: 0}
1819
},
1920

@@ -26,10 +27,10 @@ module.exports.Component = registerComponent('tracked-controls', {
2627
update: function () {
2728
var controllers = this.system.controllers;
2829
var data = this.data;
29-
controllers = controllers.filter(hasId);
30+
controllers = controllers.filter(hasIdOrPrefix);
3031
// handId: 0 - right, 1 - left
3132
this.controller = controllers[data.controller];
32-
function hasId (controller) { return controller.id === data.id; }
33+
function hasIdOrPrefix (controller) { return data.idPrefix ? controller.id.indexOf(data.idPrefix) === 0 : controller.id === data.id; }
3334
},
3435

3536
tick: function (time, delta) {

‎src/components/vive-controls.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var isControllerPresent = require('../utils/tracked-controls').isControllerPrese
55
var VIVE_CONTROLLER_MODEL_OBJ_URL = 'https://cdn.aframe.io/controllers/vive/vr_controller_vive.obj';
66
var VIVE_CONTROLLER_MODEL_OBJ_MTL = 'https://cdn.aframe.io/controllers/vive/vr_controller_vive.mtl';
77

8-
var GAMEPAD_ID_PREFIX = 'OpenVR Gamepad';
8+
var GAMEPAD_ID_PREFIX = 'OpenVR ';
99

1010
/**
1111
* Vive Controls Component
@@ -128,7 +128,7 @@ module.exports.Component = registerComponent('vive-controls', {
128128
// handId: 0 - right, 1 - left, 2 - anything else...
129129
var controller = data.hand === 'right' ? 0 : data.hand === 'left' ? 1 : 2;
130130
// if we have an OpenVR Gamepad, use the fixed mapping
131-
el.setAttribute('tracked-controls', {id: GAMEPAD_ID_PREFIX, controller: controller, rotationOffset: data.rotationOffset});
131+
el.setAttribute('tracked-controls', {idPrefix: GAMEPAD_ID_PREFIX, controller: controller, rotationOffset: data.rotationOffset});
132132
if (!this.data.model) { return; }
133133
this.el.setAttribute('obj-model', {
134134
obj: VIVE_CONTROLLER_MODEL_OBJ_URL,

0 commit comments

Comments
 (0)