Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update aframe-button-controls.js #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kylebakerio
Copy link

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.
if (evt?.target?.inputSources[0]?.targetRayMode === "gaze") {
this.pseudoCardboardController.buttons[0] = {pressed:false};
}
});
Copy link
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
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
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.

None yet

2 participants