@babylonjs/core 5.0.0-beta.8 → 5.0.0-rc.1
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/Actions/actionEvent.d.ts +3 -4
- package/Actions/actionEvent.js.map +1 -1
- package/Animations/animation.d.ts +4 -4
- package/Animations/animation.js +4 -4
- package/Animations/animation.js.map +1 -1
- package/Audio/sound.d.ts +12 -6
- package/Audio/sound.js +48 -24
- package/Audio/sound.js.map +1 -1
- package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.d.ts +1 -0
- package/Cameras/Inputs/BaseCameraPointersInput.js +4 -3
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +7 -5
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/arcRotateCamera.js +3 -3
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/DeviceInput/Helpers/eventFactory.d.ts +6 -6
- package/DeviceInput/Helpers/eventFactory.js +34 -16
- package/DeviceInput/Helpers/eventFactory.js.map +1 -1
- package/DeviceInput/InputDevices/deviceEnums.d.ts +26 -3
- package/DeviceInput/InputDevices/deviceEnums.js +31 -7
- package/DeviceInput/InputDevices/deviceEnums.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSource.d.ts +11 -3
- package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.d.ts +28 -10
- package/DeviceInput/InputDevices/deviceSourceManager.js +131 -7
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/InputDevices/deviceTypes.d.ts +1 -1
- package/DeviceInput/InputDevices/deviceTypes.js.map +1 -1
- package/DeviceInput/InputDevices/inputInterfaces.d.ts +3 -28
- package/DeviceInput/InputDevices/inputInterfaces.js.map +1 -1
- package/DeviceInput/InputDevices/internalDeviceSourceManager.d.ts +15 -30
- package/DeviceInput/InputDevices/internalDeviceSourceManager.js +40 -110
- package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +1 -1
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.d.ts +3 -2
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.js +7 -13
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +1 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.d.ts +11 -8
- package/DeviceInput/InputDevices/webDeviceInputSystem.js +116 -110
- package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.query.d.ts +7 -0
- package/Engines/Extensions/engine.query.js +12 -0
- package/Engines/Extensions/engine.query.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.d.ts +5 -0
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +7 -0
- package/Engines/Extensions/engine.views.js +12 -0
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/engine.d.ts +6 -2
- package/Engines/engine.js.map +1 -1
- package/Engines/index.d.ts +1 -0
- package/Engines/index.js +1 -0
- package/Engines/index.js.map +1 -1
- package/Engines/nativeEngine.js +12 -11
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +2 -2
- package/Engines/webgpuEngine.js.map +1 -1
- package/Events/deviceInputEvents.d.ts +17 -18
- package/Events/deviceInputEvents.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Helpers/environmentHelper.js +2 -2
- package/Helpers/environmentHelper.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +0 -1
- package/Inputs/scene.inputManager.js +54 -28
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.d.ts +1 -0
- package/Layers/effectLayer.js +24 -0
- package/Layers/effectLayer.js.map +1 -1
- package/Loading/sceneLoader.js +4 -3
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +6 -2
- package/Materials/Node/Blocks/Dual/textureBlock.js +50 -8
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/dynamicTexture.d.ts +1 -1
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +5 -0
- package/Materials/materialPluginBase.js +5 -0
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginEvent.d.ts +1 -0
- package/Materials/materialPluginEvent.js.map +1 -1
- package/Materials/materialPluginManager.d.ts +1 -0
- package/Materials/materialPluginManager.js +20 -15
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/standardMaterial.js +1 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.vector.d.ts +5 -0
- package/Maths/math.vector.js +11 -0
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/polygonBuilder.js +2 -1
- package/Meshes/Builders/polygonBuilder.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/instancedMesh.js +7 -4
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.js +21 -22
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +2 -2
- package/Meshes/mesh.vertexData.js +100 -76
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/transformNode.d.ts +0 -2
- package/Meshes/transformNode.js +6 -5
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/error.d.ts +51 -0
- package/Misc/error.js +66 -0
- package/Misc/error.js.map +1 -0
- package/Misc/fileTools.d.ts +4 -4
- package/Misc/fileTools.js +30 -16
- package/Misc/fileTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +8 -7
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/videoRecorder.d.ts +1 -1
- package/Misc/videoRecorder.js +1 -1
- package/Misc/videoRecorder.js.map +1 -1
- package/Morph/morphTarget.d.ts +2 -1
- package/Morph/morphTarget.js +5 -1
- package/Morph/morphTarget.js.map +1 -1
- package/Morph/morphTargetManager.js +1 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/particleSystem.d.ts +13 -1
- package/Particles/particleSystem.js +27 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Rendering/prePassRenderer.js +12 -2
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Rendering/subSurfaceConfiguration.js +1 -1
- package/Rendering/subSurfaceConfiguration.js.map +1 -1
- package/Rendering/utilityLayerRenderer.js +2 -0
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/pointCloudVertex.js +1 -1
- package/Shaders/ShadersInclude/pointCloudVertex.js.map +1 -1
- package/Shaders/background.vertex.js +1 -1
- package/Shaders/background.vertex.js.map +1 -1
- package/Shaders/pbr.vertex.js +1 -1
- package/Shaders/pbr.vertex.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js +4 -2
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/webXRSessionManager.js +1 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +4 -4
- package/scene.d.ts +1 -10
- package/scene.js +20 -39
- package/scene.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js.map +1 -1
- package/Misc/baseError.d.ts +0 -7
- package/Misc/baseError.js +0 -18
- package/Misc/baseError.js.map +0 -1
|
@@ -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;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,KAAK;gBACjB,IAAI,UAAU,KAAK,YAAY,CAAC,WAAW,IAAI,UAAU,KAAK,YAAY,CAAC,WAAW,IAAI,UAAU,KAAK,YAAY,CAAC,WAAW,EAAE;oBAC/H,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;iBACzH;YACL,KAAK,UAAU,CAAC,KAAK;gBACjB,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;YAC5H;gBACI,MAAM,8CAAuC,UAAU,CAAC,UAAU,CAAC,CAAE,CAAC;SAC7E;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACY,sCAAmB,GAAlC,UAAmC,UAAsB,EAAE,UAAkB,EAAE,UAAkB,EAAE,YAA8B,EAAE,iBAAqC,EAAE,iBAAuB;QA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\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}"]}
|
|
1
|
+
{"version":3,"file":"eventFactory.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/Helpers/eventFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAY,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3F;;GAEG;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iBAAiB,CAAC;QAE/B,OAAO,GAAG,CAAC;IACf,CAAC;IACL,yBAAC;AAAD,CAAC,AAvLD,IAuLC","sourcesContent":["\r\nimport { EventConstants, IUIEvent } from \"../../Events/deviceInputEvents\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceType, NativePointerInput, 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 IUIEvent object\r\n */\r\n public static CreateDeviceEvent(deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>, deviceInputSystem: IDeviceInputSystem, elementToAttachTo?: any): IUIEvent {\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 IUIEvent 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 if (deviceType === DeviceType.Mouse) {\r\n evt.deviceType = DeviceType.Mouse;\r\n evt.pointerId = 1;\r\n evt.pointerType = \"mouse\";\r\n }\r\n else {\r\n evt.deviceType = DeviceType.Touch;\r\n evt.pointerId = deviceSlot;\r\n evt.pointerType = \"touch\";\r\n }\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 IUIEvent 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 IUIEvent 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\r\n // Handle offsets/deltas based on existence of HTMLElement\r\n if (elementToAttachTo) {\r\n evt.movementX = 0;\r\n evt.movementY = 0;\r\n evt.offsetX = evt.movementX - elementToAttachTo.getBoundingClientRect().x;\r\n evt.offsetY = evt.movementY - elementToAttachTo.getBoundingClientRect().y;\r\n }\r\n else {\r\n evt.movementX = deviceInputSystem.pollInput(deviceType, deviceSlot, NativePointerInput.DeltaHorizontal); // DeltaHorizontal\r\n evt.movementY = deviceInputSystem.pollInput(deviceType, deviceSlot, NativePointerInput.DeltaVertical); // DeltaVertical\r\n evt.offsetX = 0;\r\n evt.offsetY = 0;\r\n }\r\n this._checkNonCharacterKeys(evt, deviceInputSystem);\r\n\r\n evt.clientX = pointerX;\r\n evt.clientY = pointerY;\r\n evt.x = pointerX;\r\n evt.y = pointerY;\r\n\r\n evt.deviceType = deviceType;\r\n evt.deviceSlot = deviceSlot;\r\n evt.inputIndex = inputIndex;\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 evt.deviceType = DeviceType.Keyboard;\r\n evt.deviceSlot = 0;\r\n evt.inputIndex = inputIndex;\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}"]}
|
|
@@ -23,6 +23,31 @@ export declare enum DeviceType {
|
|
|
23
23
|
* Enum for All Pointers (Touch/Mouse)
|
|
24
24
|
*/
|
|
25
25
|
export declare enum PointerInput {
|
|
26
|
+
/** Horizontal Axis (Not used in events/observables; only in polling) */
|
|
27
|
+
Horizontal = 0,
|
|
28
|
+
/** Vertical Axis (Not used in events/observables; only in polling) */
|
|
29
|
+
Vertical = 1,
|
|
30
|
+
/** Left Click or Touch */
|
|
31
|
+
LeftClick = 2,
|
|
32
|
+
/** Middle Click */
|
|
33
|
+
MiddleClick = 3,
|
|
34
|
+
/** Right Click */
|
|
35
|
+
RightClick = 4,
|
|
36
|
+
/** Browser Back */
|
|
37
|
+
BrowserBack = 5,
|
|
38
|
+
/** Browser Forward */
|
|
39
|
+
BrowserForward = 6,
|
|
40
|
+
/** Mouse Wheel X */
|
|
41
|
+
MouseWheelX = 7,
|
|
42
|
+
/** Mouse Wheel Y */
|
|
43
|
+
MouseWheelY = 8,
|
|
44
|
+
/** Mouse Wheel Z */
|
|
45
|
+
MouseWheelZ = 9,
|
|
46
|
+
/** Used in events/observables to identify if x/y changes occurred */
|
|
47
|
+
Move = 12
|
|
48
|
+
}
|
|
49
|
+
/** @hidden */
|
|
50
|
+
export declare enum NativePointerInput {
|
|
26
51
|
/** Horizontal Axis */
|
|
27
52
|
Horizontal = 0,
|
|
28
53
|
/** Vertical Axis */
|
|
@@ -46,9 +71,7 @@ export declare enum PointerInput {
|
|
|
46
71
|
/** Delta X */
|
|
47
72
|
DeltaHorizontal = 10,
|
|
48
73
|
/** Delta Y */
|
|
49
|
-
DeltaVertical = 11
|
|
50
|
-
/** Move Catch-all */
|
|
51
|
-
Move = 12
|
|
74
|
+
DeltaVertical = 11
|
|
52
75
|
}
|
|
53
76
|
/**
|
|
54
77
|
* Enum for Dual Shock Gamepad
|
|
@@ -26,9 +26,9 @@ export var DeviceType;
|
|
|
26
26
|
*/
|
|
27
27
|
export var PointerInput;
|
|
28
28
|
(function (PointerInput) {
|
|
29
|
-
/** Horizontal Axis */
|
|
29
|
+
/** Horizontal Axis (Not used in events/observables; only in polling) */
|
|
30
30
|
PointerInput[PointerInput["Horizontal"] = 0] = "Horizontal";
|
|
31
|
-
/** Vertical Axis */
|
|
31
|
+
/** Vertical Axis (Not used in events/observables; only in polling) */
|
|
32
32
|
PointerInput[PointerInput["Vertical"] = 1] = "Vertical";
|
|
33
33
|
/** Left Click or Touch */
|
|
34
34
|
PointerInput[PointerInput["LeftClick"] = 2] = "LeftClick";
|
|
@@ -46,13 +46,37 @@ export var PointerInput;
|
|
|
46
46
|
PointerInput[PointerInput["MouseWheelY"] = 8] = "MouseWheelY";
|
|
47
47
|
/** Mouse Wheel Z */
|
|
48
48
|
PointerInput[PointerInput["MouseWheelZ"] = 9] = "MouseWheelZ";
|
|
49
|
-
/**
|
|
50
|
-
PointerInput[PointerInput["DeltaHorizontal"] = 10] = "DeltaHorizontal";
|
|
51
|
-
/** Delta Y */
|
|
52
|
-
PointerInput[PointerInput["DeltaVertical"] = 11] = "DeltaVertical";
|
|
53
|
-
/** Move Catch-all */
|
|
49
|
+
/** Used in events/observables to identify if x/y changes occurred */
|
|
54
50
|
PointerInput[PointerInput["Move"] = 12] = "Move";
|
|
55
51
|
})(PointerInput || (PointerInput = {}));
|
|
52
|
+
/** @hidden */
|
|
53
|
+
export var NativePointerInput;
|
|
54
|
+
(function (NativePointerInput) {
|
|
55
|
+
/** Horizontal Axis */
|
|
56
|
+
NativePointerInput[NativePointerInput["Horizontal"] = 0] = "Horizontal";
|
|
57
|
+
/** Vertical Axis */
|
|
58
|
+
NativePointerInput[NativePointerInput["Vertical"] = 1] = "Vertical";
|
|
59
|
+
/** Left Click or Touch */
|
|
60
|
+
NativePointerInput[NativePointerInput["LeftClick"] = 2] = "LeftClick";
|
|
61
|
+
/** Middle Click */
|
|
62
|
+
NativePointerInput[NativePointerInput["MiddleClick"] = 3] = "MiddleClick";
|
|
63
|
+
/** Right Click */
|
|
64
|
+
NativePointerInput[NativePointerInput["RightClick"] = 4] = "RightClick";
|
|
65
|
+
/** Browser Back */
|
|
66
|
+
NativePointerInput[NativePointerInput["BrowserBack"] = 5] = "BrowserBack";
|
|
67
|
+
/** Browser Forward */
|
|
68
|
+
NativePointerInput[NativePointerInput["BrowserForward"] = 6] = "BrowserForward";
|
|
69
|
+
/** Mouse Wheel X */
|
|
70
|
+
NativePointerInput[NativePointerInput["MouseWheelX"] = 7] = "MouseWheelX";
|
|
71
|
+
/** Mouse Wheel Y */
|
|
72
|
+
NativePointerInput[NativePointerInput["MouseWheelY"] = 8] = "MouseWheelY";
|
|
73
|
+
/** Mouse Wheel Z */
|
|
74
|
+
NativePointerInput[NativePointerInput["MouseWheelZ"] = 9] = "MouseWheelZ";
|
|
75
|
+
/** Delta X */
|
|
76
|
+
NativePointerInput[NativePointerInput["DeltaHorizontal"] = 10] = "DeltaHorizontal";
|
|
77
|
+
/** Delta Y */
|
|
78
|
+
NativePointerInput[NativePointerInput["DeltaVertical"] = 11] = "DeltaVertical";
|
|
79
|
+
})(NativePointerInput || (NativePointerInput = {}));
|
|
56
80
|
/**
|
|
57
81
|
* Enum for Dual Shock Gamepad
|
|
58
82
|
*/
|
|
@@ -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;AAED,eAAe;AACf;;GAEG;AACH,MAAM,CAAN,IAAY,YAuBX;AAvBD,WAAY,YAAY;IACpB,wEAAwE;IACxE,2DAAc,CAAA;IACd,sEAAsE;IACtE,uDAAY,CAAA;IACZ,0BAA0B;IAC1B,yDAAa,CAAA;IACb,mBAAmB;IACnB,6DAAe,CAAA;IACf,kBAAkB;IAClB,2DAAc,CAAA;IACd,mBAAmB;IACnB,6DAAe,CAAA;IACf,sBAAsB;IACtB,mEAAkB,CAAA;IAClB,oBAAoB;IACpB,6DAAe,CAAA;IACf,oBAAoB;IACpB,6DAAe,CAAA;IACf,oBAAoB;IACpB,6DAAe,CAAA;IACf,qEAAqE;IACrE,gDAAS,CAAA;AACb,CAAC,EAvBW,YAAY,KAAZ,YAAY,QAuBvB;AAED,cAAc;AACd,MAAM,CAAN,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AAA;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 (Not used in events/observables; only in polling) */\r\n Horizontal = 0,\r\n /** Vertical Axis (Not used in events/observables; only in polling) */\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 /** Used in events/observables to identify if x/y changes occurred */\r\n Move = 12,\r\n}\r\n\r\n/** @hidden */\r\nexport enum NativePointerInput {\r\n /** Horizontal Axis */\r\n Horizontal = PointerInput.Horizontal,\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}\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,7 +1,12 @@
|
|
|
1
|
-
import { DeviceType } from './deviceEnums';
|
|
1
|
+
import { DeviceType, PointerInput } from './deviceEnums';
|
|
2
2
|
import { Observable } from '../../Misc/observable';
|
|
3
3
|
import { DeviceInput } from './deviceTypes';
|
|
4
|
-
import {
|
|
4
|
+
import { IDeviceInputSystem } from './inputInterfaces';
|
|
5
|
+
import { IUIEvent } from '../../Events/deviceInputEvents';
|
|
6
|
+
/**
|
|
7
|
+
* Subset of DeviceInput that only handles pointers and keyboard
|
|
8
|
+
*/
|
|
9
|
+
declare type DeviceEventInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? Exclude<PointerInput, PointerInput.Horizontal | PointerInput.Vertical> : never;
|
|
5
10
|
/**
|
|
6
11
|
* Class that handles all input for a specific device
|
|
7
12
|
*/
|
|
@@ -13,7 +18,9 @@ export declare class DeviceSource<T extends DeviceType> {
|
|
|
13
18
|
/**
|
|
14
19
|
* Observable to handle device input changes per device
|
|
15
20
|
*/
|
|
16
|
-
readonly onInputChangedObservable: Observable<
|
|
21
|
+
readonly onInputChangedObservable: Observable<IUIEvent & {
|
|
22
|
+
inputIndex: DeviceEventInput<T>;
|
|
23
|
+
}>;
|
|
17
24
|
private readonly _deviceInputSystem;
|
|
18
25
|
/**
|
|
19
26
|
* Default Constructor
|
|
@@ -33,3 +40,4 @@ export declare class DeviceSource<T extends DeviceType> {
|
|
|
33
40
|
*/
|
|
34
41
|
getInput(inputIndex: DeviceInput<T>): number;
|
|
35
42
|
}
|
|
43
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceSource.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/deviceSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"deviceSource.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/deviceSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAanD;;GAEG;AACH;IAUI;;;;;OAKG;IACH,sBAAY,iBAAqC;IAC7C,qBAAqB;IACL,UAAsB;IACtC,mDAAmD;IACnC,UAAsB;QAAtB,2BAAA,EAAA,cAAsB;QAFtB,eAAU,GAAV,UAAU,CAAY;QAEtB,eAAU,GAAV,UAAU,CAAY;QAnB1C,iBAAiB;QACjB;;WAEG;QACa,6BAAwB,GAAG,IAAI,UAAU,EAAkD,CAAC;QAgBxG,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,+BAAQ,GAAf,UAAgB,UAA0B;QACtC,OAAO,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3F,CAAC;IACL,mBAAC;AAAD,CAAC,AAhCD,IAgCC","sourcesContent":["import { DeviceType, PointerInput } from './deviceEnums';\r\nimport { Observable } from '../../Misc/observable';\r\nimport { DeviceInput } from './deviceTypes';\r\nimport { IDeviceInputSystem } from './inputInterfaces';\r\nimport { IUIEvent } from '../../Events/deviceInputEvents';\r\n\r\n/**\r\n * Subset of DeviceInput that only handles pointers and keyboard\r\n */\r\ntype DeviceEventInput<T extends DeviceType> =\r\n T extends DeviceType.Keyboard | DeviceType.Generic ? number :\r\n T extends DeviceType.Mouse | DeviceType.Touch ? Exclude<PointerInput, PointerInput.Horizontal | PointerInput.Vertical> :\r\n never;\r\n\r\n/**\r\n * Class that handles all input for a specific device\r\n */\r\nexport class DeviceSource<T extends DeviceType> {\r\n // Public Members\r\n /**\r\n * Observable to handle device input changes per device\r\n */\r\n public readonly onInputChangedObservable = new Observable<IUIEvent & { inputIndex: DeviceEventInput<T> }>();\r\n\r\n // Private Members\r\n private readonly _deviceInputSystem: IDeviceInputSystem;\r\n\r\n /**\r\n * Default Constructor\r\n * @param deviceInputSystem Reference to DeviceInputSystem\r\n * @param deviceType Type of device\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n constructor(deviceInputSystem: IDeviceInputSystem,\r\n /** Type of device */\r\n public readonly deviceType: DeviceType,\r\n /** \"Slot\" or index that device is referenced in */\r\n public readonly deviceSlot: number = 0) {\r\n this._deviceInputSystem = deviceInputSystem;\r\n }\r\n\r\n /**\r\n * Get input for specific input\r\n * @param inputIndex index of specific input on device\r\n * @returns Input value from DeviceInputSystem\r\n */\r\n public getInput(inputIndex: DeviceInput<T>): number {\r\n return this._deviceInputSystem.pollInput(this.deviceType, this.deviceSlot, inputIndex);\r\n }\r\n}"]}
|
|
@@ -2,40 +2,58 @@ import { Engine } from '../../Engines/engine';
|
|
|
2
2
|
import { DeviceType } from './deviceEnums';
|
|
3
3
|
import { Nullable } from '../../types';
|
|
4
4
|
import { Observable } from '../../Misc/observable';
|
|
5
|
-
import { IDeviceEvent } from './inputInterfaces';
|
|
6
5
|
import { DeviceSource } from './deviceSource';
|
|
6
|
+
import { IObservableManager } from './internalDeviceSourceManager';
|
|
7
|
+
import { IDisposable } from '../../scene';
|
|
8
|
+
import { IUIEvent } from '../../Events/deviceInputEvents';
|
|
7
9
|
/**
|
|
8
10
|
* Class to keep track of devices
|
|
9
11
|
*/
|
|
10
|
-
export declare class DeviceSourceManager {
|
|
12
|
+
export declare class DeviceSourceManager implements IDisposable, IObservableManager {
|
|
11
13
|
/**
|
|
12
14
|
* Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
|
|
13
15
|
*/
|
|
14
16
|
readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
|
|
15
|
-
/**
|
|
16
|
-
* Observable to be triggered when a device's input is changed
|
|
17
|
-
*/
|
|
18
|
-
readonly onInputChangedObservable: Observable<IDeviceEvent>;
|
|
19
17
|
/**
|
|
20
18
|
* Observable to be triggered when after a device is disconnected
|
|
21
19
|
*/
|
|
22
20
|
readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
|
|
23
|
-
private
|
|
21
|
+
private _engine;
|
|
22
|
+
private _onDisposeObserver;
|
|
23
|
+
private readonly _devices;
|
|
24
|
+
private readonly _firstDevice;
|
|
24
25
|
/**
|
|
25
26
|
* Gets a DeviceSource, given a type and slot
|
|
27
|
+
* @param deviceType Type of Device
|
|
28
|
+
* @param deviceSlot Slot or ID of device
|
|
29
|
+
* @returns DeviceSource
|
|
26
30
|
*/
|
|
27
|
-
getDeviceSource
|
|
31
|
+
getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
|
|
28
32
|
/**
|
|
29
33
|
* Gets an array of DeviceSource objects for a given device type
|
|
34
|
+
* @param deviceType Type of Device
|
|
35
|
+
* @returns All available DeviceSources of a given type
|
|
30
36
|
*/
|
|
31
|
-
getDeviceSources
|
|
37
|
+
getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
|
|
32
38
|
/**
|
|
33
39
|
* Returns a read-only list of all available devices
|
|
40
|
+
* @returns All available DeviceSources
|
|
34
41
|
*/
|
|
35
|
-
getDevices
|
|
42
|
+
getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
|
|
36
43
|
/**
|
|
37
44
|
* Default constructor
|
|
38
45
|
* @param engine Used to get canvas (if applicable)
|
|
39
46
|
*/
|
|
40
47
|
constructor(engine: Engine);
|
|
48
|
+
/**
|
|
49
|
+
* Dispose of DeviceSourceManager
|
|
50
|
+
*/
|
|
51
|
+
dispose(): void;
|
|
52
|
+
/** @hidden */
|
|
53
|
+
_addDevice(deviceSource: DeviceSource<DeviceType>): void;
|
|
54
|
+
/** @hidden */
|
|
55
|
+
_removeDevice(deviceType: DeviceType, deviceSlot: number): void;
|
|
56
|
+
/** @hidden */
|
|
57
|
+
_onInputChanged(deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent): void;
|
|
58
|
+
private _updateFirstDevices;
|
|
41
59
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DeviceType } from './deviceEnums.js';
|
|
2
|
+
import { Observable } from '../../Misc/observable.js';
|
|
1
3
|
import { InternalDeviceSourceManager } from './internalDeviceSourceManager.js';
|
|
2
4
|
/**
|
|
3
5
|
* Class to keep track of devices
|
|
@@ -8,14 +10,136 @@ var DeviceSourceManager = /** @class */ (function () {
|
|
|
8
10
|
* @param engine Used to get canvas (if applicable)
|
|
9
11
|
*/
|
|
10
12
|
function DeviceSourceManager(engine) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
var _this = this;
|
|
14
|
+
var numberOfDeviceTypes = Object.keys(DeviceType).length / 2;
|
|
15
|
+
this._devices = new Array(numberOfDeviceTypes);
|
|
16
|
+
this._firstDevice = new Array(numberOfDeviceTypes);
|
|
17
|
+
this._engine = engine;
|
|
18
|
+
if (!this._engine._deviceSourceManager) {
|
|
19
|
+
this._engine._deviceSourceManager = new InternalDeviceSourceManager(engine);
|
|
20
|
+
}
|
|
21
|
+
this._engine._deviceSourceManager._refCount++;
|
|
22
|
+
// Observables
|
|
23
|
+
this.onDeviceConnectedObservable = new Observable(function (observer) {
|
|
24
|
+
_this.getDevices().forEach(function (device) {
|
|
25
|
+
_this.onDeviceConnectedObservable.notifyObserver(observer, device);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
this.onDeviceDisconnectedObservable = new Observable();
|
|
29
|
+
this._engine._deviceSourceManager.registerManager(this);
|
|
30
|
+
this._onDisposeObserver = engine.onDisposeObservable.add(function () {
|
|
31
|
+
_this.dispose();
|
|
32
|
+
});
|
|
18
33
|
}
|
|
34
|
+
// Public Functions
|
|
35
|
+
/**
|
|
36
|
+
* Gets a DeviceSource, given a type and slot
|
|
37
|
+
* @param deviceType Type of Device
|
|
38
|
+
* @param deviceSlot Slot or ID of device
|
|
39
|
+
* @returns DeviceSource
|
|
40
|
+
*/
|
|
41
|
+
DeviceSourceManager.prototype.getDeviceSource = function (deviceType, deviceSlot) {
|
|
42
|
+
if (deviceSlot === undefined) {
|
|
43
|
+
if (this._firstDevice[deviceType] === undefined) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
deviceSlot = this._firstDevice[deviceType];
|
|
47
|
+
}
|
|
48
|
+
if (!this._devices[deviceType] || this._devices[deviceType][deviceSlot] === undefined) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return this._devices[deviceType][deviceSlot];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Gets an array of DeviceSource objects for a given device type
|
|
55
|
+
* @param deviceType Type of Device
|
|
56
|
+
* @returns All available DeviceSources of a given type
|
|
57
|
+
*/
|
|
58
|
+
DeviceSourceManager.prototype.getDeviceSources = function (deviceType) {
|
|
59
|
+
return this._devices[deviceType].filter(function (source) { return !!source; });
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Returns a read-only list of all available devices
|
|
63
|
+
* @returns All available DeviceSources
|
|
64
|
+
*/
|
|
65
|
+
DeviceSourceManager.prototype.getDevices = function () {
|
|
66
|
+
var deviceArray = new Array();
|
|
67
|
+
for (var _i = 0, _a = this._devices; _i < _a.length; _i++) {
|
|
68
|
+
var deviceSet = _a[_i];
|
|
69
|
+
deviceArray.push.apply(deviceArray, deviceSet);
|
|
70
|
+
}
|
|
71
|
+
return deviceArray;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Dispose of DeviceSourceManager
|
|
75
|
+
*/
|
|
76
|
+
DeviceSourceManager.prototype.dispose = function () {
|
|
77
|
+
// Null out observable refs
|
|
78
|
+
this.onDeviceConnectedObservable.clear();
|
|
79
|
+
this.onDeviceDisconnectedObservable.clear();
|
|
80
|
+
if (this._engine._deviceSourceManager) {
|
|
81
|
+
this._engine._deviceSourceManager.unregisterManager(this);
|
|
82
|
+
if (--this._engine._deviceSourceManager._refCount < 1) {
|
|
83
|
+
this._engine._deviceSourceManager.dispose();
|
|
84
|
+
delete this._engine._deviceSourceManager;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
this._engine.onDisposeObservable.remove(this._onDisposeObserver);
|
|
88
|
+
};
|
|
89
|
+
// Hidden Functions
|
|
90
|
+
/** @hidden */
|
|
91
|
+
DeviceSourceManager.prototype._addDevice = function (deviceSource) {
|
|
92
|
+
if (!this._devices[deviceSource.deviceType]) {
|
|
93
|
+
this._devices[deviceSource.deviceType] = new Array();
|
|
94
|
+
}
|
|
95
|
+
if (!this._devices[deviceSource.deviceType][deviceSource.deviceSlot]) {
|
|
96
|
+
this._devices[deviceSource.deviceType][deviceSource.deviceSlot] = deviceSource;
|
|
97
|
+
this._updateFirstDevices(deviceSource.deviceType);
|
|
98
|
+
}
|
|
99
|
+
this.onDeviceConnectedObservable.notifyObservers(deviceSource);
|
|
100
|
+
};
|
|
101
|
+
/** @hidden */
|
|
102
|
+
DeviceSourceManager.prototype._removeDevice = function (deviceType, deviceSlot) {
|
|
103
|
+
var _a, _b;
|
|
104
|
+
var deviceSource = (_a = this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot]; // Grab local reference to use before removing from devices
|
|
105
|
+
this.onDeviceDisconnectedObservable.notifyObservers(deviceSource);
|
|
106
|
+
if ((_b = this._devices[deviceType]) === null || _b === void 0 ? void 0 : _b[deviceSlot]) {
|
|
107
|
+
delete this._devices[deviceType][deviceSlot];
|
|
108
|
+
}
|
|
109
|
+
// Even if we don't delete a device, we should still check for the first device as things may have gotten out of sync.
|
|
110
|
+
this._updateFirstDevices(deviceType);
|
|
111
|
+
};
|
|
112
|
+
/** @hidden */
|
|
113
|
+
DeviceSourceManager.prototype._onInputChanged = function (deviceType, deviceSlot, eventData) {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
(_b = (_a = this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot]) === null || _b === void 0 ? void 0 : _b.onInputChangedObservable.notifyObservers(eventData);
|
|
116
|
+
};
|
|
117
|
+
// Private Functions
|
|
118
|
+
DeviceSourceManager.prototype._updateFirstDevices = function (type) {
|
|
119
|
+
switch (type) {
|
|
120
|
+
case DeviceType.Keyboard:
|
|
121
|
+
case DeviceType.Mouse:
|
|
122
|
+
this._firstDevice[type] = 0;
|
|
123
|
+
break;
|
|
124
|
+
case DeviceType.Touch:
|
|
125
|
+
case DeviceType.DualSense:
|
|
126
|
+
case DeviceType.DualShock:
|
|
127
|
+
case DeviceType.Xbox:
|
|
128
|
+
case DeviceType.Switch:
|
|
129
|
+
case DeviceType.Generic:
|
|
130
|
+
delete this._firstDevice[type];
|
|
131
|
+
var devices = this._devices[type];
|
|
132
|
+
if (devices) {
|
|
133
|
+
for (var i = 0; i < devices.length; i++) {
|
|
134
|
+
if (devices[i]) {
|
|
135
|
+
this._firstDevice[type] = i;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
19
143
|
return DeviceSourceManager;
|
|
20
144
|
}());
|
|
21
145
|
export { DeviceSourceManager };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceSourceManager.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/deviceSourceManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;GAEG;AACH;IAkCI;;;OAGG;IACH,6BAAY,MAAc;QACtB,IAAI,CAAC,oBAAoB,GAAG,2BAA2B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAExE,IAAI,CAAC,2BAA2B,GAAG,IAAI,CAAC,oBAAoB,CAAC,2BAA2B,CAAC;QACzF,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,oBAAoB,CAAC,wBAAwB,CAAC;QACnF,IAAI,CAAC,8BAA8B,GAAG,IAAI,CAAC,oBAAoB,CAAC,8BAA8B,CAAC;QAC/F,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,eAAe,CAAC;QACjE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC;QACnE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC;IAC3D,CAAC;IACL,0BAAC;AAAD,CAAC,AAhDD,IAgDC","sourcesContent":["import { Engine } from '../../Engines/engine';\nimport { DeviceType } from './deviceEnums';\nimport { Nullable } from '../../types';\nimport { Observable } from '../../Misc/observable';\nimport { IDeviceEvent } from './inputInterfaces';\nimport { DeviceSource } from './deviceSource';\nimport { InternalDeviceSourceManager } from './internalDeviceSourceManager';\n\n/**\n * Class to keep track of devices\n */\nexport class DeviceSourceManager {\n // Public Members\n /**\n * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices\n */\n public readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;\n /**\n * Observable to be triggered when a device's input is changed\n */\n public readonly onInputChangedObservable: Observable<IDeviceEvent>;\n /**\n * Observable to be triggered when after a device is disconnected\n */\n public readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;\n\n // Private Members\n private _deviceSourceManager: InternalDeviceSourceManager;\n\n // Public Functions\n /**\n * Gets a DeviceSource, given a type and slot\n */\n public getDeviceSource: <T extends DeviceType>(deviceType: T, deviceSlot?: number) => Nullable<DeviceSource<T>>;\n\n /**\n * Gets an array of DeviceSource objects for a given device type\n */\n public getDeviceSources: <T extends DeviceType>(deviceType: T) => ReadonlyArray<DeviceSource<T>>;\n\n /**\n * Returns a read-only list of all available devices\n */\n public getDevices: () => ReadonlyArray<DeviceSource<DeviceType>>;\n\n /**\n * Default constructor\n * @param engine Used to get canvas (if applicable)\n */\n constructor(engine: Engine) {\n this._deviceSourceManager = InternalDeviceSourceManager._Create(engine);\n\n this.onDeviceConnectedObservable = this._deviceSourceManager.onDeviceConnectedObservable;\n this.onInputChangedObservable = this._deviceSourceManager.onInputChangedObservable;\n this.onDeviceDisconnectedObservable = this._deviceSourceManager.onDeviceDisconnectedObservable;\n this.getDeviceSource = this._deviceSourceManager.getDeviceSource;\n this.getDeviceSources = this._deviceSourceManager.getDeviceSources;\n this.getDevices = this._deviceSourceManager.getDevices;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"deviceSourceManager.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/deviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAY,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,2BAA2B,EAAsB,MAAM,+BAA+B,CAAC;AAKhG;;GAEG;AACH;IA8DI;;;OAGG;IACH,6BAAY,MAAc;QAA1B,iBAwBC;QAvBG,IAAM,mBAAmB,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,IAAI,KAAK,CAAkC,mBAAmB,CAAC,CAAC;QAChF,IAAI,CAAC,YAAY,GAAG,IAAI,KAAK,CAAS,mBAAmB,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QAEtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;YACpC,IAAI,CAAC,OAAO,CAAC,oBAAoB,GAAG,IAAI,2BAA2B,CAAC,MAAM,CAAC,CAAC;SAC/E;QACD,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,CAAC;QAE9C,cAAc;QACd,IAAI,CAAC,2BAA2B,GAAG,IAAI,UAAU,CAA2B,UAAC,QAAQ;YACjF,KAAI,CAAC,UAAU,EAAE,CA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KAAK,UAAU,CAAC,OAAO;gBACnB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;gBAC/B,IAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACpC,IAAI,OAAO,EAAE;oBACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACrC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;4BACZ,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;4BAC5B,MAAM;yBACT;qBACJ;iBACJ;gBACD,MAAM;SACb;IACL,CAAC;IACL,0BAAC;AAAD,CAAC,AAvKD,IAuKC","sourcesContent":["import { Engine } from '../../Engines/engine';\nimport { DeviceType } from './deviceEnums';\nimport { Nullable } from '../../types';\nimport { Observable, Observer } from '../../Misc/observable';\nimport { DeviceSource } from './deviceSource';\nimport { InternalDeviceSourceManager, IObservableManager } from './internalDeviceSourceManager';\nimport { IDisposable } from '../../scene';\nimport { ThinEngine } from '../../Engines/thinEngine';\nimport { IUIEvent } from '../../Events/deviceInputEvents';\n\n/**\n * Class to keep track of devices\n */\nexport class DeviceSourceManager implements IDisposable, IObservableManager {\n // Public Members\n /**\n * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices\n */\n public readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;\n\n /**\n * Observable to be triggered when after a device is disconnected\n */\n public readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;\n\n // Private Members\n private _engine: Engine;\n private _onDisposeObserver: Nullable<Observer<ThinEngine>>;\n private readonly _devices: Array<Array<DeviceSource<DeviceType>>>;\n private readonly _firstDevice: Array<number>;\n\n // Public Functions\n /**\n * Gets a DeviceSource, given a type and slot\n * @param deviceType Type of Device\n * @param deviceSlot Slot or ID of device\n * @returns DeviceSource\n */\n public getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>> {\n if (deviceSlot === undefined) {\n if (this._firstDevice[deviceType] === undefined) {\n return null;\n }\n\n deviceSlot = this._firstDevice[deviceType];\n }\n\n if (!this._devices[deviceType] || this._devices[deviceType][deviceSlot] === undefined) {\n return null;\n }\n\n return this._devices[deviceType][deviceSlot];\n }\n /**\n * Gets an array of DeviceSource objects for a given device type\n * @param deviceType Type of Device\n * @returns All available DeviceSources of a given type\n */\n public getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>> {\n return this._devices[deviceType].filter((source) => { return !!source; });\n }\n\n /**\n * Returns a read-only list of all available devices\n * @returns All available DeviceSources\n */\n public getDevices(): ReadonlyArray<DeviceSource<DeviceType>> {\n const deviceArray = new Array<DeviceSource<DeviceType>>();\n for (const deviceSet of this._devices) {\n deviceArray.push.apply(deviceArray, deviceSet);\n }\n\n return deviceArray;\n }\n\n /**\n * Default constructor\n * @param engine Used to get canvas (if applicable)\n */\n constructor(engine: Engine) {\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\n this._devices = new Array<Array<DeviceSource<DeviceType>>>(numberOfDeviceTypes);\n this._firstDevice = new Array<number>(numberOfDeviceTypes);\n this._engine = engine;\n\n if (!this._engine._deviceSourceManager) {\n this._engine._deviceSourceManager = new InternalDeviceSourceManager(engine);\n }\n this._engine._deviceSourceManager._refCount++;\n\n // Observables\n this.onDeviceConnectedObservable = new Observable<DeviceSource<DeviceType>>((observer) => {\n this.getDevices().forEach((device) => {\n this.onDeviceConnectedObservable.notifyObserver(observer, device);\n });\n });\n this.onDeviceDisconnectedObservable = new Observable<DeviceSource<DeviceType>>();\n\n this._engine._deviceSourceManager.registerManager(this);\n\n this._onDisposeObserver = engine.onDisposeObservable.add(() => {\n this.dispose();\n });\n }\n\n /**\n * Dispose of DeviceSourceManager\n */\n public dispose(): void {\n // Null out observable refs\n this.onDeviceConnectedObservable.clear();\n this.onDeviceDisconnectedObservable.clear();\n\n if (this._engine._deviceSourceManager) {\n this._engine._deviceSourceManager.unregisterManager(this);\n if (--this._engine._deviceSourceManager._refCount < 1) {\n this._engine._deviceSourceManager.dispose();\n delete this._engine._deviceSourceManager;\n }\n }\n this._engine.onDisposeObservable.remove(this._onDisposeObserver);\n }\n\n // Hidden Functions\n /** @hidden */\n public _addDevice(deviceSource: DeviceSource<DeviceType>): void {\n if (!this._devices[deviceSource.deviceType]) {\n this._devices[deviceSource.deviceType] = new Array<DeviceSource<DeviceType>>();\n }\n\n if (!this._devices[deviceSource.deviceType][deviceSource.deviceSlot]) {\n this._devices[deviceSource.deviceType][deviceSource.deviceSlot] = deviceSource;\n this._updateFirstDevices(deviceSource.deviceType);\n }\n\n this.onDeviceConnectedObservable.notifyObservers(deviceSource);\n }\n\n /** @hidden */\n public _removeDevice(deviceType: DeviceType, deviceSlot: number): void {\n const deviceSource = this._devices[deviceType]?.[deviceSlot]; // Grab local reference to use before removing from devices\n this.onDeviceDisconnectedObservable.notifyObservers(deviceSource);\n if (this._devices[deviceType]?.[deviceSlot]) {\n delete this._devices[deviceType][deviceSlot];\n }\n // Even if we don't delete a device, we should still check for the first device as things may have gotten out of sync.\n this._updateFirstDevices(deviceType);\n }\n\n /** @hidden */\n public _onInputChanged(deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent): void {\n this._devices[deviceType]?.[deviceSlot]?.onInputChangedObservable.notifyObservers(eventData);\n }\n\n // Private Functions\n private _updateFirstDevices(type: DeviceType): void {\n switch (type) {\n case DeviceType.Keyboard:\n case DeviceType.Mouse:\n this._firstDevice[type] = 0;\n break;\n case DeviceType.Touch:\n case DeviceType.DualSense:\n case DeviceType.DualShock:\n case DeviceType.Xbox:\n case DeviceType.Switch:\n case DeviceType.Generic:\n delete this._firstDevice[type];\n const devices = this._devices[type];\n if (devices) {\n for (let i = 0; i < devices.length; i++) {\n if (devices[i]) {\n this._firstDevice[type] = i;\n break;\n }\n }\n }\n break;\n }\n }\n}\n"]}
|
|
@@ -2,4 +2,4 @@ import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput, DualS
|
|
|
2
2
|
/**
|
|
3
3
|
* Type to handle enforcement of inputs
|
|
4
4
|
*/
|
|
5
|
-
export declare type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : T extends DeviceType.DualSense ? DualSenseInput : never;
|
|
5
|
+
export declare type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? Exclude<PointerInput, PointerInput.Move> : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : T extends DeviceType.DualSense ? DualSenseInput : never;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceTypes.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/deviceTypes.ts"],"names":[],"mappings":"","sourcesContent":["import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput, DualSenseInput } from './deviceEnums';\r\n\r\n/**\r\n * Type to handle enforcement of inputs\r\n */\r\nexport type DeviceInput<T extends DeviceType> =\r\n T extends DeviceType.Keyboard | DeviceType.Generic ? number :\r\n T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput :\r\n T extends DeviceType.DualShock ? DualShockInput :\r\n T extends DeviceType.Xbox ? XboxInput :\r\n T extends DeviceType.Switch ? SwitchInput :\r\n T extends DeviceType.DualSense ? DualSenseInput :\r\n never;"]}
|
|
1
|
+
{"version":3,"file":"deviceTypes.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/deviceTypes.ts"],"names":[],"mappings":"","sourcesContent":["import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput, DualSenseInput } from './deviceEnums';\r\n\r\n/**\r\n * Type to handle enforcement of inputs\r\n */\r\nexport type DeviceInput<T extends DeviceType> =\r\n T extends DeviceType.Keyboard | DeviceType.Generic ? number :\r\n T extends DeviceType.Mouse | DeviceType.Touch ? Exclude<PointerInput, PointerInput.Move> :\r\n T extends DeviceType.DualShock ? DualShockInput :\r\n T extends DeviceType.Xbox ? XboxInput :\r\n T extends DeviceType.Switch ? SwitchInput :\r\n T extends DeviceType.DualSense ? DualSenseInput :\r\n never;"]}
|
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IUIEvent } from "../../Events/deviceInputEvents";
|
|
2
2
|
import { IDisposable } from "../../scene";
|
|
3
3
|
import { Nullable } from "../../types";
|
|
4
4
|
import { DeviceType } from "./deviceEnums";
|
|
5
|
-
/**
|
|
6
|
-
* Interface for Observables in DeviceInputSystem
|
|
7
|
-
*/
|
|
8
|
-
export interface IDeviceEvent extends IEvent {
|
|
9
|
-
/**
|
|
10
|
-
* Device type
|
|
11
|
-
*/
|
|
12
|
-
deviceType: DeviceType;
|
|
13
|
-
/**
|
|
14
|
-
* Device slot
|
|
15
|
-
*/
|
|
16
|
-
deviceSlot: number;
|
|
17
|
-
/**
|
|
18
|
-
* Input array index
|
|
19
|
-
*/
|
|
20
|
-
inputIndex: number;
|
|
21
|
-
/**
|
|
22
|
-
* Previous state of given input
|
|
23
|
-
*/
|
|
24
|
-
previousState: Nullable<number>;
|
|
25
|
-
/**
|
|
26
|
-
* Current state of given input
|
|
27
|
-
*/
|
|
28
|
-
currentState: Nullable<number>;
|
|
29
|
-
}
|
|
30
5
|
/**
|
|
31
6
|
* Interface for NativeInput object
|
|
32
7
|
*/
|
|
@@ -42,7 +17,7 @@ export interface INativeInput extends IDisposable {
|
|
|
42
17
|
/**
|
|
43
18
|
* Callback for when input is changed on a device
|
|
44
19
|
*/
|
|
45
|
-
onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number,
|
|
20
|
+
onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>) => void;
|
|
46
21
|
/**
|
|
47
22
|
* Checks for current device input value, given an id and input index.
|
|
48
23
|
* @param deviceType Type of device
|
|
@@ -73,7 +48,7 @@ export interface IDeviceInputSystem extends IDisposable {
|
|
|
73
48
|
/**
|
|
74
49
|
* Callback for when an input is changed
|
|
75
50
|
*/
|
|
76
|
-
onInputChanged: (
|
|
51
|
+
onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;
|
|
77
52
|
/**
|
|
78
53
|
* Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
|
|
79
54
|
* @param deviceType Enum specifiying device type
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputInterfaces.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/inputInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"inputInterfaces.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/inputInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["import { IUIEvent } from \"../../Events/deviceInputEvents\";\r\nimport { IDisposable } from \"../../scene\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceType } from \"./deviceEnums\";\r\n\r\n/**\r\n * Interface for NativeInput object\r\n */\r\nexport interface INativeInput extends IDisposable {\r\n /**\r\n * Callback for when a device is connected\r\n */\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when a device is disconnected\r\n */\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when input is changed on a device\r\n */\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: Nullable<number>) => void;\r\n\r\n /**\r\n * Checks for current device input value, given an id and input index.\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 * @returns Current value of input\r\n */\r\n pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;\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 isDeviceAvailable(deviceType: DeviceType): boolean;\r\n}\r\n\r\n/**\r\n * Interface for DeviceInputSystem implementations (JS and Native)\r\n */\r\nexport interface IDeviceInputSystem extends IDisposable {\r\n // Callbacks\r\n /**\r\n * Callback for when a device is connected\r\n */\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when a device is disconnected\r\n */\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;\r\n\r\n /**\r\n * Callback for when an input is changed\r\n */\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;\r\n\r\n // 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 pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;\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 isDeviceAvailable(deviceType: DeviceType): boolean;\r\n}\r\n"]}
|