@babylonjs/core 5.0.0-beta.6 → 5.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DeviceInput/Helpers/eventFactory.js +1 -4
- package/DeviceInput/Helpers/eventFactory.js.map +1 -1
- package/DeviceInput/InputDevices/deviceEnums.d.ts +4 -2
- package/DeviceInput/InputDevices/deviceEnums.js +3 -1
- package/DeviceInput/InputDevices/deviceEnums.js.map +1 -1
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.js +3 -2
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +1 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.js +6 -52
- package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.cubeTexture.js +2 -1
- package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js +4 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js +9 -2
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/nativeEngine.js +1 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +8 -0
- package/Engines/renderTargetWrapper.js +20 -0
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +7 -0
- package/Engines/thinEngine.js +19 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Inputs/scene.inputManager.js +1 -4
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +2 -0
- package/Materials/Textures/internalTexture.js +2 -0
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/material.js +1 -1
- package/Materials/material.js.map +1 -1
- package/Materials/materialHelper.js +5 -0
- package/Materials/materialHelper.js.map +1 -1
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +6 -12
- package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
- package/Shaders/geometry.vertex.js +1 -1
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/pbr.vertex.js +1 -1
- package/Shaders/pbr.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -45,10 +45,7 @@ var DeviceEventFactory = /** @class */ (function () {
|
|
|
45
45
|
DeviceEventFactory._createPointerEvent = function (deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo) {
|
|
46
46
|
var evt = this._createMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);
|
|
47
47
|
evt.pointerId = deviceType === DeviceType.Mouse ? 1 : deviceSlot;
|
|
48
|
-
if (inputIndex === PointerInput.
|
|
49
|
-
inputIndex === PointerInput.Vertical ||
|
|
50
|
-
inputIndex === PointerInput.DeltaHorizontal ||
|
|
51
|
-
inputIndex === PointerInput.DeltaVertical) {
|
|
48
|
+
if (inputIndex === PointerInput.Move) {
|
|
52
49
|
evt.type = "pointermove";
|
|
53
50
|
}
|
|
54
51
|
else if (inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventFactory.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/Helpers/eventFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAU,MAAM,gCAAgC,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGvE;;GAEG;AACH;IAAA;IAwKA,CAAC;IAvKG;;;;;;;;;;OAUG;IACW,oCAAiB,GAA/B,UAAgC,UAAsB,EAAE,UAAkB,EAAE,UAAkB,EAAE,YAA8B,EAAE,iBAAqC,EAAE,iBAAuB;QAC1L,QAAQ,UAAU,EAAE;YAChB,KAAK,UAAU,CAAC,QAAQ;gBACpB,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAA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AS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC;gBAC7D,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QACvE,IAAM,QAAQ,GAAG,gBAAgB,IAAI,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAEnG,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QACpB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACY,+BAAY,GAA3B,UAA4B,iBAAsB;QAC9C,IAAM,GAAG,GAAyB,EAAE,CAAC;QACrC,GAAG,CAAC,cAAc,GAAG,cAAQ,CAAC,CAAC;QAC/B,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IACL,yBAAC;AAAD,CAAC,AAxKD,IAwKC","sourcesContent":["\r\nimport { EventConstants, IEvent } from \"../../Events/deviceInputEvents\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceType, PointerInput } from \"../InputDevices/deviceEnums\";\r\nimport { IDeviceInputSystem } from \"../InputDevices/inputInterfaces\";\r\n\r\n/**\r\n * Class to wrap DeviceInputSystem data into an event object\r\n */\r\nexport class DeviceEventFactory {\r\n /**\r\n * Create device input events based on provided type and slot\r\n *\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object\r\n */\r\n public static CreateDeviceEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): IEvent {\r\n switch (deviceType) {\r\n case DeviceType.Keyboard:\r\n return this._createKeyboardEvent(inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n case DeviceType.Mouse:\r\n if (inputIndex === PointerInput.MouseWheelX || inputIndex === PointerInput.MouseWheelY || inputIndex === PointerInput.MouseWheelZ) {\r\n return this._createWheelEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n }\r\n case DeviceType.Touch:\r\n return this._createPointerEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n default:\r\n throw `Unable to generate event for device ${DeviceType[deviceType]}`;\r\n }\r\n }\r\n\r\n /**\r\n * Creates pointer event\r\n *\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Pointer)\r\n */\r\n private static _createPointerEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._createMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n evt.pointerId = deviceType === DeviceType.Mouse ? 1 : deviceSlot;\r\n\r\n if (\r\n inputIndex === PointerInput.Horizontal ||\r\n inputIndex === PointerInput.Vertical ||\r\n inputIndex === PointerInput.DeltaHorizontal ||\r\n inputIndex === PointerInput.DeltaVertical\r\n ) {\r\n evt.type = \"pointermove\";\r\n }\r\n else if (inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick) {\r\n evt.type = (currentState === 1) ? \"pointerdown\" : \"pointerup\";\r\n evt.button = inputIndex - 2;\r\n }\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Wheel Event\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Wheel)\r\n */\r\n private static _createWheelEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo: any): any {\r\n const evt = this._createMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n evt.type = \"wheel\";\r\n evt.deltaMode = EventConstants.DOM_DELTA_PIXEL;\r\n evt.deltaX = (inputIndex === PointerInput.MouseWheelX) ? currentState : deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MouseWheelX);\r\n evt.deltaY = (inputIndex === PointerInput.MouseWheelY) ? currentState : deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MouseWheelY);\r\n evt.deltaZ = (inputIndex === PointerInput.MouseWheelZ) ? currentState : deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MouseWheelZ);\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Event\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Mouse)\r\n */\r\n private static _createMouseEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._createEvent(elementToAttachTo);\r\n const pointerX = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Horizontal);\r\n const pointerY = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Vertical);\r\n // If dealing with a change to the delta, grab values for event init\r\n const movementX = inputIndex === PointerInput.DeltaHorizontal ? currentState : 0;\r\n const movementY = inputIndex === PointerInput.DeltaVertical ? currentState : 0;\r\n // Get offsets from container\r\n const offsetX = inputIndex === PointerInput.DeltaHorizontal && elementToAttachTo ? movementX! - elementToAttachTo.getBoundingClientRect().x : 0;\r\n const offsetY = inputIndex === PointerInput.DeltaVertical && elementToAttachTo ? movementY! - elementToAttachTo.getBoundingClientRect().y : 0;\r\n this._checkNonCharacterKeys(evt, deviceInputSystem);\r\n\r\n evt.clientX = pointerX;\r\n evt.clientY = pointerY;\r\n evt.movementX = movementX;\r\n evt.movementY = movementY;\r\n evt.offsetX = offsetX;\r\n evt.offsetY = offsetY;\r\n evt.x = pointerX;\r\n evt.y = pointerY;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Keyboard Event\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Keyboard)\r\n */\r\n private static _createKeyboardEvent(inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._createEvent(elementToAttachTo);\r\n this._checkNonCharacterKeys(evt, deviceInputSystem);\r\n\r\n evt.type = currentState === 1 ? \"keydown\" : \"keyup\";\r\n evt.key = String.fromCharCode(inputIndex);\r\n evt.keyCode = inputIndex;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Add parameters for non-character keys (Ctrl, Alt, Meta, Shift)\r\n * @param evt Event object to add parameters to\r\n * @param deviceInputSystem DeviceInputSystem to pull values from\r\n */\r\n private static _checkNonCharacterKeys(evt: any, deviceInputSystem: IDeviceInputSystem): void {\r\n const isKeyboardActive = deviceInputSystem.isDeviceAvailable(DeviceType.Keyboard);\r\n const altKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 18) === 1;\r\n const ctrlKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 17) === 1;\r\n const metaKey =\r\n isKeyboardActive &&\r\n (deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 91) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 92) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 93) === 1);\r\n const shiftKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 16) === 1;\r\n\r\n evt.altKey = altKey;\r\n evt.ctrlKey = ctrlKey;\r\n evt.metaKey = metaKey;\r\n evt.shiftKey = shiftKey;\r\n }\r\n\r\n /**\r\n * Create base event object\r\n * @param elementToAttachTo Value to use as event target\r\n * @returns\r\n */\r\n private static _createEvent(elementToAttachTo: any): any {\r\n const evt: { [k: string]: any } = {};\r\n evt.preventDefault = () => { };\r\n evt.target = elementToAttachTo;\r\n\r\n return evt;\r\n }\r\n}"]}
|
|
1
|
+
{"version":3,"file":"eventFactory.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/Helpers/eventFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAU,MAAM,gCAAgC,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGvE;;GAEG;AACH;IAAA;IAmKA,CAAC;IAlKG;;;;;;;;;;OAUG;IACW,oCAAiB,GAA/B,UAAgC,UAAsB,EAAE,UAAkB,EAAE,UAAkB,EAAE,YAA8B,EAAE,iBAAqC,EAAE,iBAAuB;QAC1L,QAAQ,UAAU,EAAE;YAChB,KAAK,UAAU,CAAC,QAAQ;gBACpB,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;YACrG,KAAK,UAAU,CAAC,KAA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AAQ,GAAG,gBAAgB,IAAI,iBAAiB,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAEnG,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;QACpB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;QACtB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACY,+BAAY,GAA3B,UAA4B,iBAAsB;QAC9C,IAAM,GAAG,GAAyB,EAAE,CAAC;QACrC,GAAG,CAAC,cAAc,GAAG,cAAQ,CAAC,CAAC;QAC/B,GAAG,CAAC,MAAM,GAAG,iBAAiB,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IACL,yBAAC;AAAD,CAAC,AAnKD,IAmKC","sourcesContent":["\r\nimport { EventConstants, IEvent } from \"../../Events/deviceInputEvents\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceType, PointerInput } from \"../InputDevices/deviceEnums\";\r\nimport { IDeviceInputSystem } from \"../InputDevices/inputInterfaces\";\r\n\r\n/**\r\n * Class to wrap DeviceInputSystem data into an event object\r\n */\r\nexport class DeviceEventFactory {\r\n /**\r\n * Create device input events based on provided type and slot\r\n *\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object\r\n */\r\n public static CreateDeviceEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): IEvent {\r\n switch (deviceType) {\r\n case DeviceType.Keyboard:\r\n return this._createKeyboardEvent(inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n case DeviceType.Mouse:\r\n if (inputIndex === PointerInput.MouseWheelX || inputIndex === PointerInput.MouseWheelY || inputIndex === PointerInput.MouseWheelZ) {\r\n return this._createWheelEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n }\r\n case DeviceType.Touch:\r\n return this._createPointerEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n default:\r\n throw `Unable to generate event for device ${DeviceType[deviceType]}`;\r\n }\r\n }\r\n\r\n /**\r\n * Creates pointer event\r\n *\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Pointer)\r\n */\r\n private static _createPointerEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._createMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n evt.pointerId = deviceType === DeviceType.Mouse ? 1 : deviceSlot;\r\n\r\n if (inputIndex === PointerInput.Move) {\r\n evt.type = \"pointermove\";\r\n }\r\n else if (inputIndex >= PointerInput.LeftClick && inputIndex <= PointerInput.RightClick) {\r\n evt.type = (currentState === 1) ? \"pointerdown\" : \"pointerup\";\r\n evt.button = inputIndex - 2;\r\n }\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Wheel Event\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Wheel)\r\n */\r\n private static _createWheelEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo: any): any {\r\n const evt = this._createMouseEvent(deviceType, deviceSlot, inputIndex, currentState, deviceInputSystem, elementToAttachTo);\r\n\r\n evt.type = \"wheel\";\r\n evt.deltaMode = EventConstants.DOM_DELTA_PIXEL;\r\n evt.deltaX = (inputIndex === PointerInput.MouseWheelX) ? currentState : deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MouseWheelX);\r\n evt.deltaY = (inputIndex === PointerInput.MouseWheelY) ? currentState : deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MouseWheelY);\r\n evt.deltaZ = (inputIndex === PointerInput.MouseWheelZ) ? currentState : deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.MouseWheelZ);\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Mouse Event\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Mouse)\r\n */\r\n private static _createMouseEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._createEvent(elementToAttachTo);\r\n const pointerX = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Horizontal);\r\n const pointerY = deviceInputSystem.pollInput(deviceType, deviceSlot, PointerInput.Vertical);\r\n // If dealing with a change to the delta, grab values for event init\r\n const movementX = inputIndex === PointerInput.DeltaHorizontal ? currentState : 0;\r\n const movementY = inputIndex === PointerInput.DeltaVertical ? currentState : 0;\r\n // Get offsets from container\r\n const offsetX = inputIndex === PointerInput.DeltaHorizontal && elementToAttachTo ? movementX! - elementToAttachTo.getBoundingClientRect().x : 0;\r\n const offsetY = inputIndex === PointerInput.DeltaVertical && elementToAttachTo ? movementY! - elementToAttachTo.getBoundingClientRect().y : 0;\r\n this._checkNonCharacterKeys(evt, deviceInputSystem);\r\n\r\n evt.clientX = pointerX;\r\n evt.clientY = pointerY;\r\n evt.movementX = movementX;\r\n evt.movementY = movementY;\r\n evt.offsetX = offsetX;\r\n evt.offsetY = offsetY;\r\n evt.x = pointerX;\r\n evt.y = pointerY;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Create Keyboard Event\r\n * @param inputIndex Id of input to be checked\r\n * @param currentState Current value for given input\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param elementToAttachTo HTMLElement to reference as target for inputs\r\n * @returns IEvent object (Keyboard)\r\n */\r\n private static _createKeyboardEvent(inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): any {\r\n const evt = this._createEvent(elementToAttachTo);\r\n this._checkNonCharacterKeys(evt, deviceInputSystem);\r\n\r\n evt.type = currentState === 1 ? \"keydown\" : \"keyup\";\r\n evt.key = String.fromCharCode(inputIndex);\r\n evt.keyCode = inputIndex;\r\n\r\n return evt;\r\n }\r\n\r\n /**\r\n * Add parameters for non-character keys (Ctrl, Alt, Meta, Shift)\r\n * @param evt Event object to add parameters to\r\n * @param deviceInputSystem DeviceInputSystem to pull values from\r\n */\r\n private static _checkNonCharacterKeys(evt: any, deviceInputSystem: IDeviceInputSystem): void {\r\n const isKeyboardActive = deviceInputSystem.isDeviceAvailable(DeviceType.Keyboard);\r\n const altKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 18) === 1;\r\n const ctrlKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 17) === 1;\r\n const metaKey =\r\n isKeyboardActive &&\r\n (deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 91) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 92) === 1 ||\r\n deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 93) === 1);\r\n const shiftKey = isKeyboardActive && deviceInputSystem.pollInput(DeviceType.Keyboard, 0, 16) === 1;\r\n\r\n evt.altKey = altKey;\r\n evt.ctrlKey = ctrlKey;\r\n evt.metaKey = metaKey;\r\n evt.shiftKey = shiftKey;\r\n }\r\n\r\n /**\r\n * Create base event object\r\n * @param elementToAttachTo Value to use as event target\r\n * @returns\r\n */\r\n private static _createEvent(elementToAttachTo: any): any {\r\n const evt: { [k: string]: any } = {};\r\n evt.preventDefault = () => { };\r\n evt.target = elementToAttachTo;\r\n\r\n return evt;\r\n }\r\n}"]}
|
|
@@ -46,7 +46,9 @@ export declare enum PointerInput {
|
|
|
46
46
|
/** Delta X */
|
|
47
47
|
DeltaHorizontal = 10,
|
|
48
48
|
/** Delta Y */
|
|
49
|
-
DeltaVertical = 11
|
|
49
|
+
DeltaVertical = 11,
|
|
50
|
+
/** Move Catch-all */
|
|
51
|
+
Move = 12
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
54
|
* Enum for Dual Shock Gamepad
|
|
@@ -98,7 +100,7 @@ export declare enum DualShockInput {
|
|
|
98
100
|
RStickYAxis = 21
|
|
99
101
|
}
|
|
100
102
|
/**
|
|
101
|
-
* Enum for Dual
|
|
103
|
+
* Enum for Dual Sense Gamepad
|
|
102
104
|
*/
|
|
103
105
|
export declare enum DualSenseInput {
|
|
104
106
|
/** Cross */
|
|
@@ -50,6 +50,8 @@ export var PointerInput;
|
|
|
50
50
|
PointerInput[PointerInput["DeltaHorizontal"] = 10] = "DeltaHorizontal";
|
|
51
51
|
/** Delta Y */
|
|
52
52
|
PointerInput[PointerInput["DeltaVertical"] = 11] = "DeltaVertical";
|
|
53
|
+
/** Move Catch-all */
|
|
54
|
+
PointerInput[PointerInput["Move"] = 12] = "Move";
|
|
53
55
|
})(PointerInput || (PointerInput = {}));
|
|
54
56
|
/**
|
|
55
57
|
* Enum for Dual Shock Gamepad
|
|
@@ -102,7 +104,7 @@ export var DualShockInput;
|
|
|
102
104
|
DualShockInput[DualShockInput["RStickYAxis"] = 21] = "RStickYAxis";
|
|
103
105
|
})(DualShockInput || (DualShockInput = {}));
|
|
104
106
|
/**
|
|
105
|
-
* Enum for Dual
|
|
107
|
+
* Enum for Dual Sense Gamepad
|
|
106
108
|
*/
|
|
107
109
|
export var DualSenseInput;
|
|
108
110
|
(function (DualSenseInput) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceEnums.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/deviceEnums.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,UAiBX;AAjBD,WAAY,UAAU;IAClB,cAAc;IACd,iDAAW,CAAA;IACX,eAAe;IACf,mDAAY,CAAA;IACZ,YAAY;IACZ,6CAAS,CAAA;IACT,qBAAqB;IACrB,6CAAS,CAAA;IACT,qBAAqB;IACrB,qDAAa,CAAA;IACb,WAAW;IACX,2CAAQ,CAAA;IACR,wBAAwB;IACxB,+CAAU,CAAA;IACV,oBAAoB;IACpB,qDAAa,CAAA;AACjB,CAAC,EAjBW,UAAU,KAAV,UAAU,QAiBrB;AAED,eAAe;AACf;;GAEG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"deviceEnums.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/deviceEnums.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,UAiBX;AAjBD,WAAY,UAAU;IAClB,cAAc;IACd,iDAAW,CAAA;IACX,eAAe;IACf,mDAAY,CAAA;IACZ,YAAY;IACZ,6CAAS,CAAA;IACT,qBAAqB;IACrB,6CAAS,CAAA;IACT,qBAAqB;IACrB,qDAAa,CAAA;IACb,WAAW;IACX,2CAAQ,CAAA;IACR,wBAAwB;IACxB,+CAAU,CAAA;IACV,oBAAoB;IACpB,qDAAa,CAAA;AACjB,CAAC,EAjBW,UAAU,KAAV,UAAU,QAiBrB;AA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AAA;IACP,SAAS;IACT,sCAAO,CAAA;IACP,aAAa;IACb,8CAAW,CAAA;IACX,eAAe;IACf,kDAAa,CAAA;IACb,eAAe;IACf,kDAAa,CAAA;IACb,aAAa;IACb,oDAAc,CAAA;IACd,WAAW;IACX,0CAAS,CAAA;IACT,kBAAkB;IAClB,wDAAgB,CAAA;IAChB,kBAAkB;IAClB,wDAAgB,CAAA;IAChB,kBAAkB;IAClB,wDAAgB,CAAA;IAChB,kBAAkB;IAClB,wDAAgB,CAAA;AACpB,CAAC,EA3CW,SAAS,KAAT,SAAS,QA2CpB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,WA6CX;AA7CD,WAAY,WAAW;IACnB,QAAQ;IACR,uCAAK,CAAA;IACL,QAAQ;IACR,uCAAK,CAAA;IACL,QAAQ;IACR,uCAAK,CAAA;IACL,QAAQ;IACR,uCAAK,CAAA;IACL,QAAQ;IACR,uCAAK,CAAA;IACL,QAAQ;IACR,uCAAK,CAAA;IACL,SAAS;IACT,yCAAM,CAAA;IACN,SAAS;IACT,yCAAM,CAAA;IACN,YAAY;IACZ,+CAAS,CAAA;IACT,WAAW;IACX,6CAAQ,CAAA;IACR,SAAS;IACT,0CAAO,CAAA;IACP,SAAS;IACT,0CAAO,CAAA;IACP,aAAa;IACb,kDAAW,CAAA;IACX,eAAe;IACf,sDAAa,CAAA;IACb,eAAe;IACf,sDAAa,CAAA;IACb,aAAa;IACb,wDAAc,CAAA;IACd,WAAW;IACX,8CAAS,CAAA;IACT,cAAc;IACd,oDAAY,CAAA;IACZ,kBAAkB;IAClB,4DAAgB,CAAA;IAChB,kBAAkB;IAClB,4DAAgB,CAAA;IAChB,kBAAkB;IAClB,4DAAgB,CAAA;IAChB,kBAAkB;IAClB,4DAAgB,CAAA;AACpB,CAAC,EA7CW,WAAW,KAAX,WAAW,QA6CtB","sourcesContent":["/**\r\n * Enum for Device Types\r\n */\r\nexport enum DeviceType {\r\n /** Generic */\r\n Generic = 0,\r\n /** Keyboard */\r\n Keyboard = 1,\r\n /** Mouse */\r\n Mouse = 2,\r\n /** Touch Pointers */\r\n Touch = 3,\r\n /** PS4 Dual Shock */\r\n DualShock = 4,\r\n /** Xbox */\r\n Xbox = 5,\r\n /** Switch Controller */\r\n Switch = 6,\r\n /** PS5 DualSense */\r\n DualSense = 7,\r\n}\r\n\r\n// Device Enums\r\n/**\r\n * Enum for All Pointers (Touch/Mouse)\r\n */\r\nexport enum PointerInput {\r\n /** Horizontal Axis */\r\n Horizontal = 0,\r\n /** Vertical Axis */\r\n Vertical = 1,\r\n /** Left Click or Touch */\r\n LeftClick = 2,\r\n /** Middle Click */\r\n MiddleClick = 3,\r\n /** Right Click */\r\n RightClick = 4,\r\n /** Browser Back */\r\n BrowserBack = 5,\r\n /** Browser Forward */\r\n BrowserForward = 6,\r\n /** Mouse Wheel X */\r\n MouseWheelX = 7,\r\n /** Mouse Wheel Y */\r\n MouseWheelY = 8,\r\n /** Mouse Wheel Z */\r\n MouseWheelZ = 9,\r\n /** Delta X */\r\n DeltaHorizontal = 10,\r\n /** Delta Y */\r\n DeltaVertical = 11,\r\n /** Move Catch-all */\r\n Move = 12,\r\n}\r\n\r\n/**\r\n * Enum for Dual Shock Gamepad\r\n */\r\nexport enum DualShockInput {\r\n /** Cross */\r\n Cross = 0,\r\n /** Circle */\r\n Circle = 1,\r\n /** Square */\r\n Square = 2,\r\n /** Triangle */\r\n Triangle = 3,\r\n /** L1 */\r\n L1 = 4,\r\n /** R1 */\r\n R1 = 5,\r\n /** L2 */\r\n L2 = 6,\r\n /** R2 */\r\n R2 = 7,\r\n /** Share */\r\n Share = 8,\r\n /** Options */\r\n Options = 9,\r\n /** L3 */\r\n L3 = 10,\r\n /** R3 */\r\n R3 = 11,\r\n /** DPadUp */\r\n DPadUp = 12,\r\n /** DPadDown */\r\n DPadDown = 13,\r\n /** DPadLeft */\r\n DPadLeft = 14,\r\n /** DRight */\r\n DPadRight = 15,\r\n /** Home */\r\n Home = 16,\r\n /** TouchPad */\r\n TouchPad = 17,\r\n /** LStickXAxis */\r\n LStickXAxis = 18,\r\n /** LStickYAxis */\r\n LStickYAxis = 19,\r\n /** RStickXAxis */\r\n RStickXAxis = 20,\r\n /** RStickYAxis */\r\n RStickYAxis = 21\r\n}\r\n\r\n/**\r\n * Enum for Dual Sense Gamepad\r\n */\r\n export enum DualSenseInput {\r\n /** Cross */\r\n Cross = 0,\r\n /** Circle */\r\n Circle = 1,\r\n /** Square */\r\n Square = 2,\r\n /** Triangle */\r\n Triangle = 3,\r\n /** L1 */\r\n L1 = 4,\r\n /** R1 */\r\n R1 = 5,\r\n /** L2 */\r\n L2 = 6,\r\n /** R2 */\r\n R2 = 7,\r\n /** Create */\r\n Create = 8,\r\n /** Options */\r\n Options = 9,\r\n /** L3 */\r\n L3 = 10,\r\n /** R3 */\r\n R3 = 11,\r\n /** DPadUp */\r\n DPadUp = 12,\r\n /** DPadDown */\r\n DPadDown = 13,\r\n /** DPadLeft */\r\n DPadLeft = 14,\r\n /** DRight */\r\n DPadRight = 15,\r\n /** Home */\r\n Home = 16,\r\n /** TouchPad */\r\n TouchPad = 17,\r\n /** LStickXAxis */\r\n LStickXAxis = 18,\r\n /** LStickYAxis */\r\n LStickYAxis = 19,\r\n /** RStickXAxis */\r\n RStickXAxis = 20,\r\n /** RStickYAxis */\r\n RStickYAxis = 21\r\n}\r\n\r\n/**\r\n * Enum for Xbox Gamepad\r\n */\r\nexport enum XboxInput {\r\n /** A */\r\n A = 0,\r\n /** B */\r\n B = 1,\r\n /** X */\r\n X = 2,\r\n /** Y */\r\n Y = 3,\r\n /** LB */\r\n LB = 4,\r\n /** RB */\r\n RB = 5,\r\n /** LT */\r\n LT = 6,\r\n /** RT */\r\n RT = 7,\r\n /** Back */\r\n Back = 8,\r\n /** Start */\r\n Start = 9,\r\n /** LS */\r\n LS = 10,\r\n /** RS */\r\n RS = 11,\r\n /** DPadUp */\r\n DPadUp = 12,\r\n /** DPadDown */\r\n DPadDown = 13,\r\n /** DPadLeft */\r\n DPadLeft = 14,\r\n /** DRight */\r\n DPadRight = 15,\r\n /** Home */\r\n Home = 16,\r\n /** LStickXAxis */\r\n LStickXAxis = 17,\r\n /** LStickYAxis */\r\n LStickYAxis = 18,\r\n /** RStickXAxis */\r\n RStickXAxis = 19,\r\n /** RStickYAxis */\r\n RStickYAxis = 20\r\n}\r\n\r\n/**\r\n * Enum for Switch (Pro/JoyCon L+R) Gamepad\r\n */\r\nexport enum SwitchInput {\r\n /** B */\r\n B = 0,\r\n /** A */\r\n A = 1,\r\n /** Y */\r\n Y = 2,\r\n /** X */\r\n X = 3,\r\n /** L */\r\n L = 4,\r\n /** R */\r\n R = 5,\r\n /** ZL */\r\n ZL = 6,\r\n /** ZR */\r\n ZR = 7,\r\n /** Minus */\r\n Minus = 8,\r\n /** Plus */\r\n Plus = 9,\r\n /** LS */\r\n LS = 10,\r\n /** RS */\r\n RS = 11,\r\n /** DPadUp */\r\n DPadUp = 12,\r\n /** DPadDown */\r\n DPadDown = 13,\r\n /** DPadLeft */\r\n DPadLeft = 14,\r\n /** DRight */\r\n DPadRight = 15,\r\n /** Home */\r\n Home = 16,\r\n /** Capture */\r\n Capture = 17,\r\n /** LStickXAxis */\r\n LStickXAxis = 18,\r\n /** LStickYAxis */\r\n LStickYAxis = 19,\r\n /** RStickXAxis */\r\n RStickXAxis = 20,\r\n /** RStickYAxis */\r\n RStickYAxis = 21\r\n}"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeviceEventFactory } from "../Helpers/eventFactory.js";
|
|
2
|
-
import { DeviceType } from "./deviceEnums.js";
|
|
2
|
+
import { DeviceType, PointerInput } from "./deviceEnums.js";
|
|
3
3
|
/** @hidden */
|
|
4
4
|
var NativeDeviceInputSystem = /** @class */ (function () {
|
|
5
5
|
function NativeDeviceInputSystem(nativeInput) {
|
|
@@ -15,11 +15,12 @@ var NativeDeviceInputSystem = /** @class */ (function () {
|
|
|
15
15
|
_this.onDeviceDisconnected(deviceType, deviceSlot);
|
|
16
16
|
};
|
|
17
17
|
this._nativeInput.onInputChanged = function (deviceType, deviceSlot, inputIndex, previousState, currentState, eventData) {
|
|
18
|
+
var idx = (inputIndex === PointerInput.Horizontal || inputIndex === PointerInput.Vertical || inputIndex === PointerInput.DeltaHorizontal || inputIndex === PointerInput.DeltaVertical) ? PointerInput.Move : inputIndex;
|
|
18
19
|
var evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, inputIndex, currentState, _this);
|
|
19
20
|
var deviceEvent = evt;
|
|
20
21
|
deviceEvent.deviceType = deviceType;
|
|
21
22
|
deviceEvent.deviceSlot = deviceSlot;
|
|
22
|
-
deviceEvent.inputIndex =
|
|
23
|
+
deviceEvent.inputIndex = idx;
|
|
23
24
|
deviceEvent.previousState = previousState;
|
|
24
25
|
deviceEvent.currentState = currentState;
|
|
25
26
|
_this.onInputChanged(deviceEvent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/nativeDeviceInputSystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"nativeDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/nativeDeviceInputSystem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGzD,cAAc;AACd;IAOI,iCAAmB,WAA0B;QAA7C,iBAwBC;QA9BM,sBAAiB,GAAG,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC,CAAC;QACxE,yBAAoB,GAAG,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC,CAAC;QAC3E,mBAAc,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IACnB;;;;;;OAMG;IACI,2CAAS,GAAhB,UAAiB,UAAsB,EAAE,UAAkB,EAAE,UAAkB;QAC3E,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACI,mDAAiB,GAAxB,UAAyB,UAAsB;QAC3C,6BAA6B;QAC7B,OAAO,CAAC,UAAU,KAAK,UAAU,CAAC,KAAK,IAAI,UAAU,KAAK,UAAU,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;IAED;;OAEG;IACI,yCAAO,GAAd;QACI,IAAI,CAAC,iBAAiB,GAAG,cAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,oBAAoB,GAAG,cAAQ,CAAC,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,cAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACK,yDAAuB,GAA/B;QACI,IAAI,WAAW,GAAG;YACd,iBAAiB,EAAE,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC;YACtE,oBAAoB,EAAE,UAAC,UAAsB,EAAE,UAAkB,IAAO,CAAC;YACzE,cAAc,EAAE,UAAC,UAAsB,EAAE,UAAkB,EAAE,UAAkB,EAAE,aAA+B,EAAE,YAA8B,EAAE,SAAe,IAAO,CAAC;YACzK,SAAS,EAAE,cAAQ,OAAO,CAAC,CAAC,CAAC,CAAC;YAC9B,iBAAiB,EAAE,cAAQ,OAAO,KAAK,CAAC,CAAC,CAAC;YAC1C,OAAO,EAAE,cAAQ,CAAC;SACrB,CAAC;QAEF,OAAO,WAAW,CAAC;IACvB,CAAC;IACL,8BAAC;AAAD,CAAC,AAhFD,IAgFC","sourcesContent":["import { Nullable } from \"../../types\";\r\nimport { DeviceEventFactory } from \"../Helpers/eventFactory\";\r\nimport { DeviceType, PointerInput } from \"./deviceEnums\";\r\nimport { IDeviceEvent, IDeviceInputSystem, INativeInput } from \"./inputInterfaces\";\r\n\r\n/** @hidden */\r\nexport class NativeDeviceInputSystem implements IDeviceInputSystem {\r\n public onDeviceConnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n public onDeviceDisconnected = (deviceType: DeviceType, deviceSlot: number) => { };\r\n public onInputChanged = (deviceEvent: IDeviceEvent) => { };\r\n\r\n private readonly _nativeInput: INativeInput;\r\n\r\n public constructor(nativeInput?: INativeInput) {\r\n this._nativeInput = nativeInput || this._createDummyNativeInput();\r\n\r\n this._nativeInput.onDeviceConnected = (deviceType, deviceSlot) => {\r\n this.onDeviceConnected(deviceType, deviceSlot);\r\n };\r\n\r\n this._nativeInput.onDeviceDisconnected = (deviceType, deviceSlot) => {\r\n this.onDeviceDisconnected(deviceType, deviceSlot);\r\n };\r\n\r\n this._nativeInput.onInputChanged = (deviceType, deviceSlot, inputIndex, previousState, currentState, eventData) => {\r\n const idx = (inputIndex === PointerInput.Horizontal || inputIndex === PointerInput.Vertical || inputIndex === PointerInput.DeltaHorizontal || inputIndex === PointerInput.DeltaVertical) ? PointerInput.Move : inputIndex;\r\n const evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, inputIndex, currentState, this);\r\n\r\n let deviceEvent = evt as IDeviceEvent;\r\n deviceEvent.deviceType = deviceType;\r\n deviceEvent.deviceSlot = deviceSlot;\r\n deviceEvent.inputIndex = idx;\r\n deviceEvent.previousState = previousState;\r\n deviceEvent.currentState = currentState;\r\n\r\n this.onInputChanged(deviceEvent);\r\n };\r\n }\r\n\r\n // Public functions\r\n /**\r\n * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.\r\n * @param deviceType Enum specifiying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n * @param inputIndex Id of input to be checked\r\n * @returns Current value of input\r\n */\r\n public pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number {\r\n return this._nativeInput.pollInput(deviceType, deviceSlot, inputIndex);\r\n }\r\n\r\n /**\r\n * Check for a specific device in the DeviceInputSystem\r\n * @param deviceType Type of device to check for\r\n * @returns bool with status of device's existence\r\n */\r\n public isDeviceAvailable(deviceType: DeviceType): boolean {\r\n //TODO: FIx native side first\r\n return (deviceType === DeviceType.Mouse || deviceType === DeviceType.Touch);\r\n }\r\n\r\n /**\r\n * Dispose of all the observables\r\n */\r\n public dispose(): void {\r\n this.onDeviceConnected = () => { };\r\n this.onDeviceDisconnected = () => { };\r\n this.onInputChanged = () => { };\r\n }\r\n\r\n /**\r\n * For versions of BabylonNative that don't have the NativeInput plugin initialized, create a dummy version\r\n * @returns Object with dummy functions\r\n */\r\n private _createDummyNativeInput() {\r\n let nativeInput = {\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => { },\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => { },\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>, eventData?: any) => { },\r\n pollInput: () => { return 0; },\r\n isDeviceAvailable: () => { return false; },\r\n dispose: () => { },\r\n };\r\n\r\n return nativeInput;\r\n }\r\n}"]}
|
|
@@ -287,11 +287,6 @@ var WebDeviceInputSystem = /** @class */ (function () {
|
|
|
287
287
|
}
|
|
288
288
|
var pointer = _this._inputs[deviceType][deviceSlot];
|
|
289
289
|
if (pointer) {
|
|
290
|
-
// Store previous values for event
|
|
291
|
-
var previousHorizontal = pointer[PointerInput.Horizontal];
|
|
292
|
-
var previousVertical = pointer[PointerInput.Vertical];
|
|
293
|
-
var previousDeltaHorizontal = pointer[PointerInput.DeltaHorizontal];
|
|
294
|
-
var previousDeltaVertical = pointer[PointerInput.DeltaVertical];
|
|
295
290
|
pointer[PointerInput.Horizontal] = evt.clientX;
|
|
296
291
|
pointer[PointerInput.Vertical] = evt.clientY;
|
|
297
292
|
pointer[PointerInput.DeltaHorizontal] = evt.movementX;
|
|
@@ -299,33 +294,8 @@ var WebDeviceInputSystem = /** @class */ (function () {
|
|
|
299
294
|
var deviceEvent = evt;
|
|
300
295
|
deviceEvent.deviceType = deviceType;
|
|
301
296
|
deviceEvent.deviceSlot = deviceSlot;
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
// in this case we stil need to propagate it.
|
|
305
|
-
if (previousHorizontal !== evt.clientX) {
|
|
306
|
-
deviceEvent.inputIndex = PointerInput.Horizontal;
|
|
307
|
-
deviceEvent.previousState = previousHorizontal;
|
|
308
|
-
deviceEvent.currentState = pointer[PointerInput.Horizontal];
|
|
309
|
-
_this.onInputChanged(deviceEvent);
|
|
310
|
-
}
|
|
311
|
-
if (previousVertical !== evt.clientY) {
|
|
312
|
-
deviceEvent.inputIndex = PointerInput.Vertical;
|
|
313
|
-
deviceEvent.previousState = previousVertical;
|
|
314
|
-
deviceEvent.currentState = pointer[PointerInput.Vertical];
|
|
315
|
-
_this.onInputChanged(deviceEvent);
|
|
316
|
-
}
|
|
317
|
-
if (pointer[PointerInput.DeltaHorizontal] !== 0) {
|
|
318
|
-
deviceEvent.inputIndex = PointerInput.DeltaHorizontal;
|
|
319
|
-
deviceEvent.previousState = previousDeltaHorizontal;
|
|
320
|
-
deviceEvent.currentState = pointer[PointerInput.DeltaHorizontal];
|
|
321
|
-
_this.onInputChanged(deviceEvent);
|
|
322
|
-
}
|
|
323
|
-
if (pointer[PointerInput.DeltaVertical] !== 0) {
|
|
324
|
-
deviceEvent.inputIndex = PointerInput.DeltaVertical;
|
|
325
|
-
deviceEvent.previousState = previousDeltaVertical;
|
|
326
|
-
deviceEvent.currentState = pointer[PointerInput.DeltaVertical];
|
|
327
|
-
_this.onInputChanged(deviceEvent);
|
|
328
|
-
}
|
|
297
|
+
deviceEvent.inputIndex = PointerInput.Move;
|
|
298
|
+
_this.onInputChanged(deviceEvent);
|
|
329
299
|
// Lets Propagate the event for move with same position.
|
|
330
300
|
if (!_this._usingSafari && evt.button !== -1) {
|
|
331
301
|
deviceEvent.inputIndex = evt.button + 2;
|
|
@@ -406,16 +376,8 @@ var WebDeviceInputSystem = /** @class */ (function () {
|
|
|
406
376
|
deviceEvent.previousState = previousButton;
|
|
407
377
|
deviceEvent.currentState = pointer[deviceEvent.inputIndex];
|
|
408
378
|
_this.onInputChanged(deviceEvent);
|
|
409
|
-
if (previousHorizontal !== evt.clientX) {
|
|
410
|
-
deviceEvent.inputIndex = PointerInput.
|
|
411
|
-
deviceEvent.previousState = previousHorizontal;
|
|
412
|
-
deviceEvent.currentState = pointer[PointerInput.Horizontal];
|
|
413
|
-
_this.onInputChanged(deviceEvent);
|
|
414
|
-
}
|
|
415
|
-
if (previousVertical !== evt.clientY) {
|
|
416
|
-
deviceEvent.inputIndex = PointerInput.Vertical;
|
|
417
|
-
deviceEvent.previousState = previousVertical;
|
|
418
|
-
deviceEvent.currentState = pointer[PointerInput.Vertical];
|
|
379
|
+
if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {
|
|
380
|
+
deviceEvent.inputIndex = PointerInput.Move;
|
|
419
381
|
_this.onInputChanged(deviceEvent);
|
|
420
382
|
}
|
|
421
383
|
}
|
|
@@ -443,16 +405,8 @@ var WebDeviceInputSystem = /** @class */ (function () {
|
|
|
443
405
|
var deviceEvent = evt;
|
|
444
406
|
deviceEvent.deviceType = deviceType;
|
|
445
407
|
deviceEvent.deviceSlot = deviceSlot;
|
|
446
|
-
if (previousHorizontal !== evt.clientX) {
|
|
447
|
-
deviceEvent.inputIndex = PointerInput.
|
|
448
|
-
deviceEvent.previousState = previousHorizontal;
|
|
449
|
-
deviceEvent.currentState = pointer[PointerInput.Horizontal];
|
|
450
|
-
_this.onInputChanged(deviceEvent);
|
|
451
|
-
}
|
|
452
|
-
if (previousVertical !== evt.clientY) {
|
|
453
|
-
deviceEvent.inputIndex = PointerInput.Vertical;
|
|
454
|
-
deviceEvent.previousState = previousVertical;
|
|
455
|
-
deviceEvent.currentState = pointer[PointerInput.Vertical];
|
|
408
|
+
if (previousHorizontal !== evt.clientX || previousVertical !== evt.clientY) {
|
|
409
|
+
deviceEvent.inputIndex = PointerInput.Move;
|
|
456
410
|
_this.onInputChanged(deviceEvent);
|
|
457
411
|
}
|
|
458
412
|
// NOTE: The +2 used here to is because PointerInput has the same value progression for its mouse buttons as PointerEvent.button
|