Skip to content

Update aframe-button-controls.js#5

Open
kylebakerio wants to merge 3 commits intoDougReeder:masterfrom
kylebakerio:patch-2
Open

Update aframe-button-controls.js#5
kylebakerio wants to merge 3 commits intoDougReeder:masterfrom
kylebakerio:patch-2

Conversation

@kylebakerio
Copy link
Copy Markdown

See: issue #4

methodology: we still primarily rely on polling when poll=true, but when poll=true we also add the selectstart and selectend listeners in and specifically listen for the gaze controller in those listeners; when we detect those events, we update a fake psuedo-controller record. syntheticGamepad() recognizes when it is getting an update from the cardboard-gaze controller, and instead of just pushing two hardcoded button values as it did before this update, it refers to this psuedo-controller record and passes that along--in this way, the psuedo-controller record is picked up within the polling loop like other controllers when poll=true.

See: issue DougReeder#4 

methodology: we still primarily rely on polling when poll=true, but when poll=true we also add the `selectstart` and `selectend` listeners in and specifically listen for the `gaze` controller in those listeners; when we detect those events, we update a fake psuedo-controller record. `syntheticGamepad()` recognizes when it is getting an update from the cardboard-gaze controller, and instead of just pushing two hardcoded button values as it did before this update, it refers to this psuedo-controller record and passes that along--in this way, the psuedo-controller record is picked up within the polling loop like other controllers when poll=true.
Comment thread aframe-button-controls.js Outdated
if (evt?.target?.inputSources[0]?.targetRayMode === "gaze") {
this.pseudoCardboardController.buttons[0] = {pressed:false};
}
});
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Are squeezestart and squeezend not needed when poll is true?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Cardboard is single-button, so there's only select. It seems to me that within the non-poll old-style API, you always listened for a grip and trigger button event only (which were squeeze and select). The gaze controller, however, exposes only one button, which fires as select.

Normally we wouldn't listen to any events when poll = true, but in this hack to get the cardboard button working, we listen to those events for the gaze controller only, for this single button available only, and set the correct values to be observed by the poll loop.

Other values that would correspond to squeeze from other controllers are picked up in the 'normal' way, within the poll loop, when poll = true.

@DougReeder
Copy link
Copy Markdown
Owner

I've refactored the code to remove listeners on pause, but my tests of example.html in cardboard on current iOS and the old Chrome on my old Android phone show it not responding properly in Cardboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants