@epicgames-ps/lib-pixelstreamingfrontend-ue5.5 0.3.0 → 0.3.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/dist/commonjs/AFK/AFKController.js +109 -109
- package/dist/commonjs/Config/Config.js +559 -559
- package/dist/commonjs/Config/SettingBase.js +98 -98
- package/dist/commonjs/Config/SettingFlag.js +49 -49
- package/dist/commonjs/Config/SettingNumber.js +83 -83
- package/dist/commonjs/Config/SettingOption.js +84 -84
- package/dist/commonjs/Config/SettingText.js +42 -42
- package/dist/commonjs/DataChannel/DataChannelController.js +106 -106
- package/dist/commonjs/DataChannel/DataChannelLatencyTestController.js +94 -94
- package/dist/commonjs/DataChannel/DataChannelLatencyTestResults.js +18 -18
- package/dist/commonjs/DataChannel/DataChannelSender.js +43 -43
- package/dist/commonjs/DataChannel/InitialSettings.js +41 -41
- package/dist/commonjs/DataChannel/LatencyTestResults.js +60 -60
- package/dist/commonjs/FreezeFrame/FreezeFrame.js +93 -93
- package/dist/commonjs/FreezeFrame/FreezeFrameController.js +95 -95
- package/dist/commonjs/Inputs/GamepadController.js +188 -188
- package/dist/commonjs/Inputs/GamepadTypes.js +21 -21
- package/dist/commonjs/Inputs/IInputController.js +2 -2
- package/dist/commonjs/Inputs/InputClassesFactory.js +96 -96
- package/dist/commonjs/Inputs/KeyCodes.js +112 -112
- package/dist/commonjs/Inputs/KeyboardController.js +137 -137
- package/dist/commonjs/Inputs/MouseButtons.js +28 -28
- package/dist/commonjs/Inputs/MouseController.js +97 -97
- package/dist/commonjs/Inputs/MouseControllerHovering.js +93 -93
- package/dist/commonjs/Inputs/MouseControllerLocked.js +153 -153
- package/dist/commonjs/Inputs/SpecialKeyCodes.js +19 -19
- package/dist/commonjs/Inputs/TouchController.js +123 -123
- package/dist/commonjs/Inputs/TouchControllerFake.js +91 -91
- package/dist/commonjs/Inputs/XRGamepadController.js +124 -124
- package/dist/commonjs/PeerConnectionController/AggregatedStats.js +252 -252
- package/dist/commonjs/PeerConnectionController/CandidatePairStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/CandidateStat.js +10 -10
- package/dist/commonjs/PeerConnectionController/CodecStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/DataChannelStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/InboundRTPStats.js +22 -22
- package/dist/commonjs/PeerConnectionController/InboundTrackStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/OutBoundRTPStats.js +16 -16
- package/dist/commonjs/PeerConnectionController/PeerConnectionController.js +584 -584
- package/dist/commonjs/PeerConnectionController/SessionStats.js +10 -10
- package/dist/commonjs/PeerConnectionController/StreamStats.js +10 -10
- package/dist/commonjs/PixelStreaming/PixelStreaming.js +607 -607
- package/dist/commonjs/UI/OnScreenKeyboard.js +82 -82
- package/dist/commonjs/UeInstanceMessage/ResponseController.js +38 -38
- package/dist/commonjs/UeInstanceMessage/SendMessageController.js +120 -120
- package/dist/commonjs/UeInstanceMessage/StreamMessageController.js +210 -210
- package/dist/commonjs/UeInstanceMessage/ToStreamerMessagesController.js +49 -49
- package/dist/commonjs/Util/EventEmitter.js +386 -386
- package/dist/commonjs/Util/FileUtil.js +108 -108
- package/dist/commonjs/Util/IURLSearchParams.js +25 -25
- package/dist/commonjs/Util/InputCoordTranslator.js +49 -49
- package/dist/commonjs/Util/RTCUtils.js +40 -40
- package/dist/commonjs/VideoPlayer/StreamController.js +67 -67
- package/dist/commonjs/VideoPlayer/VideoPlayer.js +177 -177
- package/dist/commonjs/WebRtcPlayer/WebRtcPlayerController.js +1221 -1221
- package/dist/commonjs/WebXR/WebXRController.js +335 -335
- package/dist/commonjs/pixelstreamingfrontend.js +70 -70
- package/dist/esm/AFK/AFKController.js +105 -105
- package/dist/esm/Config/Config.js +551 -551
- package/dist/esm/Config/SettingBase.js +94 -94
- package/dist/esm/Config/SettingFlag.js +45 -45
- package/dist/esm/Config/SettingNumber.js +79 -79
- package/dist/esm/Config/SettingOption.js +80 -80
- package/dist/esm/Config/SettingText.js +38 -38
- package/dist/esm/DataChannel/DataChannelController.js +102 -102
- package/dist/esm/DataChannel/DataChannelLatencyTestController.js +90 -90
- package/dist/esm/DataChannel/DataChannelLatencyTestResults.js +14 -14
- package/dist/esm/DataChannel/DataChannelSender.js +39 -39
- package/dist/esm/DataChannel/InitialSettings.js +34 -34
- package/dist/esm/DataChannel/LatencyTestResults.js +56 -56
- package/dist/esm/FreezeFrame/FreezeFrame.js +89 -89
- package/dist/esm/FreezeFrame/FreezeFrameController.js +91 -91
- package/dist/esm/Inputs/GamepadController.js +184 -184
- package/dist/esm/Inputs/GamepadTypes.js +17 -17
- package/dist/esm/Inputs/IInputController.js +1 -1
- package/dist/esm/Inputs/InputClassesFactory.js +91 -91
- package/dist/esm/Inputs/KeyCodes.js +109 -109
- package/dist/esm/Inputs/KeyboardController.js +133 -133
- package/dist/esm/Inputs/MouseButtons.js +23 -23
- package/dist/esm/Inputs/MouseController.js +93 -93
- package/dist/esm/Inputs/MouseControllerHovering.js +89 -89
- package/dist/esm/Inputs/MouseControllerLocked.js +149 -149
- package/dist/esm/Inputs/SpecialKeyCodes.js +15 -15
- package/dist/esm/Inputs/TouchController.js +119 -119
- package/dist/esm/Inputs/TouchControllerFake.js +87 -87
- package/dist/esm/Inputs/XRGamepadController.js +120 -120
- package/dist/esm/PeerConnectionController/AggregatedStats.js +248 -248
- package/dist/esm/PeerConnectionController/CandidatePairStats.js +6 -6
- package/dist/esm/PeerConnectionController/CandidateStat.js +6 -6
- package/dist/esm/PeerConnectionController/CodecStats.js +6 -6
- package/dist/esm/PeerConnectionController/DataChannelStats.js +6 -6
- package/dist/esm/PeerConnectionController/InboundRTPStats.js +16 -16
- package/dist/esm/PeerConnectionController/InboundTrackStats.js +6 -6
- package/dist/esm/PeerConnectionController/OutBoundRTPStats.js +11 -11
- package/dist/esm/PeerConnectionController/PeerConnectionController.js +580 -580
- package/dist/esm/PeerConnectionController/SessionStats.js +6 -6
- package/dist/esm/PeerConnectionController/StreamStats.js +6 -6
- package/dist/esm/PixelStreaming/PixelStreaming.js +603 -603
- package/dist/esm/UI/OnScreenKeyboard.js +78 -78
- package/dist/esm/UeInstanceMessage/ResponseController.js +34 -34
- package/dist/esm/UeInstanceMessage/SendMessageController.js +116 -116
- package/dist/esm/UeInstanceMessage/StreamMessageController.js +205 -205
- package/dist/esm/UeInstanceMessage/ToStreamerMessagesController.js +45 -45
- package/dist/esm/Util/EventEmitter.js +345 -345
- package/dist/esm/Util/FileUtil.js +103 -103
- package/dist/esm/Util/IURLSearchParams.js +21 -21
- package/dist/esm/Util/InputCoordTranslator.js +45 -45
- package/dist/esm/Util/RTCUtils.js +36 -36
- package/dist/esm/VideoPlayer/StreamController.js +63 -63
- package/dist/esm/VideoPlayer/VideoPlayer.js +173 -173
- package/dist/esm/WebRtcPlayer/WebRtcPlayerController.js +1217 -1217
- package/dist/esm/WebXR/WebXRController.js +331 -331
- package/dist/esm/pixelstreamingfrontend.js +24 -24
- package/dist/types/AFK/AFKController.d.ts +38 -38
- package/dist/types/Config/Config.d.ts +220 -220
- package/dist/types/Config/SettingBase.d.ts +43 -43
- package/dist/types/Config/SettingFlag.d.ts +24 -24
- package/dist/types/Config/SettingNumber.d.ts +41 -41
- package/dist/types/Config/SettingOption.d.ts +41 -41
- package/dist/types/Config/SettingText.d.ts +21 -21
- package/dist/types/DataChannel/DataChannelController.d.ts +59 -59
- package/dist/types/DataChannel/DataChannelLatencyTestController.d.ts +25 -25
- package/dist/types/DataChannel/DataChannelLatencyTestResults.d.ts +46 -46
- package/dist/types/DataChannel/DataChannelSender.d.ts +21 -21
- package/dist/types/DataChannel/InitialSettings.d.ts +44 -44
- package/dist/types/DataChannel/LatencyTestResults.d.ts +31 -31
- package/dist/types/FreezeFrame/FreezeFrame.d.ts +36 -36
- package/dist/types/FreezeFrame/FreezeFrameController.d.ts +37 -37
- package/dist/types/Inputs/GamepadController.d.ts +61 -61
- package/dist/types/Inputs/GamepadTypes.d.ts +15 -15
- package/dist/types/Inputs/IInputController.d.ts +16 -16
- package/dist/types/Inputs/InputClassesFactory.d.ts +53 -53
- package/dist/types/Inputs/KeyCodes.d.ts +5 -5
- package/dist/types/Inputs/KeyboardController.d.ts +34 -34
- package/dist/types/Inputs/MouseButtons.d.ts +22 -22
- package/dist/types/Inputs/MouseController.d.ts +40 -40
- package/dist/types/Inputs/MouseControllerHovering.d.ts +26 -26
- package/dist/types/Inputs/MouseControllerLocked.d.ts +31 -31
- package/dist/types/Inputs/SpecialKeyCodes.d.ts +14 -14
- package/dist/types/Inputs/TouchController.d.ts +28 -28
- package/dist/types/Inputs/TouchControllerFake.d.ts +29 -29
- package/dist/types/Inputs/XRGamepadController.d.ts +15 -15
- package/dist/types/PeerConnectionController/AggregatedStats.d.ts +82 -82
- package/dist/types/PeerConnectionController/CandidatePairStats.d.ts +22 -22
- package/dist/types/PeerConnectionController/CandidateStat.d.ts +13 -13
- package/dist/types/PeerConnectionController/CodecStats.d.ts +14 -14
- package/dist/types/PeerConnectionController/DataChannelStats.d.ts +15 -15
- package/dist/types/PeerConnectionController/InboundRTPStats.d.ts +141 -141
- package/dist/types/PeerConnectionController/InboundTrackStats.d.ts +32 -32
- package/dist/types/PeerConnectionController/OutBoundRTPStats.d.ts +23 -23
- package/dist/types/PeerConnectionController/PeerConnectionController.d.ts +143 -143
- package/dist/types/PeerConnectionController/SessionStats.d.ts +8 -8
- package/dist/types/PeerConnectionController/StreamStats.d.ts +9 -9
- package/dist/types/PixelStreaming/PixelStreaming.d.ts +271 -271
- package/dist/types/UI/OnScreenKeyboard.d.ts +30 -30
- package/dist/types/UeInstanceMessage/ResponseController.d.ts +19 -19
- package/dist/types/UeInstanceMessage/SendMessageController.d.ts +18 -18
- package/dist/types/UeInstanceMessage/StreamMessageController.d.ts +29 -29
- package/dist/types/UeInstanceMessage/ToStreamerMessagesController.d.ts +32 -32
- package/dist/types/Util/EventEmitter.d.ts +429 -429
- package/dist/types/Util/FileUtil.d.ts +32 -32
- package/dist/types/Util/IURLSearchParams.d.ts +9 -9
- package/dist/types/Util/InputCoordTranslator.d.ts +29 -29
- package/dist/types/Util/RTCUtils.d.ts +8 -8
- package/dist/types/VideoPlayer/StreamController.d.ts +22 -22
- package/dist/types/VideoPlayer/VideoPlayer.d.ts +78 -78
- package/dist/types/WebRtcPlayer/WebRtcPlayerController.d.ts +379 -379
- package/dist/types/WebXR/WebXRController.d.ts +42 -42
- package/dist/types/pixelstreamingfrontend.d.ts +23 -23
- package/package.json +45 -45
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
2
|
-
import { MouseController } from './MouseController';
|
|
3
|
-
/**
|
|
4
|
-
* A mouse controller that locks the mouse to the video document and prevents it from leaving the window
|
|
5
|
-
*/
|
|
6
|
-
export class MouseControllerLocked extends MouseController {
|
|
7
|
-
constructor(streamMessageController, videoPlayer, coordinateConverter, activeKeys) {
|
|
8
|
-
super(streamMessageController, videoPlayer, coordinateConverter, activeKeys);
|
|
9
|
-
this.videoElementParent = videoPlayer.getVideoParentElement();
|
|
10
|
-
this.x = this.videoElementParent.getBoundingClientRect().width / 2;
|
|
11
|
-
this.y = this.videoElementParent.getBoundingClientRect().height / 2;
|
|
12
|
-
this.normalizedCoord = this.coordinateConverter.translateUnsigned(this.x, this.y);
|
|
13
|
-
this.onRequestLockListener = this.onRequestLock.bind(this);
|
|
14
|
-
this.onLockStateChangeListener = this.onLockStateChange.bind(this);
|
|
15
|
-
this.onMouseUpListener = this.onMouseUp.bind(this);
|
|
16
|
-
this.onMouseDownListener = this.onMouseDown.bind(this);
|
|
17
|
-
this.onMouseDblClickListener = this.onMouseDblClick.bind(this);
|
|
18
|
-
this.onMouseWheelListener = this.onMouseWheel.bind(this);
|
|
19
|
-
this.onMouseMoveListener = this.onMouseMove.bind(this);
|
|
20
|
-
}
|
|
21
|
-
register() {
|
|
22
|
-
super.register();
|
|
23
|
-
this.videoElementParent.requestPointerLock =
|
|
24
|
-
this.videoElementParent.requestPointerLock || this.videoElementParent.mozRequestPointerLock;
|
|
25
|
-
document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock;
|
|
26
|
-
if (this.videoElementParent.requestPointerLock) {
|
|
27
|
-
this.videoElementParent.addEventListener('click', this.onRequestLockListener);
|
|
28
|
-
}
|
|
29
|
-
document.addEventListener('pointerlockchange', this.onLockStateChangeListener);
|
|
30
|
-
document.addEventListener('mozpointerlockchange', this.onLockStateChangeListener);
|
|
31
|
-
this.videoElementParent.addEventListener('mousedown', this.onMouseDownListener);
|
|
32
|
-
this.videoElementParent.addEventListener('mouseup', this.onMouseUpListener);
|
|
33
|
-
this.videoElementParent.addEventListener('wheel', this.onMouseWheelListener);
|
|
34
|
-
this.videoElementParent.addEventListener('dblclick', this.onMouseDblClickListener);
|
|
35
|
-
}
|
|
36
|
-
unregister() {
|
|
37
|
-
const pointerLockElement = document.pointerLockElement || document.mozPointerLockElement;
|
|
38
|
-
if (document.exitPointerLock && pointerLockElement === this.videoElementParent) {
|
|
39
|
-
document.exitPointerLock();
|
|
40
|
-
}
|
|
41
|
-
this.videoElementParent.removeEventListener('click', this.onRequestLockListener);
|
|
42
|
-
document.removeEventListener('pointerlockchange', this.onLockStateChangeListener);
|
|
43
|
-
document.removeEventListener('mozpointerlockchange', this.onLockStateChangeListener);
|
|
44
|
-
document.removeEventListener('mousemove', this.onMouseMoveListener);
|
|
45
|
-
this.videoElementParent.removeEventListener('mousedown', this.onMouseDownListener);
|
|
46
|
-
this.videoElementParent.removeEventListener('mouseup', this.onMouseUpListener);
|
|
47
|
-
this.videoElementParent.removeEventListener('wheel', this.onMouseWheelListener);
|
|
48
|
-
this.videoElementParent.removeEventListener('dblclick', this.onMouseDblClickListener);
|
|
49
|
-
super.unregister();
|
|
50
|
-
}
|
|
51
|
-
onRequestLock() {
|
|
52
|
-
this.videoElementParent.requestPointerLock();
|
|
53
|
-
}
|
|
54
|
-
onLockStateChange() {
|
|
55
|
-
const pointerLockElement = document.pointerLockElement || document.mozPointerLockElement;
|
|
56
|
-
if (pointerLockElement === this.videoElementParent) {
|
|
57
|
-
Logger.Info('Pointer locked');
|
|
58
|
-
document.addEventListener('mousemove', this.onMouseMoveListener);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
Logger.Info('The pointer lock status is now unlocked');
|
|
62
|
-
document.removeEventListener('mousemove', this.onMouseMoveListener);
|
|
63
|
-
// If mouse loses focus, send a key up for all of the currently held-down keys
|
|
64
|
-
// This is necessary as when the mouse loses focus, the windows stops listening for events and as such
|
|
65
|
-
// the keyup listener won't get fired
|
|
66
|
-
const activeKeys = this.activeKeys.getActiveKeys();
|
|
67
|
-
activeKeys.forEach((key) => {
|
|
68
|
-
this.streamMessageController.toStreamerHandlers.get('KeyUp')([key]);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
onMouseDown(event) {
|
|
73
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
this.streamMessageController.toStreamerHandlers.get('MouseDown')([
|
|
77
|
-
event.button,
|
|
78
|
-
// We use the store value of this.coord as opposed to the mouseEvent.x/y as the mouseEvent location
|
|
79
|
-
// uses the system cursor location which hasn't moved
|
|
80
|
-
this.normalizedCoord.x,
|
|
81
|
-
this.normalizedCoord.y
|
|
82
|
-
]);
|
|
83
|
-
}
|
|
84
|
-
onMouseUp(event) {
|
|
85
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
this.streamMessageController.toStreamerHandlers.get('MouseUp')([
|
|
89
|
-
event.button,
|
|
90
|
-
// We use the store value of this.coord as opposed to the mouseEvent.x/y as the mouseEvent location
|
|
91
|
-
// uses the system cursor location which hasn't moved
|
|
92
|
-
this.normalizedCoord.x,
|
|
93
|
-
this.normalizedCoord.y
|
|
94
|
-
]);
|
|
95
|
-
}
|
|
96
|
-
onMouseMove(event) {
|
|
97
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const styleWidth = this.videoPlayer.getVideoParentElement().clientWidth;
|
|
101
|
-
const styleHeight = this.videoPlayer.getVideoParentElement().clientHeight;
|
|
102
|
-
this.x += event.movementX;
|
|
103
|
-
this.y += event.movementY;
|
|
104
|
-
while (this.x > styleWidth) {
|
|
105
|
-
this.x -= styleWidth;
|
|
106
|
-
}
|
|
107
|
-
while (this.y > styleHeight) {
|
|
108
|
-
this.y -= styleHeight;
|
|
109
|
-
}
|
|
110
|
-
while (this.x < 0) {
|
|
111
|
-
this.x += styleWidth;
|
|
112
|
-
}
|
|
113
|
-
while (this.y < 0) {
|
|
114
|
-
this.y += styleHeight;
|
|
115
|
-
}
|
|
116
|
-
this.normalizedCoord = this.coordinateConverter.translateUnsigned(this.x, this.y);
|
|
117
|
-
const delta = this.coordinateConverter.translateSigned(event.movementX, event.movementY);
|
|
118
|
-
this.streamMessageController.toStreamerHandlers.get('MouseMove')([
|
|
119
|
-
this.normalizedCoord.x,
|
|
120
|
-
this.normalizedCoord.y,
|
|
121
|
-
delta.x,
|
|
122
|
-
delta.y
|
|
123
|
-
]);
|
|
124
|
-
}
|
|
125
|
-
onMouseWheel(event) {
|
|
126
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
this.streamMessageController.toStreamerHandlers.get('MouseWheel')([
|
|
130
|
-
event.wheelDelta,
|
|
131
|
-
// We use the store value of this.coord as opposed to the mouseEvent.x/y as the mouseEvent location
|
|
132
|
-
// uses the system cursor location which hasn't moved
|
|
133
|
-
this.normalizedCoord.x,
|
|
134
|
-
this.normalizedCoord.y
|
|
135
|
-
]);
|
|
136
|
-
}
|
|
137
|
-
onMouseDblClick(event) {
|
|
138
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
this.streamMessageController.toStreamerHandlers.get('MouseDouble')([
|
|
142
|
-
event.button,
|
|
143
|
-
// We use the store value of this.coord as opposed to the mouseEvent.x/y as the mouseEvent location
|
|
144
|
-
// uses the system cursor location which hasn't moved
|
|
145
|
-
this.normalizedCoord.x,
|
|
146
|
-
this.normalizedCoord.y
|
|
147
|
-
]);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
1
|
+
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
2
|
+
import { MouseController } from './MouseController';
|
|
3
|
+
/**
|
|
4
|
+
* A mouse controller that locks the mouse to the video document and prevents it from leaving the window
|
|
5
|
+
*/
|
|
6
|
+
export class MouseControllerLocked extends MouseController {
|
|
7
|
+
constructor(streamMessageController, videoPlayer, coordinateConverter, activeKeys) {
|
|
8
|
+
super(streamMessageController, videoPlayer, coordinateConverter, activeKeys);
|
|
9
|
+
this.videoElementParent = videoPlayer.getVideoParentElement();
|
|
10
|
+
this.x = this.videoElementParent.getBoundingClientRect().width / 2;
|
|
11
|
+
this.y = this.videoElementParent.getBoundingClientRect().height / 2;
|
|
12
|
+
this.normalizedCoord = this.coordinateConverter.translateUnsigned(this.x, this.y);
|
|
13
|
+
this.onRequestLockListener = this.onRequestLock.bind(this);
|
|
14
|
+
this.onLockStateChangeListener = this.onLockStateChange.bind(this);
|
|
15
|
+
this.onMouseUpListener = this.onMouseUp.bind(this);
|
|
16
|
+
this.onMouseDownListener = this.onMouseDown.bind(this);
|
|
17
|
+
this.onMouseDblClickListener = this.onMouseDblClick.bind(this);
|
|
18
|
+
this.onMouseWheelListener = this.onMouseWheel.bind(this);
|
|
19
|
+
this.onMouseMoveListener = this.onMouseMove.bind(this);
|
|
20
|
+
}
|
|
21
|
+
register() {
|
|
22
|
+
super.register();
|
|
23
|
+
this.videoElementParent.requestPointerLock =
|
|
24
|
+
this.videoElementParent.requestPointerLock || this.videoElementParent.mozRequestPointerLock;
|
|
25
|
+
document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock;
|
|
26
|
+
if (this.videoElementParent.requestPointerLock) {
|
|
27
|
+
this.videoElementParent.addEventListener('click', this.onRequestLockListener);
|
|
28
|
+
}
|
|
29
|
+
document.addEventListener('pointerlockchange', this.onLockStateChangeListener);
|
|
30
|
+
document.addEventListener('mozpointerlockchange', this.onLockStateChangeListener);
|
|
31
|
+
this.videoElementParent.addEventListener('mousedown', this.onMouseDownListener);
|
|
32
|
+
this.videoElementParent.addEventListener('mouseup', this.onMouseUpListener);
|
|
33
|
+
this.videoElementParent.addEventListener('wheel', this.onMouseWheelListener);
|
|
34
|
+
this.videoElementParent.addEventListener('dblclick', this.onMouseDblClickListener);
|
|
35
|
+
}
|
|
36
|
+
unregister() {
|
|
37
|
+
const pointerLockElement = document.pointerLockElement || document.mozPointerLockElement;
|
|
38
|
+
if (document.exitPointerLock && pointerLockElement === this.videoElementParent) {
|
|
39
|
+
document.exitPointerLock();
|
|
40
|
+
}
|
|
41
|
+
this.videoElementParent.removeEventListener('click', this.onRequestLockListener);
|
|
42
|
+
document.removeEventListener('pointerlockchange', this.onLockStateChangeListener);
|
|
43
|
+
document.removeEventListener('mozpointerlockchange', this.onLockStateChangeListener);
|
|
44
|
+
document.removeEventListener('mousemove', this.onMouseMoveListener);
|
|
45
|
+
this.videoElementParent.removeEventListener('mousedown', this.onMouseDownListener);
|
|
46
|
+
this.videoElementParent.removeEventListener('mouseup', this.onMouseUpListener);
|
|
47
|
+
this.videoElementParent.removeEventListener('wheel', this.onMouseWheelListener);
|
|
48
|
+
this.videoElementParent.removeEventListener('dblclick', this.onMouseDblClickListener);
|
|
49
|
+
super.unregister();
|
|
50
|
+
}
|
|
51
|
+
onRequestLock() {
|
|
52
|
+
this.videoElementParent.requestPointerLock();
|
|
53
|
+
}
|
|
54
|
+
onLockStateChange() {
|
|
55
|
+
const pointerLockElement = document.pointerLockElement || document.mozPointerLockElement;
|
|
56
|
+
if (pointerLockElement === this.videoElementParent) {
|
|
57
|
+
Logger.Info('Pointer locked');
|
|
58
|
+
document.addEventListener('mousemove', this.onMouseMoveListener);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
Logger.Info('The pointer lock status is now unlocked');
|
|
62
|
+
document.removeEventListener('mousemove', this.onMouseMoveListener);
|
|
63
|
+
// If mouse loses focus, send a key up for all of the currently held-down keys
|
|
64
|
+
// This is necessary as when the mouse loses focus, the windows stops listening for events and as such
|
|
65
|
+
// the keyup listener won't get fired
|
|
66
|
+
const activeKeys = this.activeKeys.getActiveKeys();
|
|
67
|
+
activeKeys.forEach((key) => {
|
|
68
|
+
this.streamMessageController.toStreamerHandlers.get('KeyUp')([key]);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
onMouseDown(event) {
|
|
73
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
this.streamMessageController.toStreamerHandlers.get('MouseDown')([
|
|
77
|
+
event.button,
|
|
78
|
+
// We use the store value of this.coord as opposed to the mouseEvent.x/y as the mouseEvent location
|
|
79
|
+
// uses the system cursor location which hasn't moved
|
|
80
|
+
this.normalizedCoord.x,
|
|
81
|
+
this.normalizedCoord.y
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
onMouseUp(event) {
|
|
85
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this.streamMessageController.toStreamerHandlers.get('MouseUp')([
|
|
89
|
+
event.button,
|
|
90
|
+
// We use the store value of this.coord as opposed to the mouseEvent.x/y as the mouseEvent location
|
|
91
|
+
// uses the system cursor location which hasn't moved
|
|
92
|
+
this.normalizedCoord.x,
|
|
93
|
+
this.normalizedCoord.y
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
onMouseMove(event) {
|
|
97
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const styleWidth = this.videoPlayer.getVideoParentElement().clientWidth;
|
|
101
|
+
const styleHeight = this.videoPlayer.getVideoParentElement().clientHeight;
|
|
102
|
+
this.x += event.movementX;
|
|
103
|
+
this.y += event.movementY;
|
|
104
|
+
while (this.x > styleWidth) {
|
|
105
|
+
this.x -= styleWidth;
|
|
106
|
+
}
|
|
107
|
+
while (this.y > styleHeight) {
|
|
108
|
+
this.y -= styleHeight;
|
|
109
|
+
}
|
|
110
|
+
while (this.x < 0) {
|
|
111
|
+
this.x += styleWidth;
|
|
112
|
+
}
|
|
113
|
+
while (this.y < 0) {
|
|
114
|
+
this.y += styleHeight;
|
|
115
|
+
}
|
|
116
|
+
this.normalizedCoord = this.coordinateConverter.translateUnsigned(this.x, this.y);
|
|
117
|
+
const delta = this.coordinateConverter.translateSigned(event.movementX, event.movementY);
|
|
118
|
+
this.streamMessageController.toStreamerHandlers.get('MouseMove')([
|
|
119
|
+
this.normalizedCoord.x,
|
|
120
|
+
this.normalizedCoord.y,
|
|
121
|
+
delta.x,
|
|
122
|
+
delta.y
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
onMouseWheel(event) {
|
|
126
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
this.streamMessageController.toStreamerHandlers.get('MouseWheel')([
|
|
130
|
+
event.wheelDelta,
|
|
131
|
+
// We use the store value of this.coord as opposed to the mouseEvent.x/y as the mouseEvent location
|
|
132
|
+
// uses the system cursor location which hasn't moved
|
|
133
|
+
this.normalizedCoord.x,
|
|
134
|
+
this.normalizedCoord.y
|
|
135
|
+
]);
|
|
136
|
+
}
|
|
137
|
+
onMouseDblClick(event) {
|
|
138
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.streamMessageController.toStreamerHandlers.get('MouseDouble')([
|
|
142
|
+
event.button,
|
|
143
|
+
// We use the store value of this.coord as opposed to the mouseEvent.x/y as the mouseEvent location
|
|
144
|
+
// uses the system cursor location which hasn't moved
|
|
145
|
+
this.normalizedCoord.x,
|
|
146
|
+
this.normalizedCoord.y
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
150
|
//# sourceMappingURL=MouseControllerLocked.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
/**
|
|
3
|
-
* Registers the Special Key codes
|
|
4
|
-
* Must be kept in sync with JavaScriptKeyCodeToFKey C++ array.
|
|
5
|
-
* The index of the entry in the array is the special key code given below.
|
|
6
|
-
*/
|
|
7
|
-
export class SpecialKeyCodes {
|
|
8
|
-
}
|
|
9
|
-
SpecialKeyCodes.backSpace = 8;
|
|
10
|
-
SpecialKeyCodes.shift = 16;
|
|
11
|
-
SpecialKeyCodes.control = 17;
|
|
12
|
-
SpecialKeyCodes.alt = 18;
|
|
13
|
-
SpecialKeyCodes.rightShift = 253;
|
|
14
|
-
SpecialKeyCodes.rightControl = 254;
|
|
15
|
-
SpecialKeyCodes.rightAlt = 255;
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
/**
|
|
3
|
+
* Registers the Special Key codes
|
|
4
|
+
* Must be kept in sync with JavaScriptKeyCodeToFKey C++ array.
|
|
5
|
+
* The index of the entry in the array is the special key code given below.
|
|
6
|
+
*/
|
|
7
|
+
export class SpecialKeyCodes {
|
|
8
|
+
}
|
|
9
|
+
SpecialKeyCodes.backSpace = 8;
|
|
10
|
+
SpecialKeyCodes.shift = 16;
|
|
11
|
+
SpecialKeyCodes.control = 17;
|
|
12
|
+
SpecialKeyCodes.alt = 18;
|
|
13
|
+
SpecialKeyCodes.rightShift = 253;
|
|
14
|
+
SpecialKeyCodes.rightControl = 254;
|
|
15
|
+
SpecialKeyCodes.rightAlt = 255;
|
|
16
16
|
//# sourceMappingURL=SpecialKeyCodes.js.map
|
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
-
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
-
/**
|
|
4
|
-
* The basic touch controller that handles the touch events on the document.
|
|
5
|
-
*/
|
|
6
|
-
export class TouchController {
|
|
7
|
-
constructor(streamMessageController, videoPlayer, coordinateConverter) {
|
|
8
|
-
this.fingers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
|
|
9
|
-
this.fingerIds = new Map();
|
|
10
|
-
this.maxByteValue = 255;
|
|
11
|
-
this.streamMessageController = streamMessageController;
|
|
12
|
-
this.videoPlayer = videoPlayer;
|
|
13
|
-
this.coordinateConverter = coordinateConverter;
|
|
14
|
-
this.videoElementParent = videoPlayer.getVideoElement();
|
|
15
|
-
this.onTouchStartListener = this.onTouchStart.bind(this);
|
|
16
|
-
this.onTouchEndListener = this.onTouchEnd.bind(this);
|
|
17
|
-
this.onTouchMoveListener = this.onTouchMove.bind(this);
|
|
18
|
-
}
|
|
19
|
-
register() {
|
|
20
|
-
this.videoElementParent.addEventListener('touchstart', this.onTouchStartListener);
|
|
21
|
-
this.videoElementParent.addEventListener('touchend', this.onTouchEndListener);
|
|
22
|
-
this.videoElementParent.addEventListener('touchmove', this.onTouchMoveListener);
|
|
23
|
-
}
|
|
24
|
-
unregister() {
|
|
25
|
-
this.videoElementParent.addEventListener('touchstart', this.onTouchStartListener);
|
|
26
|
-
this.videoElementParent.addEventListener('touchend', this.onTouchEndListener);
|
|
27
|
-
this.videoElementParent.addEventListener('touchmove', this.onTouchMoveListener);
|
|
28
|
-
}
|
|
29
|
-
rememberTouch(touch) {
|
|
30
|
-
const finger = this.fingers.pop();
|
|
31
|
-
if (finger === undefined) {
|
|
32
|
-
Logger.Info('exhausted touch identifiers');
|
|
33
|
-
}
|
|
34
|
-
this.fingerIds.set(touch.identifier, finger);
|
|
35
|
-
}
|
|
36
|
-
forgetTouch(touch) {
|
|
37
|
-
this.fingers.push(this.fingerIds.get(touch.identifier));
|
|
38
|
-
// Sort array back into descending order. This means if finger '1' were to lift after finger '0', we would ensure that 0 will be the first index to pop
|
|
39
|
-
this.fingers.sort(function (a, b) {
|
|
40
|
-
return b - a;
|
|
41
|
-
});
|
|
42
|
-
this.fingerIds.delete(touch.identifier);
|
|
43
|
-
}
|
|
44
|
-
onTouchStart(touchEvent) {
|
|
45
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
for (let t = 0; t < touchEvent.changedTouches.length; t++) {
|
|
49
|
-
this.rememberTouch(touchEvent.changedTouches[t]);
|
|
50
|
-
}
|
|
51
|
-
this.emitTouchData('TouchStart', touchEvent.changedTouches);
|
|
52
|
-
touchEvent.preventDefault();
|
|
53
|
-
}
|
|
54
|
-
onTouchEnd(touchEvent) {
|
|
55
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
this.emitTouchData('TouchEnd', touchEvent.changedTouches);
|
|
59
|
-
// Re-cycle unique identifiers previously assigned to each touch.
|
|
60
|
-
for (let t = 0; t < touchEvent.changedTouches.length; t++) {
|
|
61
|
-
this.forgetTouch(touchEvent.changedTouches[t]);
|
|
62
|
-
}
|
|
63
|
-
touchEvent.preventDefault();
|
|
64
|
-
}
|
|
65
|
-
onTouchMove(touchEvent) {
|
|
66
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
this.emitTouchData('TouchMove', touchEvent.touches);
|
|
70
|
-
touchEvent.preventDefault();
|
|
71
|
-
}
|
|
72
|
-
emitTouchData(type, touches) {
|
|
73
|
-
if (!this.videoPlayer.isVideoReady()) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const offset = this.videoPlayer.getVideoParentElement().getBoundingClientRect();
|
|
77
|
-
const toStreamerHandlers = this.streamMessageController.toStreamerHandlers;
|
|
78
|
-
for (let t = 0; t < touches.length; t++) {
|
|
79
|
-
const numTouches = 1; // the number of touches to be sent this message
|
|
80
|
-
const touch = touches[t];
|
|
81
|
-
const x = touch.clientX - offset.left;
|
|
82
|
-
const y = touch.clientY - offset.top;
|
|
83
|
-
Logger.Info(`F${this.fingerIds.get(touch.identifier)}=(${x}, ${y})`);
|
|
84
|
-
const coord = this.coordinateConverter.translateUnsigned(x, y);
|
|
85
|
-
switch (type) {
|
|
86
|
-
case 'TouchStart':
|
|
87
|
-
toStreamerHandlers.get('TouchStart')([
|
|
88
|
-
numTouches,
|
|
89
|
-
coord.x,
|
|
90
|
-
coord.y,
|
|
91
|
-
this.fingerIds.get(touch.identifier),
|
|
92
|
-
this.maxByteValue * (touch.force > 0 ? touch.force : 1),
|
|
93
|
-
coord.inRange ? 1 : 0
|
|
94
|
-
]);
|
|
95
|
-
break;
|
|
96
|
-
case 'TouchEnd':
|
|
97
|
-
toStreamerHandlers.get('TouchEnd')([
|
|
98
|
-
numTouches,
|
|
99
|
-
coord.x,
|
|
100
|
-
coord.y,
|
|
101
|
-
this.fingerIds.get(touch.identifier),
|
|
102
|
-
this.maxByteValue * touch.force,
|
|
103
|
-
coord.inRange ? 1 : 0
|
|
104
|
-
]);
|
|
105
|
-
break;
|
|
106
|
-
case 'TouchMove':
|
|
107
|
-
toStreamerHandlers.get('TouchMove')([
|
|
108
|
-
numTouches,
|
|
109
|
-
coord.x,
|
|
110
|
-
coord.y,
|
|
111
|
-
this.fingerIds.get(touch.identifier),
|
|
112
|
-
this.maxByteValue * (touch.force > 0 ? touch.force : 1),
|
|
113
|
-
coord.inRange ? 1 : 0
|
|
114
|
-
]);
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
import { Logger } from '@epicgames-ps/lib-pixelstreamingcommon-ue5.5';
|
|
3
|
+
/**
|
|
4
|
+
* The basic touch controller that handles the touch events on the document.
|
|
5
|
+
*/
|
|
6
|
+
export class TouchController {
|
|
7
|
+
constructor(streamMessageController, videoPlayer, coordinateConverter) {
|
|
8
|
+
this.fingers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
|
|
9
|
+
this.fingerIds = new Map();
|
|
10
|
+
this.maxByteValue = 255;
|
|
11
|
+
this.streamMessageController = streamMessageController;
|
|
12
|
+
this.videoPlayer = videoPlayer;
|
|
13
|
+
this.coordinateConverter = coordinateConverter;
|
|
14
|
+
this.videoElementParent = videoPlayer.getVideoElement();
|
|
15
|
+
this.onTouchStartListener = this.onTouchStart.bind(this);
|
|
16
|
+
this.onTouchEndListener = this.onTouchEnd.bind(this);
|
|
17
|
+
this.onTouchMoveListener = this.onTouchMove.bind(this);
|
|
18
|
+
}
|
|
19
|
+
register() {
|
|
20
|
+
this.videoElementParent.addEventListener('touchstart', this.onTouchStartListener);
|
|
21
|
+
this.videoElementParent.addEventListener('touchend', this.onTouchEndListener);
|
|
22
|
+
this.videoElementParent.addEventListener('touchmove', this.onTouchMoveListener);
|
|
23
|
+
}
|
|
24
|
+
unregister() {
|
|
25
|
+
this.videoElementParent.addEventListener('touchstart', this.onTouchStartListener);
|
|
26
|
+
this.videoElementParent.addEventListener('touchend', this.onTouchEndListener);
|
|
27
|
+
this.videoElementParent.addEventListener('touchmove', this.onTouchMoveListener);
|
|
28
|
+
}
|
|
29
|
+
rememberTouch(touch) {
|
|
30
|
+
const finger = this.fingers.pop();
|
|
31
|
+
if (finger === undefined) {
|
|
32
|
+
Logger.Info('exhausted touch identifiers');
|
|
33
|
+
}
|
|
34
|
+
this.fingerIds.set(touch.identifier, finger);
|
|
35
|
+
}
|
|
36
|
+
forgetTouch(touch) {
|
|
37
|
+
this.fingers.push(this.fingerIds.get(touch.identifier));
|
|
38
|
+
// Sort array back into descending order. This means if finger '1' were to lift after finger '0', we would ensure that 0 will be the first index to pop
|
|
39
|
+
this.fingers.sort(function (a, b) {
|
|
40
|
+
return b - a;
|
|
41
|
+
});
|
|
42
|
+
this.fingerIds.delete(touch.identifier);
|
|
43
|
+
}
|
|
44
|
+
onTouchStart(touchEvent) {
|
|
45
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (let t = 0; t < touchEvent.changedTouches.length; t++) {
|
|
49
|
+
this.rememberTouch(touchEvent.changedTouches[t]);
|
|
50
|
+
}
|
|
51
|
+
this.emitTouchData('TouchStart', touchEvent.changedTouches);
|
|
52
|
+
touchEvent.preventDefault();
|
|
53
|
+
}
|
|
54
|
+
onTouchEnd(touchEvent) {
|
|
55
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.emitTouchData('TouchEnd', touchEvent.changedTouches);
|
|
59
|
+
// Re-cycle unique identifiers previously assigned to each touch.
|
|
60
|
+
for (let t = 0; t < touchEvent.changedTouches.length; t++) {
|
|
61
|
+
this.forgetTouch(touchEvent.changedTouches[t]);
|
|
62
|
+
}
|
|
63
|
+
touchEvent.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
onTouchMove(touchEvent) {
|
|
66
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.emitTouchData('TouchMove', touchEvent.touches);
|
|
70
|
+
touchEvent.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
emitTouchData(type, touches) {
|
|
73
|
+
if (!this.videoPlayer.isVideoReady()) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const offset = this.videoPlayer.getVideoParentElement().getBoundingClientRect();
|
|
77
|
+
const toStreamerHandlers = this.streamMessageController.toStreamerHandlers;
|
|
78
|
+
for (let t = 0; t < touches.length; t++) {
|
|
79
|
+
const numTouches = 1; // the number of touches to be sent this message
|
|
80
|
+
const touch = touches[t];
|
|
81
|
+
const x = touch.clientX - offset.left;
|
|
82
|
+
const y = touch.clientY - offset.top;
|
|
83
|
+
Logger.Info(`F${this.fingerIds.get(touch.identifier)}=(${x}, ${y})`);
|
|
84
|
+
const coord = this.coordinateConverter.translateUnsigned(x, y);
|
|
85
|
+
switch (type) {
|
|
86
|
+
case 'TouchStart':
|
|
87
|
+
toStreamerHandlers.get('TouchStart')([
|
|
88
|
+
numTouches,
|
|
89
|
+
coord.x,
|
|
90
|
+
coord.y,
|
|
91
|
+
this.fingerIds.get(touch.identifier),
|
|
92
|
+
this.maxByteValue * (touch.force > 0 ? touch.force : 1),
|
|
93
|
+
coord.inRange ? 1 : 0
|
|
94
|
+
]);
|
|
95
|
+
break;
|
|
96
|
+
case 'TouchEnd':
|
|
97
|
+
toStreamerHandlers.get('TouchEnd')([
|
|
98
|
+
numTouches,
|
|
99
|
+
coord.x,
|
|
100
|
+
coord.y,
|
|
101
|
+
this.fingerIds.get(touch.identifier),
|
|
102
|
+
this.maxByteValue * touch.force,
|
|
103
|
+
coord.inRange ? 1 : 0
|
|
104
|
+
]);
|
|
105
|
+
break;
|
|
106
|
+
case 'TouchMove':
|
|
107
|
+
toStreamerHandlers.get('TouchMove')([
|
|
108
|
+
numTouches,
|
|
109
|
+
coord.x,
|
|
110
|
+
coord.y,
|
|
111
|
+
this.fingerIds.get(touch.identifier),
|
|
112
|
+
this.maxByteValue * (touch.force > 0 ? touch.force : 1),
|
|
113
|
+
coord.inRange ? 1 : 0
|
|
114
|
+
]);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
120
|
//# sourceMappingURL=TouchController.js.map
|