From 31975eef0a7aa8996ca3358ebd01d9261495fde2 Mon Sep 17 00:00:00 2001 From: Dave Solares <50599569+PolygonalSun@users.noreply.github.com> Date: Wed, 29 Jun 2022 14:19:32 -0700 Subject: [PATCH 1/2] Passive support check wasn't working properly so logic was changed to make it work --- .../InputDevices/webDeviceInputSystem.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/dev/core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts b/packages/dev/core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts index 6d5a0e4b887..e44ca7fc2af 100644 --- a/packages/dev/core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts +++ b/packages/dev/core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts @@ -104,7 +104,7 @@ export class WebDeviceInputSystem implements IDeviceInputSystem { throw `Unable to find device ${DeviceType[deviceType]}`; } - if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense && navigator.getGamepads) { + if (deviceType >= DeviceType.DualShock && deviceType <= DeviceType.DualSense) { this._updateDevice(deviceType, deviceSlot, inputIndex); } @@ -456,7 +456,7 @@ export class WebDeviceInputSystem implements IDeviceInputSystem { } } - if (!document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) { + if (!document.pointerLockElement) { try { this._elementToAttachTo.setPointerCapture(this._mouseId); } catch (e) { @@ -465,7 +465,7 @@ export class WebDeviceInputSystem implements IDeviceInputSystem { } } else { // Touch; Since touches are dynamically assigned, only set capture if we have an id - if (evt.pointerId && !document.pointerLockElement && this._elementToAttachTo.hasPointerCapture) { + if (evt.pointerId && !document.pointerLockElement) { try { this._elementToAttachTo.setPointerCapture(evt.pointerId); } catch (e) { @@ -592,13 +592,11 @@ export class WebDeviceInputSystem implements IDeviceInputSystem { const noop = function () {}; try { - const options: object = { - passive: { - get: function () { - passiveSupported = true; - }, + const options = Object.defineProperty({}, "passive", { + get: function () { + passiveSupported = true; }, - }; + }); this._elementToAttachTo.addEventListener("test", noop, options); this._elementToAttachTo.removeEventListener("test", noop, options); From 52689f5859414f9421deca5ba583a8aa4929be04 Mon Sep 17 00:00:00 2001 From: Dave Solares <50599569+PolygonalSun@users.noreply.github.com> Date: Wed, 29 Jun 2022 15:12:47 -0700 Subject: [PATCH 2/2] forgot passive to be set to true --- .../core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/dev/core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts b/packages/dev/core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts index e44ca7fc2af..e3c6daf3b27 100644 --- a/packages/dev/core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts +++ b/packages/dev/core/src/DeviceInput/InputDevices/webDeviceInputSystem.ts @@ -690,7 +690,7 @@ export class WebDeviceInputSystem implements IDeviceInputSystem { this._elementToAttachTo.addEventListener(this._eventPrefix + "up", this._pointerUpEvent); this._elementToAttachTo.addEventListener(this._eventPrefix + "cancel", this._pointerCancelEvent); this._elementToAttachTo.addEventListener("blur", this._pointerBlurEvent); - this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, passiveSupported ? { passive: false } : false); + this._elementToAttachTo.addEventListener(this._wheelEventName, this._pointerWheelEvent, passiveSupported ? { passive: true } : false); // Since there's no up or down event for mouse wheel or delta x/y, clear mouse values at end of frame this._pointerInputClearObserver = this._engine.onEndFrameObservable.add(() => {