XR controller issue

Hi,

I believe some buttons of XR controllers are not handled correctly.
Here is a small sample on the playground.
I tried it in 4.2.0-beta.17 on Oculus Rift, Oculus Quest, HTC Vive, and Google Daydream.

What’s wrong with this demo:

  1. Oculus Rift:
    Google Chrome 86.0.4240.111 (Official Build) (64-bit), started with flags:
    --enable-features=openvr --disable-features=XRSandbox --force-webxr-runtime=oculus
    All controls (buttons, triggers, squeeze, thumbstick) work fine, except buttons “B” and “Y”.

  2. Oculus Quest:
    Oculus Browser 11.1.2.0.0.252217267, Chromium 84.0.4147.125
    Same as Rift: buttons “B” and “Y” doesn’t work.

  3. HTC Vive:
    Google Chrome 86.0.4240.111 (Official Build) (64-bit), started with flags:
    Button “menu” (with three horizontal lines icon) doesn’t work.

  4. Google Daydream:
    Pixel XL + Google Chrome 86.0.4240.110
    The main button and touchpad don’t work.

Adding @RaananW to the thread.

Thanks for the thorough test!

  1. The reason B and Y don’t work is the way you interact with the components. You use this:
motionController.getComponentOfType("button")?.onButtonStateChangedObservable.add((ev: BABYLON.WebXRControllerComponent) => {
            console.log(`${ev.type} => touched: ${ev.touched}, pressed: ${ev.pressed}, value: ${ev.value}`);
        });

but this will only return the first component of type button. If you want to have all buttons, use the getAllComponentsOfType function:

 motionController.getAllComponentsOfType("button").forEach(controller => controller?.onButtonStateChangedObservable.add((ev: BABYLON.WebXRControllerComponent) => {
            console.log(`${ev.type} => touched: ${ev.touched}, pressed: ${ev.pressed}, value: ${ev.value}`);
        }));

I know there was a long discussion about the menu button and whether or not WebXR should support it. As far as I know, menu buttons are not supported in WebXR and are not being triggered inside WebXR. this is done to keep the native functionality.

Try console.log(controller.components) to see the list of supported components and which one you can use. It will list them all together with their type and ID

@RaananW, hi,

Thank you for the answer and explanation!
Everything is clear with Rift, Quest, and Vive controllers now.

Unfortunately, I still have an issue with Google Daydream. I understand that Daydream worth more dead than alive, but we still have a lot of users with this headset.

Here is a new version of my test: https://playground.babylonjs.com/#HGY1MA#10.

motionController.components says that Daydream has a “touchpad” component only. But it doesn’t handle onButtonStateChangedObservable and onAxisValueChangedObservable events.

And by the way, I think that there must a button component too. The touchpad is clickable on this controller.

Is it WebXR or Babylonjs issue? I tried this WebXR sample: https://immersive-web.github.io/webxr-samples/input-selection.html?usePolyfill=0, and it works fine on Google Daydream.

So I believe that this bug can be fixed on the Babylonjs side. I’m ready to help with tests on my old Pixel XL (just in case).

The touchpad is also a button (but is not of type button), the button state should also be updated so both onButton and onAxis observables should be triggered.

If the touchpad works in Input Selection , it should work in Babylon as well. I’ll need to find my Daydream and run a few tests. Will keep you updated

1 Like

So, there seems to be an error in the webxr input library. It reports the gamepad button index to be 2 but it is actually 0.

This playground (daydream only!!!) will work - https://playground.babylonjs.com/#HGY1MA#13 . line 74 is the “magic”. I force the button index (a private member) to be 0 instead of the reported 2.

I will ask the guys at the webxr input repo, let’s see what they are saying. We might be doing something wrong, but it might be an error on their side as well.

1 Like

Thank you very much for digging so deep!
Tried your Daydream sample - yes, it works fine. Please keep me informed of any ideas.

Update google-daydream.json by RaananW · Pull Request #184 · immersive-web/webxr-input-profiles · GitHub - already commited and will be fixed very soon :slight_smile:

1 Like

Oh, thank you for this WebXR PR fix!