Skip to content

Commit c1998a7

Browse files
authored
Fix triggerchanged event not firing from touch v3 (#5149)
* Fix triggerchanged event not firing from touch v3 - button would be undefined if the onButtonChangedV3 function was ran * Add button definition back to onButtonChangedV3
1 parent fbfb4de commit c1998a7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/components/oculus-touch-controls.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,14 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
309309
},
310310

311311
onButtonChanged: function (evt) {
312+
var button = this.mapping[this.data.hand].buttons[evt.detail.id];
313+
if (!button) { return; }
312314
// move the button meshes
313315
if (this.isOculusTouchV3) {
314316
this.onButtonChangedV3(evt);
315317
} else {
316-
var button = this.mapping[this.data.hand].buttons[evt.detail.id];
317318
var buttonMeshes = this.buttonMeshes;
318319
var analogValue;
319-
if (!button) { return; }
320320

321321
if (button === 'trigger' || button === 'grip') { analogValue = evt.detail.state.value; }
322322

@@ -339,7 +339,6 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
339339
var button = this.mapping[this.data.hand].buttons[evt.detail.id];
340340
var buttonObjects = this.buttonObjects;
341341
var analogValue;
342-
if (!button) { return; }
343342

344343
analogValue = evt.detail.state.value;
345344
analogValue *= this.data.hand === 'left' ? -1 : 1;

0 commit comments

Comments
 (0)