Skip to content

Commit 249e389

Browse files
authored
Merge pull request aframevr#3961 from dmarcos/buttonChangedWebXR
Emit buttonchanged event for WebXR controllers for consistency with WebVR API
2 parents d7baf5b + 3da6ee2 commit 249e389

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/components/tracked-controls-webxr.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports.Component = registerComponent('tracked-controls-webxr', {
1111
this.updateController = this.updateController.bind(this);
1212
this.emitButtonUpEvent = this.emitButtonUpEvent.bind(this);
1313
this.emitButtonDownEvent = this.emitButtonDownEvent.bind(this);
14-
this.buttonEventDetails = {id: 'trigger'};
14+
this.buttonEventDetails = {id: 'trigger', state: {pressed: false}};
1515
},
1616

1717
play: function () {
@@ -45,13 +45,17 @@ module.exports.Component = registerComponent('tracked-controls-webxr', {
4545

4646
emitButtonDownEvent: function (evt) {
4747
if (!this.controller || evt.inputSource.handedness !== this.data.hand) { return; }
48+
this.buttonEventDetails.state.pressed = true;
4849
this.el.emit('buttondown', this.buttonEventDetails);
50+
this.el.emit('buttonchanged', this.buttonEventDetails);
4951
this.el.emit('triggerdown');
5052
},
5153

5254
emitButtonUpEvent: function (evt) {
5355
if (!this.controller || evt.inputSource.handedness !== this.data.hand) { return; }
56+
this.buttonEventDetails.state.pressed = false;
5457
this.el.emit('buttonup', this.buttonEventDetails);
58+
this.el.emit('buttonchanged', this.buttonEventDetails);
5559
this.el.emit('triggerup');
5660
},
5761

0 commit comments

Comments
 (0)