Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/components/oculus-touch-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,14 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
},

onButtonChanged: function (evt) {
var button = this.mapping[this.data.hand].buttons[evt.detail.id];
if (!button) { return; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I fully understand the bug now. Since we were already checking the button existence in onButtonChangedV3 and early returing. this and old code should be equivalent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This jsfiddle is the simplest demonstration of what I mean https://jsfiddle.net/1xgnzv58/3/

That is what the current code does. If I have a touch v3 controller, it won't fire the triggerchanged event.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

// move the button meshes
if (this.isOculusTouchV3) {
this.onButtonChangedV3(evt);
this.onButtonChangedV3(button, evt);
Copy link
Member

@dmarcos dmarcos Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we define a variable button inside onButtonChangedV3 to decouple branches?

this.onButtonChangedV3(evt);

and

var button = this.mapping[this.data.hand].buttons[evt.detail.id]; inside

} else {
var button = this.mapping[this.data.hand].buttons[evt.detail.id];
var buttonMeshes = this.buttonMeshes;
var analogValue;
if (!button) { return; }

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

Expand All @@ -335,11 +335,9 @@ module.exports.Component = registerComponent('oculus-touch-controls', {
},

clickButtons: ['xbutton', 'ybutton', 'abutton', 'bbutton', 'thumbstick'],
onButtonChangedV3: function (evt) {
var button = this.mapping[this.data.hand].buttons[evt.detail.id];
onButtonChangedV3: function (button, evt) {
var buttonObjects = this.buttonObjects;
var analogValue;
if (!button) { return; }

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