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

DeviceInputSystem: Fixed Passive Support Check to prevent Violation Warning #12696

Merged
merged 2 commits into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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", {
deltakosh marked this conversation as resolved.
Show resolved Hide resolved
get: function () {
passiveSupported = true;
},
};
});

this._elementToAttachTo.addEventListener("test", noop, options);
this._elementToAttachTo.removeEventListener("test", noop, options);
Expand Down Expand Up @@ -692,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(() => {
Expand Down