@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,46 +1,31 @@
|
|
|
1
1
|
import { IDisposable } from '../../scene';
|
|
2
2
|
import { DeviceType } from './deviceEnums';
|
|
3
|
-
import { Nullable } from '../../types';
|
|
4
3
|
import { Observable } from '../../Misc/observable';
|
|
5
|
-
import { IDeviceEvent } from './inputInterfaces';
|
|
6
4
|
import { DeviceSource } from './deviceSource';
|
|
7
5
|
import { Engine } from '../../Engines/engine';
|
|
6
|
+
import { IUIEvent } from '../../Events/deviceInputEvents';
|
|
8
7
|
declare module "../../Engines/engine" {
|
|
9
8
|
interface Engine {
|
|
10
9
|
/** @hidden */
|
|
11
|
-
_deviceSourceManager
|
|
10
|
+
_deviceSourceManager?: InternalDeviceSourceManager;
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
/** @hidden */
|
|
14
|
+
export interface IObservableManager {
|
|
15
|
+
onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
|
|
16
|
+
onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
|
|
17
|
+
_onInputChanged(deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent): void;
|
|
18
|
+
_addDevice(deviceSource: DeviceSource<DeviceType>): void;
|
|
19
|
+
_removeDevice(deviceType: DeviceType, deviceSlot: number): void;
|
|
20
|
+
}
|
|
21
|
+
/** @hidden */
|
|
15
22
|
export declare class InternalDeviceSourceManager implements IDisposable {
|
|
16
|
-
readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
|
|
17
|
-
readonly onInputChangedObservable: Observable<IDeviceEvent>;
|
|
18
|
-
readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
|
|
19
23
|
private readonly _devices;
|
|
20
|
-
private readonly _firstDevice;
|
|
21
24
|
private readonly _deviceInputSystem;
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
getDevices: () => ReadonlyArray<DeviceSource<DeviceType>>;
|
|
25
|
+
private readonly _registeredManagers;
|
|
26
|
+
_refCount: number;
|
|
27
|
+
constructor(engine: Engine);
|
|
28
|
+
readonly registerManager: (manager: IObservableManager) => void;
|
|
29
|
+
readonly unregisterManager: (manager: IObservableManager) => void;
|
|
28
30
|
dispose(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Function to add device name to device list
|
|
31
|
-
* @param deviceType Enum specifying device type
|
|
32
|
-
* @param deviceSlot "Slot" or index that device is referenced in
|
|
33
|
-
*/
|
|
34
|
-
private _addDevice;
|
|
35
|
-
/**
|
|
36
|
-
* Function to remove device name to device list
|
|
37
|
-
* @param deviceType Enum specifying device type
|
|
38
|
-
* @param deviceSlot "Slot" or index that device is referenced in
|
|
39
|
-
*/
|
|
40
|
-
private _removeDevice;
|
|
41
|
-
/**
|
|
42
|
-
* Updates array storing first connected device of each type
|
|
43
|
-
* @param type Type of Device
|
|
44
|
-
*/
|
|
45
|
-
private _updateFirstDevices;
|
|
46
31
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DeviceType } from './deviceEnums.js';
|
|
2
|
-
import { Observable } from '../../Misc/observable.js';
|
|
3
2
|
import { NativeDeviceInputSystem } from './nativeDeviceInputSystem.js';
|
|
4
3
|
import { WebDeviceInputSystem } from './webDeviceInputSystem.js';
|
|
5
4
|
import { DeviceSource } from './deviceSource.js';
|
|
@@ -7,47 +6,27 @@ import { DeviceSource } from './deviceSource.js';
|
|
|
7
6
|
var InternalDeviceSourceManager = /** @class */ (function () {
|
|
8
7
|
function InternalDeviceSourceManager(engine) {
|
|
9
8
|
var _this = this;
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
_this.getDevices().forEach(function (device) {
|
|
13
|
-
if (device) {
|
|
14
|
-
_this.onDeviceConnectedObservable.notifyObserver(observer, device);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
this.onInputChangedObservable = new Observable();
|
|
19
|
-
this.onDeviceDisconnectedObservable = new Observable();
|
|
9
|
+
this._registeredManagers = new Array();
|
|
10
|
+
this._refCount = 0;
|
|
20
11
|
// Public Functions
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
this.registerManager = function (manager) {
|
|
13
|
+
for (var deviceType = 0; deviceType < _this._devices.length; deviceType++) {
|
|
14
|
+
var device = _this._devices[deviceType];
|
|
15
|
+
for (var deviceSlotKey in device) {
|
|
16
|
+
var deviceSlot = +deviceSlotKey;
|
|
17
|
+
manager._addDevice(new DeviceSource(_this._deviceInputSystem, deviceType, deviceSlot));
|
|
25
18
|
}
|
|
26
|
-
deviceSlot = _this._firstDevice[deviceType];
|
|
27
|
-
}
|
|
28
|
-
if (!_this._devices[deviceType] || _this._devices[deviceType][deviceSlot] === undefined) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
if (!_this._oninputChangedObserver) {
|
|
32
|
-
_this._oninputChangedObserver = _this.onInputChangedObservable.add(function (eventData) {
|
|
33
|
-
_this._devices[eventData.deviceType][eventData.deviceSlot].onInputChangedObservable.notifyObservers(eventData);
|
|
34
|
-
});
|
|
35
19
|
}
|
|
36
|
-
|
|
20
|
+
_this._registeredManagers.push(manager);
|
|
37
21
|
};
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
_this._devices.forEach(function (deviceSet) {
|
|
44
|
-
deviceArray.push.apply(deviceArray, deviceSet);
|
|
45
|
-
});
|
|
46
|
-
return deviceArray;
|
|
22
|
+
this.unregisterManager = function (manager) {
|
|
23
|
+
var idx = _this._registeredManagers.indexOf(manager);
|
|
24
|
+
if (idx > -1) {
|
|
25
|
+
_this._registeredManagers.splice(idx, 1);
|
|
26
|
+
}
|
|
47
27
|
};
|
|
48
28
|
var numberOfDeviceTypes = Object.keys(DeviceType).length / 2;
|
|
49
29
|
this._devices = new Array(numberOfDeviceTypes);
|
|
50
|
-
this._firstDevice = new Array(numberOfDeviceTypes);
|
|
51
30
|
if (typeof _native !== 'undefined') {
|
|
52
31
|
this._deviceInputSystem = (_native.DeviceInputSystem) ? new NativeDeviceInputSystem(new _native.DeviceInputSystem()) : new NativeDeviceInputSystem();
|
|
53
32
|
}
|
|
@@ -55,89 +34,40 @@ var InternalDeviceSourceManager = /** @class */ (function () {
|
|
|
55
34
|
this._deviceInputSystem = new WebDeviceInputSystem(engine);
|
|
56
35
|
}
|
|
57
36
|
this._deviceInputSystem.onDeviceConnected = function (deviceType, deviceSlot) {
|
|
58
|
-
_this.
|
|
59
|
-
|
|
37
|
+
if (!_this._devices[deviceType]) {
|
|
38
|
+
_this._devices[deviceType] = new Array();
|
|
39
|
+
}
|
|
40
|
+
if (!_this._devices[deviceType][deviceSlot]) {
|
|
41
|
+
_this._devices[deviceType][deviceSlot] = deviceSlot;
|
|
42
|
+
}
|
|
43
|
+
for (var _i = 0, _a = _this._registeredManagers; _i < _a.length; _i++) {
|
|
44
|
+
var manager = _a[_i];
|
|
45
|
+
var deviceSource = new DeviceSource(_this._deviceInputSystem, deviceType, deviceSlot);
|
|
46
|
+
manager._addDevice(deviceSource);
|
|
47
|
+
}
|
|
60
48
|
};
|
|
61
49
|
this._deviceInputSystem.onDeviceDisconnected = function (deviceType, deviceSlot) {
|
|
62
|
-
var
|
|
63
|
-
_this.
|
|
64
|
-
|
|
50
|
+
var _a;
|
|
51
|
+
if ((_a = _this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[deviceSlot]) {
|
|
52
|
+
delete _this._devices[deviceType][deviceSlot];
|
|
53
|
+
}
|
|
54
|
+
for (var _i = 0, _b = _this._registeredManagers; _i < _b.length; _i++) {
|
|
55
|
+
var manager = _b[_i];
|
|
56
|
+
manager._removeDevice(deviceType, deviceSlot);
|
|
57
|
+
}
|
|
65
58
|
};
|
|
66
|
-
this._deviceInputSystem.onInputChanged = function (
|
|
67
|
-
|
|
59
|
+
this._deviceInputSystem.onInputChanged = function (deviceType, deviceSlot, eventData) {
|
|
60
|
+
if (eventData) {
|
|
61
|
+
for (var _i = 0, _a = _this._registeredManagers; _i < _a.length; _i++) {
|
|
62
|
+
var manager = _a[_i];
|
|
63
|
+
manager._onInputChanged(deviceType, deviceSlot, eventData);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
68
66
|
};
|
|
69
67
|
}
|
|
70
|
-
InternalDeviceSourceManager._Create = function (engine) {
|
|
71
|
-
if (!engine._deviceSourceManager) {
|
|
72
|
-
engine._deviceSourceManager = new InternalDeviceSourceManager(engine);
|
|
73
|
-
engine.onDisposeObservable.add(function () {
|
|
74
|
-
engine._deviceSourceManager.dispose();
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return engine._deviceSourceManager;
|
|
78
|
-
};
|
|
79
68
|
InternalDeviceSourceManager.prototype.dispose = function () {
|
|
80
|
-
this.onDeviceConnectedObservable.clear();
|
|
81
|
-
this.onDeviceDisconnectedObservable.clear();
|
|
82
69
|
this._deviceInputSystem.dispose();
|
|
83
70
|
};
|
|
84
|
-
// Private Functions
|
|
85
|
-
/**
|
|
86
|
-
* Function to add device name to device list
|
|
87
|
-
* @param deviceType Enum specifying device type
|
|
88
|
-
* @param deviceSlot "Slot" or index that device is referenced in
|
|
89
|
-
*/
|
|
90
|
-
InternalDeviceSourceManager.prototype._addDevice = function (deviceType, deviceSlot) {
|
|
91
|
-
if (!this._devices[deviceType]) {
|
|
92
|
-
this._devices[deviceType] = new Array();
|
|
93
|
-
}
|
|
94
|
-
if (!this._devices[deviceType][deviceSlot]) {
|
|
95
|
-
this._devices[deviceType][deviceSlot] = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);
|
|
96
|
-
this._updateFirstDevices(deviceType);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Function to remove device name to device list
|
|
101
|
-
* @param deviceType Enum specifying device type
|
|
102
|
-
* @param deviceSlot "Slot" or index that device is referenced in
|
|
103
|
-
*/
|
|
104
|
-
InternalDeviceSourceManager.prototype._removeDevice = function (deviceType, deviceSlot) {
|
|
105
|
-
var _a;
|
|
106
|
-
if ((_a = this._devices[deviceType]) === null || _a === void 0 ? void 0 : _a[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
|
-
/**
|
|
113
|
-
* Updates array storing first connected device of each type
|
|
114
|
-
* @param type Type of Device
|
|
115
|
-
*/
|
|
116
|
-
InternalDeviceSourceManager.prototype._updateFirstDevices = function (type) {
|
|
117
|
-
switch (type) {
|
|
118
|
-
case DeviceType.Keyboard:
|
|
119
|
-
case DeviceType.Mouse:
|
|
120
|
-
this._firstDevice[type] = 0;
|
|
121
|
-
break;
|
|
122
|
-
case DeviceType.Touch:
|
|
123
|
-
case DeviceType.DualSense:
|
|
124
|
-
case DeviceType.DualShock:
|
|
125
|
-
case DeviceType.Xbox:
|
|
126
|
-
case DeviceType.Switch:
|
|
127
|
-
case DeviceType.Generic:
|
|
128
|
-
delete this._firstDevice[type];
|
|
129
|
-
var devices = this._devices[type];
|
|
130
|
-
if (devices) {
|
|
131
|
-
for (var i = 0; i < devices.length; i++) {
|
|
132
|
-
if (devices[i]) {
|
|
133
|
-
this._firstDevice[type] = i;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
71
|
return InternalDeviceSourceManager;
|
|
142
72
|
}());
|
|
143
73
|
export { InternalDeviceSourceManager };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/internalDeviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3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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,kCAAC;AAAD,CAAC,AAjKD,IAiKC","sourcesContent":["import { IDisposable } from '../../scene';\r\nimport { DeviceType } from './deviceEnums';\r\nimport { Nullable } from '../../types';\r\nimport { Observable, Observer } from '../../Misc/observable';\r\nimport { IDeviceEvent, IDeviceInputSystem } from './inputInterfaces';\r\nimport { NativeDeviceInputSystem } from './nativeDeviceInputSystem';\r\nimport { WebDeviceInputSystem } from './webDeviceInputSystem';\r\nimport { DeviceSource } from './deviceSource';\r\nimport { INative } from '../../Engines/Native/nativeInterfaces';\r\nimport { Engine } from '../../Engines/engine';\r\n\r\ndeclare const _native: INative;\r\n\r\ndeclare module \"../../Engines/engine\" {\r\n interface Engine {\r\n /** @hidden */\r\n _deviceSourceManager: InternalDeviceSourceManager;\r\n }\r\n}\r\n\r\n/** @hidden */\r\nexport class InternalDeviceSourceManager implements IDisposable {\r\n // Public Members\r\n public readonly onDeviceConnectedObservable = new Observable<DeviceSource<DeviceType>>((observer) => {\r\n this.getDevices().forEach((device) => {\r\n if (device) {\r\n this.onDeviceConnectedObservable.notifyObserver(observer, device);\r\n }\r\n });\r\n });\r\n\r\n public readonly onInputChangedObservable = new Observable<IDeviceEvent>();\r\n\r\n public readonly onDeviceDisconnectedObservable = new Observable<DeviceSource<DeviceType>>();\r\n\r\n // Private Members\r\n private readonly _devices: Array<Array<DeviceSource<DeviceType>>>;\r\n private readonly _firstDevice: Array<number>;\r\n private readonly _deviceInputSystem: IDeviceInputSystem;\r\n\r\n private _oninputChangedObserver: Nullable<Observer<IDeviceEvent>>;\r\n\r\n public static _Create(engine: Engine): InternalDeviceSourceManager {\r\n if (!engine._deviceSourceManager) {\r\n engine._deviceSourceManager = new InternalDeviceSourceManager(engine);\r\n\r\n engine.onDisposeObservable.add(() => {\r\n engine._deviceSourceManager.dispose();\r\n });\r\n }\r\n return engine._deviceSourceManager;\r\n }\r\n\r\n private constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array<Array<DeviceSource<DeviceType>>>(numberOfDeviceTypes);\r\n this._firstDevice = new Array<number>(numberOfDeviceTypes);\r\n\r\n if (typeof _native !== 'undefined') {\r\n this._deviceInputSystem = (_native.DeviceInputSystem) ? new NativeDeviceInputSystem(new _native.DeviceInputSystem()) : new NativeDeviceInputSystem();\r\n }\r\n else {\r\n this._deviceInputSystem = new WebDeviceInputSystem(engine);\r\n }\r\n\r\n this._deviceInputSystem.onDeviceConnected = (deviceType, deviceSlot) => {\r\n this._addDevice(deviceType, deviceSlot);\r\n this.onDeviceConnectedObservable.notifyObservers(this.getDeviceSource(deviceType, deviceSlot)!);\r\n };\r\n\r\n this._deviceInputSystem.onDeviceDisconnected = (deviceType, deviceSlot) => {\r\n const device = this.getDeviceSource(deviceType, deviceSlot)!; // Grab local reference to use before removing from devices\r\n this._removeDevice(deviceType, deviceSlot);\r\n this.onDeviceDisconnectedObservable.notifyObservers(device);\r\n };\r\n\r\n this._deviceInputSystem.onInputChanged = (deviceEvent) => {\r\n this.onInputChangedObservable.notifyObservers(deviceEvent);\r\n };\r\n }\r\n\r\n // Public Functions\r\n public getDeviceSource = <T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>> => {\r\n if (deviceSlot === undefined) {\r\n if (this._firstDevice[deviceType] === undefined) {\r\n return null;\r\n }\r\n\r\n deviceSlot = this._firstDevice[deviceType];\r\n }\r\n\r\n if (!this._devices[deviceType] || this._devices[deviceType][deviceSlot] === undefined) {\r\n return null;\r\n }\r\n\r\n if (!this._oninputChangedObserver) {\r\n this._oninputChangedObserver = this.onInputChangedObservable.add((eventData) => {\r\n this._devices[eventData.deviceType][eventData.deviceSlot].onInputChangedObservable.notifyObservers(eventData);\r\n });\r\n }\r\n\r\n return this._devices[deviceType][deviceSlot];\r\n }\r\n\r\n public getDeviceSources = <T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>> => {\r\n return this._devices[deviceType].filter((source) => { return !!source; });\r\n }\r\n\r\n public getDevices = (): ReadonlyArray<DeviceSource<DeviceType>> => {\r\n const deviceArray = new Array<DeviceSource<DeviceType>>();\r\n this._devices.forEach((deviceSet) => {\r\n deviceArray.push.apply(deviceArray, deviceSet);\r\n });\r\n\r\n return deviceArray;\r\n }\r\n\r\n public dispose(): void {\r\n this.onDeviceConnectedObservable.clear();\r\n this.onDeviceDisconnectedObservable.clear();\r\n this._deviceInputSystem.dispose();\r\n }\r\n\r\n // Private Functions\r\n /**\r\n * Function to add device name to device list\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _addDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (!this._devices[deviceType]) {\r\n this._devices[deviceType] = new Array<DeviceSource<DeviceType>>();\r\n }\r\n\r\n if (!this._devices[deviceType][deviceSlot]) {\r\n this._devices[deviceType][deviceSlot] = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);\r\n this._updateFirstDevices(deviceType);\r\n }\r\n }\r\n\r\n /**\r\n * Function to remove device name to device list\r\n * @param deviceType Enum specifying device type\r\n * @param deviceSlot \"Slot\" or index that device is referenced in\r\n */\r\n private _removeDevice(deviceType: DeviceType, deviceSlot: number): void {\r\n if (this._devices[deviceType]?.[deviceSlot]) {\r\n delete this._devices[deviceType][deviceSlot];\r\n }\r\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.\r\n this._updateFirstDevices(deviceType);\r\n }\r\n\r\n /**\r\n * Updates array storing first connected device of each type\r\n * @param type Type of Device\r\n */\r\n private _updateFirstDevices(type: DeviceType): void {\r\n switch (type) {\r\n case DeviceType.Keyboard:\r\n case DeviceType.Mouse:\r\n this._firstDevice[type] = 0;\r\n break;\r\n case DeviceType.Touch:\r\n case DeviceType.DualSense:\r\n case DeviceType.DualShock:\r\n case DeviceType.Xbox:\r\n case DeviceType.Switch:\r\n case DeviceType.Generic:\r\n delete this._firstDevice[type];\r\n const devices = this._devices[type];\r\n if (devices) {\r\n for (let i = 0; i < devices.length; i++) {\r\n if (devices[i]) {\r\n this._firstDevice[type] = i;\r\n break;\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"internalDeviceSourceManager.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/internalDeviceSourceManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAyB9C,cAAc;AACd;IAWI,qCAAmB,MAAc;QAAjC,iBAyCC;QA7CgB,wBAAmB,GAAG,IAAI,KAAK,EAAsB,CAAC;QAEhE,cAAS,GAAG,CAAC,CAAC;QA6CrB,mBAAmB;QACH,oBAAe,GAAG,UAAC,OAA2B;YAC1D,KAAK,IAAI,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,KAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;gBACtE,IAAM,MAAM,GAAG,KAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;gBACzC,KAAK,IAAM,aAAa,IAA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IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;IACL,kCAAC;AAAD,CAAC,AA7ED,IA6EC","sourcesContent":["import { IDisposable } from '../../scene';\r\nimport { DeviceType } from './deviceEnums';\r\nimport { Observable } from '../../Misc/observable';\r\nimport { IDeviceInputSystem } from './inputInterfaces';\r\nimport { NativeDeviceInputSystem } from './nativeDeviceInputSystem';\r\nimport { WebDeviceInputSystem } from './webDeviceInputSystem';\r\nimport { DeviceSource } from './deviceSource';\r\nimport { INative } from '../../Engines/Native/nativeInterfaces';\r\nimport { Engine } from '../../Engines/engine';\r\nimport { IUIEvent } from '../../Events/deviceInputEvents';\r\n\r\ndeclare const _native: INative;\r\n\r\ndeclare module \"../../Engines/engine\" {\r\n interface Engine {\r\n /** @hidden */\r\n _deviceSourceManager?: InternalDeviceSourceManager;\r\n }\r\n}\r\n\r\n/** @hidden */\r\nexport interface IObservableManager {\r\n onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;\r\n onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;\r\n\r\n // Functions\r\n _onInputChanged(deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent): void;\r\n _addDevice(deviceSource: DeviceSource<DeviceType>): void;\r\n _removeDevice(deviceType: DeviceType, deviceSlot: number): void;\r\n}\r\n\r\n/** @hidden */\r\nexport class InternalDeviceSourceManager implements IDisposable {\r\n // Private Members\r\n // This is a master list of all device type/slot combos\r\n private readonly _devices: Array<Array<number>>;\r\n\r\n private readonly _deviceInputSystem: IDeviceInputSystem;\r\n\r\n private readonly _registeredManagers = new Array<IObservableManager>();\r\n\r\n public _refCount = 0;\r\n\r\n public constructor(engine: Engine) {\r\n const numberOfDeviceTypes = Object.keys(DeviceType).length / 2;\r\n this._devices = new Array<Array<number>>(numberOfDeviceTypes);\r\n\r\n if (typeof _native !== 'undefined') {\r\n this._deviceInputSystem = (_native.DeviceInputSystem) ? new NativeDeviceInputSystem(new _native.DeviceInputSystem()) : new NativeDeviceInputSystem();\r\n }\r\n else {\r\n this._deviceInputSystem = new WebDeviceInputSystem(engine);\r\n }\r\n\r\n this._deviceInputSystem.onDeviceConnected = (deviceType, deviceSlot) => {\r\n if (!this._devices[deviceType]) {\r\n this._devices[deviceType] = new Array<number>();\r\n }\r\n\r\n if (!this._devices[deviceType][deviceSlot]) {\r\n this._devices[deviceType][deviceSlot] = deviceSlot;\r\n }\r\n for (const manager of this._registeredManagers) {\r\n const deviceSource = new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot);\r\n manager._addDevice(deviceSource);\r\n }\r\n };\r\n\r\n this._deviceInputSystem.onDeviceDisconnected = (deviceType, deviceSlot) => {\r\n if (this._devices[deviceType]?.[deviceSlot]) {\r\n delete this._devices[deviceType][deviceSlot];\r\n }\r\n for (const manager of this._registeredManagers) {\r\n manager._removeDevice(deviceType, deviceSlot);\r\n }\r\n };\r\n\r\n this._deviceInputSystem.onInputChanged = (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => {\r\n if (eventData) {\r\n for (const manager of this._registeredManagers) {\r\n manager._onInputChanged(deviceType, deviceSlot, eventData);\r\n }\r\n }\r\n };\r\n }\r\n\r\n // Public Functions\r\n public readonly registerManager = (manager: IObservableManager): void => {\r\n for (let deviceType = 0; deviceType < this._devices.length; deviceType++) {\r\n const device = this._devices[deviceType];\r\n for (const deviceSlotKey in device) {\r\n const deviceSlot = +deviceSlotKey;\r\n manager._addDevice(new DeviceSource(this._deviceInputSystem, deviceType, deviceSlot));\r\n }\r\n }\r\n this._registeredManagers.push(manager);\r\n }\r\n\r\n public readonly unregisterManager = (manager: IObservableManager): void => {\r\n const idx = this._registeredManagers.indexOf(manager);\r\n\r\n if (idx > -1) {\r\n this._registeredManagers.splice(idx, 1);\r\n }\r\n }\r\n\r\n public dispose(): void {\r\n this._deviceInputSystem.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { IUIEvent } from "../../Events/deviceInputEvents";
|
|
1
2
|
import { DeviceType } from "./deviceEnums";
|
|
2
|
-
import {
|
|
3
|
+
import { IDeviceInputSystem, INativeInput } from "./inputInterfaces";
|
|
3
4
|
/** @hidden */
|
|
4
5
|
export declare class NativeDeviceInputSystem implements IDeviceInputSystem {
|
|
5
6
|
onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
|
|
6
7
|
onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
|
|
7
|
-
onInputChanged: (
|
|
8
|
+
onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;
|
|
8
9
|
private readonly _nativeInput;
|
|
9
10
|
constructor(nativeInput?: INativeInput);
|
|
10
11
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DeviceEventFactory } from "../Helpers/eventFactory.js";
|
|
2
|
-
import { DeviceType, PointerInput } from "./deviceEnums.js";
|
|
2
|
+
import { DeviceType, NativePointerInput, PointerInput } from "./deviceEnums.js";
|
|
3
3
|
/** @hidden */
|
|
4
4
|
var NativeDeviceInputSystem = /** @class */ (function () {
|
|
5
5
|
function NativeDeviceInputSystem(nativeInput) {
|
|
6
6
|
var _this = this;
|
|
7
7
|
this.onDeviceConnected = function (deviceType, deviceSlot) { };
|
|
8
8
|
this.onDeviceDisconnected = function (deviceType, deviceSlot) { };
|
|
9
|
-
this.onInputChanged = function (
|
|
9
|
+
this.onInputChanged = function (deviceType, deviceSlot, eventData) { };
|
|
10
10
|
this._nativeInput = nativeInput || this._createDummyNativeInput();
|
|
11
11
|
this._nativeInput.onDeviceConnected = function (deviceType, deviceSlot) {
|
|
12
12
|
_this.onDeviceConnected(deviceType, deviceSlot);
|
|
@@ -14,16 +14,10 @@ var NativeDeviceInputSystem = /** @class */ (function () {
|
|
|
14
14
|
this._nativeInput.onDeviceDisconnected = function (deviceType, deviceSlot) {
|
|
15
15
|
_this.onDeviceDisconnected(deviceType, deviceSlot);
|
|
16
16
|
};
|
|
17
|
-
this._nativeInput.onInputChanged = function (deviceType, deviceSlot, inputIndex,
|
|
18
|
-
var idx = (inputIndex ===
|
|
19
|
-
var evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot,
|
|
20
|
-
|
|
21
|
-
deviceEvent.deviceType = deviceType;
|
|
22
|
-
deviceEvent.deviceSlot = deviceSlot;
|
|
23
|
-
deviceEvent.inputIndex = idx;
|
|
24
|
-
deviceEvent.previousState = previousState;
|
|
25
|
-
deviceEvent.currentState = currentState;
|
|
26
|
-
_this.onInputChanged(deviceEvent);
|
|
17
|
+
this._nativeInput.onInputChanged = function (deviceType, deviceSlot, inputIndex, currentState) {
|
|
18
|
+
var idx = (inputIndex === NativePointerInput.Horizontal || inputIndex === NativePointerInput.Vertical || inputIndex === NativePointerInput.DeltaHorizontal || inputIndex === NativePointerInput.DeltaVertical) ? PointerInput.Move : inputIndex;
|
|
19
|
+
var evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, idx, currentState, _this);
|
|
20
|
+
_this.onInputChanged(deviceType, deviceSlot, evt);
|
|
27
21
|
};
|
|
28
22
|
}
|
|
29
23
|
// Public functions
|
|
@@ -62,7 +56,7 @@ var NativeDeviceInputSystem = /** @class */ (function () {
|
|
|
62
56
|
var nativeInput = {
|
|
63
57
|
onDeviceConnected: function (deviceType, deviceSlot) { },
|
|
64
58
|
onDeviceDisconnected: function (deviceType, deviceSlot) { },
|
|
65
|
-
onInputChanged: function (deviceType, deviceSlot, inputIndex,
|
|
59
|
+
onInputChanged: function (deviceType, deviceSlot, inputIndex, currentState) { },
|
|
66
60
|
pollInput: function () { return 0; },
|
|
67
61
|
isDeviceAvailable: function () { return false; },
|
|
68
62
|
dispose: function () { },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeDeviceInputSystem.js","sourceRoot":"","sources":["../../../../sourceES6/core/DeviceInput/InputDevices/nativeDeviceInputSystem.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nativeDe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zED,IAyEC","sourcesContent":["import { IUIEvent } from \"../../Events/deviceInputEvents\";\r\nimport { Nullable } from \"../../types\";\r\nimport { DeviceEventFactory } from \"../Helpers/eventFactory\";\r\nimport { DeviceType, NativePointerInput, PointerInput } from \"./deviceEnums\";\r\nimport { 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 = (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => { };\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, currentState) => {\r\n const idx = (inputIndex === NativePointerInput.Horizontal || inputIndex === NativePointerInput.Vertical || inputIndex === NativePointerInput.DeltaHorizontal || inputIndex === NativePointerInput.DeltaVertical) ? PointerInput.Move : inputIndex;\r\n const evt = DeviceEventFactory.CreateDeviceEvent(deviceType, deviceSlot, idx, currentState, this);\r\n\r\n this.onInputChanged(deviceType, deviceSlot, evt);\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, currentState: Nullable<number>) => { },\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}"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Engine } from "../../Engines/engine";
|
|
2
|
+
import { IUIEvent } from "../../Events/deviceInputEvents";
|
|
2
3
|
import { DeviceType } from "./deviceEnums";
|
|
3
|
-
import {
|
|
4
|
+
import { IDeviceInputSystem } from "./inputInterfaces";
|
|
4
5
|
/** @hidden */
|
|
5
6
|
export declare class WebDeviceInputSystem implements IDeviceInputSystem {
|
|
6
7
|
/** onDeviceConnected property */
|
|
7
8
|
set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
|
|
8
9
|
get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
|
|
9
10
|
onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
|
|
10
|
-
onInputChanged: (
|
|
11
|
+
onInputChanged: (deviceType: DeviceType, deviceSlot: number, eventData: IUIEvent) => void;
|
|
11
12
|
private _inputs;
|
|
12
13
|
private _gamepads;
|
|
13
14
|
private _keyboardActive;
|
|
@@ -22,9 +23,11 @@ export declare class WebDeviceInputSystem implements IDeviceInputSystem {
|
|
|
22
23
|
private _pointerMoveEvent;
|
|
23
24
|
private _pointerDownEvent;
|
|
24
25
|
private _pointerUpEvent;
|
|
26
|
+
private _pointerCancelEvent;
|
|
25
27
|
private _pointerWheelEvent;
|
|
26
28
|
private _pointerBlurEvent;
|
|
27
29
|
private _wheelEventName;
|
|
30
|
+
private _eventsAttached;
|
|
28
31
|
private _mouseId;
|
|
29
32
|
private readonly _isUsingFirefox;
|
|
30
33
|
private _activeTouchIds;
|
|
@@ -53,9 +56,13 @@ export declare class WebDeviceInputSystem implements IDeviceInputSystem {
|
|
|
53
56
|
*/
|
|
54
57
|
dispose(): void;
|
|
55
58
|
/**
|
|
56
|
-
*
|
|
59
|
+
* Enable listening for user input events
|
|
57
60
|
*/
|
|
58
|
-
private
|
|
61
|
+
private _enableEvents;
|
|
62
|
+
/**
|
|
63
|
+
* Disable listening for user input events
|
|
64
|
+
*/
|
|
65
|
+
private _disableEvents;
|
|
59
66
|
/**
|
|
60
67
|
* Checks for existing connections to devices and register them, if necessary
|
|
61
68
|
* Currently handles gamepads and mouse
|
|
@@ -118,8 +125,4 @@ export declare class WebDeviceInputSystem implements IDeviceInputSystem {
|
|
|
118
125
|
* @returns DeviceType interpreted from event
|
|
119
126
|
*/
|
|
120
127
|
private _getPointerType;
|
|
121
|
-
/**
|
|
122
|
-
* Remove events from active input element
|
|
123
|
-
*/
|
|
124
|
-
private _removeEvents;
|
|
125
128
|
}
|