Update aframe-button-controls.js#5
Conversation
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}; | ||
| } | ||
| }); |
There was a problem hiding this comment.
Are squeezestart and squeezend not needed when poll is true?
There was a problem hiding this comment.
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.
|
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. |
See: issue #4
methodology: we still primarily rely on polling when poll=true, but when poll=true we also add the
selectstartandselectendlisteners in and specifically listen for thegazecontroller 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.