Mobile touch device managers seem broken : No deviceSourceManagers available on mobile

Calling
const ds = this.deviceSourceManager.getDeviceSources(DeviceType.Touch);
or even
const ds = this.deviceSourceManager.getDeviceSources(DeviceType.Mouse);

both result in empty arrays.

Inspecting the deviceSourceManager object seems to imply there’s no devices :

Running Babylon.js Playground on mobile (chrome and firefox) both alert null.

I assume I’m doing something wrong as it’s unlikely input has broken this much on mobile, I’m just too tired to see exactly what :smiley:

cc @amoebachant

Taking a look…

It seems that, conceptually, a Touch ‘Device’ is only momentarily present when a touch is detected. I’m guessing if I touch the screen N times I’d temporarily see N touch devices too.

This works :

          let deviceSource: DeviceSource<any> = this.deviceSourceManager.getDeviceSource(DeviceType.Mouse);
          if (deviceSource == null) {
            deviceSource = this.deviceSourceManager.getDeviceSource(DeviceType.Touch);
          }

          if (deviceSource == null) {
            return;
          }

          const res = deviceSource.getInput(PointerInput.LeftClick);

Would be great to update the docs to make this explicit, are the docs open source too?

Yes, you’re right, touch devices are added on touch down and removed on touch up. An update to the docs would be very appreciated! Please feel free to do a PR in GitHub - BabylonJS/Documentation: Babylon.js's documentation website - thank you!