@yang__yj/pixelstreaming-core 1.0.0 → 1.0.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/.cspell.json +48 -0
- package/.eslintignore +8 -0
- package/.eslintrc.js +8 -0
- package/.prettierignore +0 -0
- package/.prettierrc.json +6 -0
- package/coverage/clover.xml +3480 -0
- package/coverage/coverage-final.json +62 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +356 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/AFK/AFKController.ts.html +559 -0
- package/coverage/lcov-report/src/AFK/index.html +116 -0
- package/coverage/lcov-report/src/Config/Config.ts.html +2764 -0
- package/coverage/lcov-report/src/Config/SettingBase.ts.html +280 -0
- package/coverage/lcov-report/src/Config/SettingFlag.ts.html +382 -0
- package/coverage/lcov-report/src/Config/SettingNumber.ts.html +418 -0
- package/coverage/lcov-report/src/Config/SettingOption.ts.html +424 -0
- package/coverage/lcov-report/src/Config/SettingText.ts.html +331 -0
- package/coverage/lcov-report/src/Config/index.html +191 -0
- package/coverage/lcov-report/src/DataChannel/DataChannelController.ts.html +499 -0
- package/coverage/lcov-report/src/DataChannel/DataChannelSender.ts.html +262 -0
- package/coverage/lcov-report/src/DataChannel/InitialSettings.ts.html +268 -0
- package/coverage/lcov-report/src/DataChannel/LatencyTestResults.ts.html +313 -0
- package/coverage/lcov-report/src/DataChannel/index.html +161 -0
- package/coverage/lcov-report/src/FreezeFrame/FreezeFrame.ts.html +427 -0
- package/coverage/lcov-report/src/FreezeFrame/FreezeFrameController.ts.html +427 -0
- package/coverage/lcov-report/src/FreezeFrame/index.html +131 -0
- package/coverage/lcov-report/src/Inputs/FakeTouchController.ts.html +682 -0
- package/coverage/lcov-report/src/Inputs/GamepadController.ts.html +985 -0
- package/coverage/lcov-report/src/Inputs/HoveringMouseEvents.ts.html +688 -0
- package/coverage/lcov-report/src/Inputs/InputClassesFactory.ts.html +505 -0
- package/coverage/lcov-report/src/Inputs/KeyboardController.ts.html +1048 -0
- package/coverage/lcov-report/src/Inputs/LockedMouseEvents.ts.html +946 -0
- package/coverage/lcov-report/src/Inputs/MouseButtons.ts.html +160 -0
- package/coverage/lcov-report/src/Inputs/MouseController.ts.html +1171 -0
- package/coverage/lcov-report/src/Inputs/SpecialKeyCodes.ts.html +133 -0
- package/coverage/lcov-report/src/Inputs/TouchController.ts.html +712 -0
- package/coverage/lcov-report/src/Inputs/XRGamepadController.ts.html +463 -0
- package/coverage/lcov-report/src/Inputs/index.html +266 -0
- package/coverage/lcov-report/src/Logger/Logger.ts.html +325 -0
- package/coverage/lcov-report/src/Logger/index.html +116 -0
- package/coverage/lcov-report/src/PeerConnectionController/AggregatedStats.ts.html +1018 -0
- package/coverage/lcov-report/src/PeerConnectionController/CandidatePairStats.ts.html +136 -0
- package/coverage/lcov-report/src/PeerConnectionController/CandidateStat.ts.html +124 -0
- package/coverage/lcov-report/src/PeerConnectionController/DataChannelStats.ts.html +136 -0
- package/coverage/lcov-report/src/PeerConnectionController/InboundRTPStats.ts.html +547 -0
- package/coverage/lcov-report/src/PeerConnectionController/OutBoundRTPStats.ts.html +163 -0
- package/coverage/lcov-report/src/PeerConnectionController/PeerConnectionController.ts.html +1795 -0
- package/coverage/lcov-report/src/PeerConnectionController/SessionStats.ts.html +115 -0
- package/coverage/lcov-report/src/PeerConnectionController/StreamStats.ts.html +118 -0
- package/coverage/lcov-report/src/PeerConnectionController/index.html +236 -0
- package/coverage/lcov-report/src/PixelStreaming/PixelStreaming.ts.html +2269 -0
- package/coverage/lcov-report/src/PixelStreaming/index.html +116 -0
- package/coverage/lcov-report/src/UI/OnScreenKeyboard.ts.html +376 -0
- package/coverage/lcov-report/src/UI/index.html +116 -0
- package/coverage/lcov-report/src/UeInstanceMessage/ResponseController.ts.html +226 -0
- package/coverage/lcov-report/src/UeInstanceMessage/SendDescriptorController.ts.html +346 -0
- package/coverage/lcov-report/src/UeInstanceMessage/SendMessageController.ts.html +364 -0
- package/coverage/lcov-report/src/UeInstanceMessage/StreamMessageController.ts.html +862 -0
- package/coverage/lcov-report/src/UeInstanceMessage/ToStreamerMessagesController.ts.html +271 -0
- package/coverage/lcov-report/src/UeInstanceMessage/TwoWayMap.ts.html +241 -0
- package/coverage/lcov-report/src/UeInstanceMessage/index.html +191 -0
- package/coverage/lcov-report/src/Util/CoordinateConverter.ts.html +952 -0
- package/coverage/lcov-report/src/Util/EventEmitter.ts.html +1705 -0
- package/coverage/lcov-report/src/Util/EventListenerTracker.ts.html +172 -0
- package/coverage/lcov-report/src/Util/FileUtil.ts.html +505 -0
- package/coverage/lcov-report/src/Util/WebGLUtils.ts.html +232 -0
- package/coverage/lcov-report/src/Util/WebXRUtils.ts.html +160 -0
- package/coverage/lcov-report/src/Util/index.html +191 -0
- package/coverage/lcov-report/src/VideoPlayer/StreamController.ts.html +349 -0
- package/coverage/lcov-report/src/VideoPlayer/VideoPlayer.ts.html +799 -0
- package/coverage/lcov-report/src/VideoPlayer/index.html +131 -0
- package/coverage/lcov-report/src/WebRtcPlayer/WebRtcPlayerController.ts.html +6199 -0
- package/coverage/lcov-report/src/WebRtcPlayer/index.html +116 -0
- package/coverage/lcov-report/src/WebSockets/MessageReceive.ts.html +352 -0
- package/coverage/lcov-report/src/WebSockets/MessageSend.ts.html +604 -0
- package/coverage/lcov-report/src/WebSockets/SignallingProtocol.ts.html +622 -0
- package/coverage/lcov-report/src/WebSockets/WebSocketController.ts.html +844 -0
- package/coverage/lcov-report/src/WebSockets/index.html +161 -0
- package/coverage/lcov-report/src/WebXR/WebXRController.ts.html +1042 -0
- package/coverage/lcov-report/src/WebXR/index.html +116 -0
- package/coverage/lcov-report/src/__test__/index.html +161 -0
- package/coverage/lcov-report/src/__test__/mockMediaStream.ts.html +457 -0
- package/coverage/lcov-report/src/__test__/mockRTCPeerConnection.ts.html +1126 -0
- package/coverage/lcov-report/src/__test__/mockRTCRtpReceiver.ts.html +151 -0
- package/coverage/lcov-report/src/__test__/mockWebSocket.ts.html +475 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/pixelstreamingfrontend.ts.html +232 -0
- package/coverage/lcov.info +6458 -0
- package/jest.config.js +18 -0
- package/package.json +46 -18
- package/readme.md +15 -0
- package/src/AFK/AFKController.test.ts +162 -0
- package/src/AFK/AFKController.ts +158 -0
- package/src/Config/Config.test.ts +222 -0
- package/src/Config/Config.ts +909 -0
- package/src/Config/SettingBase.ts +65 -0
- package/src/Config/SettingFlag.ts +99 -0
- package/src/Config/SettingNumber.ts +111 -0
- package/src/Config/SettingOption.ts +124 -0
- package/src/Config/SettingText.ts +82 -0
- package/src/DataChannel/DataChannelController.ts +138 -0
- package/src/DataChannel/DataChannelLatencyTestController.ts +129 -0
- package/src/DataChannel/DataChannelLatencyTestResults.ts +67 -0
- package/src/DataChannel/DataChannelSender.ts +59 -0
- package/src/DataChannel/InitialSettings.ts +61 -0
- package/src/DataChannel/LatencyTestResults.ts +76 -0
- package/src/FreezeFrame/FreezeFrame.ts +114 -0
- package/src/FreezeFrame/FreezeFrameController.ts +114 -0
- package/src/Inputs/FakeTouchController.ts +199 -0
- package/src/Inputs/GamepadController.ts +300 -0
- package/src/Inputs/GamepadTypes.ts +10 -0
- package/src/Inputs/HoveringMouseEvents.ts +192 -0
- package/src/Inputs/IMouseEvents.ts +64 -0
- package/src/Inputs/ITouchController.ts +29 -0
- package/src/Inputs/InputClassesFactory.ts +140 -0
- package/src/Inputs/KeyboardController.ts +318 -0
- package/src/Inputs/LockedMouseEvents.ts +287 -0
- package/src/Inputs/MouseButtons.ts +25 -0
- package/src/Inputs/MouseController.ts +362 -0
- package/src/Inputs/SpecialKeyCodes.ts +16 -0
- package/src/Inputs/TouchController.ts +253 -0
- package/src/Inputs/XRGamepadController.ts +126 -0
- package/src/Logger/Logger.ts +80 -0
- package/src/PeerConnectionController/AggregatedStats.ts +311 -0
- package/src/PeerConnectionController/CandidatePairStats.ts +17 -0
- package/src/PeerConnectionController/CandidateStat.ts +13 -0
- package/src/PeerConnectionController/CodecStats.ts +19 -0
- package/src/PeerConnectionController/DataChannelStats.ts +17 -0
- package/src/PeerConnectionController/InboundRTPStats.ts +154 -0
- package/src/PeerConnectionController/InboundTrackStats.ts +34 -0
- package/src/PeerConnectionController/OutBoundRTPStats.ts +26 -0
- package/src/PeerConnectionController/PeerConnectionController.ts +563 -0
- package/src/PeerConnectionController/SessionStats.ts +10 -0
- package/src/PeerConnectionController/StreamStats.ts +11 -0
- package/src/PixelStreaming/PixelStreaming.test.ts +624 -0
- package/src/PixelStreaming/PixelStreaming.ts +847 -0
- package/src/UI/OnScreenKeyboard.ts +97 -0
- package/src/UeInstanceMessage/ResponseController.ts +47 -0
- package/src/UeInstanceMessage/SendMessageController.ts +154 -0
- package/src/UeInstanceMessage/StreamMessageController.ts +233 -0
- package/src/UeInstanceMessage/ToStreamerMessagesController.ts +62 -0
- package/src/Util/CoordinateConverter.ts +289 -0
- package/src/Util/EventEmitter.ts +595 -0
- package/src/Util/EventListenerTracker.ts +29 -0
- package/src/Util/FileUtil.ts +140 -0
- package/src/Util/RTCUtils.ts +41 -0
- package/src/Util/WebGLUtils.ts +49 -0
- package/src/Util/WebXRUtils.ts +25 -0
- package/src/VideoPlayer/StreamController.ts +89 -0
- package/src/VideoPlayer/VideoPlayer.ts +246 -0
- package/src/WebRtcPlayer/WebRtcPlayerController.ts +2144 -0
- package/src/WebSockets/MessageReceive.ts +89 -0
- package/src/WebSockets/MessageSend.ts +185 -0
- package/src/WebSockets/SignallingProtocol.ts +180 -0
- package/src/WebSockets/WebSocketController.ts +267 -0
- package/src/WebXR/WebXRController.ts +319 -0
- package/src/__test__/mockMediaStream.ts +124 -0
- package/src/__test__/mockRTCPeerConnection.ts +347 -0
- package/src/__test__/mockRTCRtpReceiver.ts +22 -0
- package/src/__test__/mockWebSocket.ts +130 -0
- package/src/pixelstreamingfrontend.ts +50 -0
- package/tsconfig.jest.json +8 -0
- package/tsconfig.json +24 -0
- package/webpack.common.js +35 -0
- package/webpack.dev.js +35 -0
- package/webpack.prod.js +36 -0
- package/yang__yj-pixelstreaming-core-1.0.1.tgz +0 -0
- /package/{library/dist → dist}/lib-pixelstreamingfrontend.esm.js +0 -0
- /package/{library/dist → dist}/lib-pixelstreamingfrontend.js +0 -0
- /package/{library/types → types}/AFK/AFKController.d.ts +0 -0
- /package/{library/types → types}/Config/Config.d.ts +0 -0
- /package/{library/types → types}/Config/SettingBase.d.ts +0 -0
- /package/{library/types → types}/Config/SettingFlag.d.ts +0 -0
- /package/{library/types → types}/Config/SettingNumber.d.ts +0 -0
- /package/{library/types → types}/Config/SettingOption.d.ts +0 -0
- /package/{library/types → types}/Config/SettingText.d.ts +0 -0
- /package/{library/types → types}/DataChannel/DataChannelController.d.ts +0 -0
- /package/{library/types → types}/DataChannel/DataChannelSender.d.ts +0 -0
- /package/{library/types → types}/DataChannel/InitialSettings.d.ts +0 -0
- /package/{library/types → types}/DataChannel/LatencyTestResults.d.ts +0 -0
- /package/{library/types → types}/FreezeFrame/FreezeFrame.d.ts +0 -0
- /package/{library/types → types}/FreezeFrame/FreezeFrameController.d.ts +0 -0
- /package/{library/types → types}/Inputs/FakeTouchController.d.ts +0 -0
- /package/{library/types → types}/Inputs/GamepadController.d.ts +0 -0
- /package/{library/types → types}/Inputs/GamepadTypes.d.ts +0 -0
- /package/{library/types → types}/Inputs/HoveringMouseEvents.d.ts +0 -0
- /package/{library/types → types}/Inputs/IMouseEvents.d.ts +0 -0
- /package/{library/types → types}/Inputs/ITouchController.d.ts +0 -0
- /package/{library/types → types}/Inputs/InputClassesFactory.d.ts +0 -0
- /package/{library/types → types}/Inputs/KeyboardController.d.ts +0 -0
- /package/{library/types → types}/Inputs/LockedMouseEvents.d.ts +0 -0
- /package/{library/types → types}/Inputs/MouseButtons.d.ts +0 -0
- /package/{library/types → types}/Inputs/MouseController.d.ts +0 -0
- /package/{library/types → types}/Inputs/SpecialKeyCodes.d.ts +0 -0
- /package/{library/types → types}/Inputs/TouchController.d.ts +0 -0
- /package/{library/types → types}/Inputs/XRGamepadController.d.ts +0 -0
- /package/{library/types → types}/Logger/Logger.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/AggregatedStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/CandidatePairStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/CandidateStat.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/CodecStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/DataChannelStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/InboundRTPStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/InboundTrackStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/OutBoundRTPStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/PeerConnectionController.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/SessionStats.d.ts +0 -0
- /package/{library/types → types}/PeerConnectionController/StreamStats.d.ts +0 -0
- /package/{library/types → types}/PixelStreaming/PixelStreaming.d.ts +0 -0
- /package/{library/types → types}/UI/OnScreenKeyboard.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/ResponseController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/SendDescriptorController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/SendMessageController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/StreamMessageController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/ToStreamerMessagesController.d.ts +0 -0
- /package/{library/types → types}/UeInstanceMessage/TwoWayMap.d.ts +0 -0
- /package/{library/types → types}/Util/CoordinateConverter.d.ts +0 -0
- /package/{library/types → types}/Util/EventEmitter.d.ts +0 -0
- /package/{library/types → types}/Util/EventListenerTracker.d.ts +0 -0
- /package/{library/types → types}/Util/FileUtil.d.ts +0 -0
- /package/{library/types → types}/Util/WebGLUtils.d.ts +0 -0
- /package/{library/types → types}/Util/WebXRUtils.d.ts +0 -0
- /package/{library/types → types}/VideoPlayer/StreamController.d.ts +0 -0
- /package/{library/types → types}/VideoPlayer/VideoPlayer.d.ts +0 -0
- /package/{library/types → types}/WebRtcPlayer/WebRtcPlayerController.d.ts +0 -0
- /package/{library/types → types}/WebSockets/MessageReceive.d.ts +0 -0
- /package/{library/types → types}/WebSockets/MessageSend.d.ts +0 -0
- /package/{library/types → types}/WebSockets/SignallingProtocol.d.ts +0 -0
- /package/{library/types → types}/WebSockets/WebSocketController.d.ts +0 -0
- /package/{library/types → types}/WebXR/WebXRController.d.ts +0 -0
- /package/{library/types → types}/pixelstreamingfrontend.d.ts +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface for Mouse Events
|
|
5
|
+
*/
|
|
6
|
+
export interface IMouseEvents {
|
|
7
|
+
/**
|
|
8
|
+
* Handle when the locked state Changed
|
|
9
|
+
*/
|
|
10
|
+
lockStateChange?(): void;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Handle when the mouse move
|
|
14
|
+
* @param mouseEvent - Mouse Event
|
|
15
|
+
*/
|
|
16
|
+
updateMouseMovePosition?(mouseEvent: MouseEvent): void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Handle when the Button Down
|
|
20
|
+
* @param mouseEvent - Mouse Event
|
|
21
|
+
*/
|
|
22
|
+
handleMouseDown(mouseEvent: MouseEvent): void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Handle when the button up
|
|
26
|
+
* @param mouseEvent - Mouse Event
|
|
27
|
+
*/
|
|
28
|
+
handleMouseUp(mouseEvent: MouseEvent): void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Handle when the mouse wheel
|
|
32
|
+
* @param wheelEvent - Mouse wheel
|
|
33
|
+
*/
|
|
34
|
+
handleMouseWheel(wheelEvent: WheelEvent): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Handle when the button double click
|
|
38
|
+
* @param mouseEvent - Mouse Event
|
|
39
|
+
*/
|
|
40
|
+
handleMouseDouble(mouseEvent: MouseEvent): void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Handle the press mouse buttons event, sends the mouse data to the UE Instance
|
|
44
|
+
* @param mouseEvent - Mouse Event
|
|
45
|
+
*/
|
|
46
|
+
handlePressMouseButtons(mouseEvent: MouseEvent): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Handle the release mouse buttons event, sends the mouse data to the UE Instance
|
|
50
|
+
* @param mouseEvent - Mouse Event
|
|
51
|
+
*/
|
|
52
|
+
handleReleaseMouseButtons(mouseEvent: MouseEvent): void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Handle the mouse context menu
|
|
56
|
+
* @param mouseEvent - mouse event
|
|
57
|
+
*/
|
|
58
|
+
handleContextMenu?(mouseEvent: MouseEvent): void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Unregisters any registered mouse event handlers
|
|
62
|
+
*/
|
|
63
|
+
unregisterMouseEvents(): void;
|
|
64
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface for Touch Events
|
|
5
|
+
*/
|
|
6
|
+
export interface ITouchController {
|
|
7
|
+
/**
|
|
8
|
+
* Fire when a touch event starts
|
|
9
|
+
* @param touchEvent - Touch Event Data
|
|
10
|
+
*/
|
|
11
|
+
onTouchStart(touchEvent: TouchEvent): void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Fire when a touch event ends
|
|
15
|
+
* @param touchEvent - Touch Event Data
|
|
16
|
+
*/
|
|
17
|
+
onTouchEnd(touchEvent: TouchEvent): void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Fire when touch moves
|
|
21
|
+
* @param touchEvent - Touch Event Data
|
|
22
|
+
*/
|
|
23
|
+
onTouchMove(touchEvent: TouchEvent): void;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Unregisters all touch event handlers
|
|
27
|
+
*/
|
|
28
|
+
unregisterTouchEvents(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
import { FakeTouchController } from './FakeTouchController';
|
|
4
|
+
import { KeyboardController } from './KeyboardController';
|
|
5
|
+
import { MouseController } from './MouseController';
|
|
6
|
+
import { TouchController } from './TouchController';
|
|
7
|
+
import { GamePadController } from './GamepadController';
|
|
8
|
+
import { Config, ControlSchemeType } from '../Config/Config';
|
|
9
|
+
import { Logger } from '../Logger/Logger';
|
|
10
|
+
import { CoordinateConverter } from '../Util/CoordinateConverter';
|
|
11
|
+
import { StreamMessageController } from '../UeInstanceMessage/StreamMessageController';
|
|
12
|
+
import { VideoPlayer } from '../VideoPlayer/VideoPlayer';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Class for making and setting up input class types
|
|
16
|
+
*/
|
|
17
|
+
export class InputClassesFactory {
|
|
18
|
+
toStreamerMessagesProvider: StreamMessageController;
|
|
19
|
+
videoElementProvider: VideoPlayer;
|
|
20
|
+
coordinateConverter: CoordinateConverter;
|
|
21
|
+
activeKeys: ActiveKeys = new ActiveKeys();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param toStreamerMessagesProvider - Stream message instance
|
|
25
|
+
* @param videoElementProvider - Video Player instance
|
|
26
|
+
* @param coordinateConverter - A coordinateConverter instance
|
|
27
|
+
*/
|
|
28
|
+
constructor(
|
|
29
|
+
toStreamerMessagesProvider: StreamMessageController,
|
|
30
|
+
videoElementProvider: VideoPlayer,
|
|
31
|
+
coordinateConverter: CoordinateConverter
|
|
32
|
+
) {
|
|
33
|
+
this.toStreamerMessagesProvider = toStreamerMessagesProvider;
|
|
34
|
+
this.videoElementProvider = videoElementProvider;
|
|
35
|
+
this.coordinateConverter = coordinateConverter;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Registers browser key events.
|
|
40
|
+
*/
|
|
41
|
+
registerKeyBoard(config: Config) {
|
|
42
|
+
Logger.Log(Logger.GetStackTrace(), 'Register Keyboard Events', 7);
|
|
43
|
+
const keyboardController = new KeyboardController(
|
|
44
|
+
this.toStreamerMessagesProvider,
|
|
45
|
+
config,
|
|
46
|
+
this.activeKeys
|
|
47
|
+
);
|
|
48
|
+
keyboardController.registerKeyBoardEvents();
|
|
49
|
+
return keyboardController;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* register mouse events based on a control type
|
|
54
|
+
* @param controlScheme - if the mouse is either hovering or locked
|
|
55
|
+
*/
|
|
56
|
+
registerMouse(controlScheme: ControlSchemeType) {
|
|
57
|
+
Logger.Log(Logger.GetStackTrace(), 'Register Mouse Events', 7);
|
|
58
|
+
const mouseController = new MouseController(
|
|
59
|
+
this.toStreamerMessagesProvider,
|
|
60
|
+
this.videoElementProvider,
|
|
61
|
+
this.coordinateConverter,
|
|
62
|
+
this.activeKeys
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
switch (controlScheme) {
|
|
66
|
+
case ControlSchemeType.LockedMouse:
|
|
67
|
+
mouseController.registerLockedMouseEvents(mouseController);
|
|
68
|
+
break;
|
|
69
|
+
case ControlSchemeType.HoveringMouse:
|
|
70
|
+
mouseController.registerHoveringMouseEvents(mouseController);
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
Logger.Info(
|
|
74
|
+
Logger.GetStackTrace(),
|
|
75
|
+
'unknown Control Scheme Type Defaulting to Locked Mouse Events'
|
|
76
|
+
);
|
|
77
|
+
mouseController.registerLockedMouseEvents(mouseController);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return mouseController;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* register touch events
|
|
86
|
+
* @param fakeMouseTouch - the faked mouse touch event
|
|
87
|
+
*/
|
|
88
|
+
registerTouch(
|
|
89
|
+
fakeMouseTouch: boolean,
|
|
90
|
+
videoElementParentClientRect: DOMRect
|
|
91
|
+
) {
|
|
92
|
+
Logger.Log(Logger.GetStackTrace(), 'Registering Touch', 6);
|
|
93
|
+
if (fakeMouseTouch) {
|
|
94
|
+
const fakeTouchController = new FakeTouchController(
|
|
95
|
+
this.toStreamerMessagesProvider,
|
|
96
|
+
this.videoElementProvider,
|
|
97
|
+
this.coordinateConverter
|
|
98
|
+
);
|
|
99
|
+
fakeTouchController.setVideoElementParentClientRect(
|
|
100
|
+
videoElementParentClientRect
|
|
101
|
+
);
|
|
102
|
+
return fakeTouchController;
|
|
103
|
+
} else {
|
|
104
|
+
return new TouchController(
|
|
105
|
+
this.toStreamerMessagesProvider,
|
|
106
|
+
this.videoElementProvider,
|
|
107
|
+
this.coordinateConverter
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* registers a gamepad
|
|
114
|
+
*/
|
|
115
|
+
registerGamePad() {
|
|
116
|
+
Logger.Log(Logger.GetStackTrace(), 'Register Game Pad', 7);
|
|
117
|
+
const gamePadController = new GamePadController(
|
|
118
|
+
this.toStreamerMessagesProvider
|
|
119
|
+
);
|
|
120
|
+
return gamePadController;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* A class that keeps track of current active keys
|
|
126
|
+
*/
|
|
127
|
+
export class ActiveKeys {
|
|
128
|
+
activeKeys: Array<number> = [];
|
|
129
|
+
constructor() {
|
|
130
|
+
this.activeKeys = [];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Get the current array of active keys
|
|
135
|
+
* @returns - an array of active keys
|
|
136
|
+
*/
|
|
137
|
+
getActiveKeys(): number[] {
|
|
138
|
+
return this.activeKeys;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
import { SpecialKeyCodes } from './SpecialKeyCodes';
|
|
4
|
+
import { Logger } from '../Logger/Logger';
|
|
5
|
+
import { ActiveKeys } from './InputClassesFactory';
|
|
6
|
+
import { StreamMessageController } from '../UeInstanceMessage/StreamMessageController';
|
|
7
|
+
import { Config, Flags } from '../Config/Config';
|
|
8
|
+
import { EventListenerTracker } from '../Util/EventListenerTracker';
|
|
9
|
+
|
|
10
|
+
interface ICodeToKeyCode {
|
|
11
|
+
[key: string]: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Handles the Keyboard Inputs for the document
|
|
16
|
+
*/
|
|
17
|
+
export class KeyboardController {
|
|
18
|
+
toStreamerMessagesProvider: StreamMessageController;
|
|
19
|
+
activeKeysProvider: ActiveKeys;
|
|
20
|
+
config: Config;
|
|
21
|
+
|
|
22
|
+
// Utility for keeping track of event handlers and unregistering them
|
|
23
|
+
private keyboardEventListenerTracker = new EventListenerTracker();
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
* New browser APIs have moved away from KeyboardEvent.keyCode to KeyboardEvent.Code.
|
|
27
|
+
* For details see: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#constants_for_keycode_value
|
|
28
|
+
* We still use old KeyboardEvent.keyCode integers in the UE C++ side, so we need a way to map the new
|
|
29
|
+
* string-based KeyboardEvent.Code to the old integers.
|
|
30
|
+
*/
|
|
31
|
+
CodeToKeyCode: ICodeToKeyCode = {
|
|
32
|
+
Escape: 27,
|
|
33
|
+
Digit0: 48,
|
|
34
|
+
Digit1: 49,
|
|
35
|
+
Digit2: 50,
|
|
36
|
+
Digit3: 51,
|
|
37
|
+
Digit4: 52,
|
|
38
|
+
Digit5: 53,
|
|
39
|
+
Digit6: 54,
|
|
40
|
+
Digit7: 55,
|
|
41
|
+
Digit8: 56,
|
|
42
|
+
Digit9: 57,
|
|
43
|
+
Minus: 173,
|
|
44
|
+
Equal: 187,
|
|
45
|
+
Backspace: 8,
|
|
46
|
+
Tab: 9,
|
|
47
|
+
KeyQ: 81,
|
|
48
|
+
KeyW: 87,
|
|
49
|
+
KeyE: 69,
|
|
50
|
+
KeyR: 82,
|
|
51
|
+
KeyT: 84,
|
|
52
|
+
KeyY: 89,
|
|
53
|
+
KeyU: 85,
|
|
54
|
+
KeyI: 73,
|
|
55
|
+
KeyO: 79,
|
|
56
|
+
KeyP: 80,
|
|
57
|
+
BracketLeft: 219,
|
|
58
|
+
BracketRight: 221,
|
|
59
|
+
Enter: 13,
|
|
60
|
+
ControlLeft: 17,
|
|
61
|
+
KeyA: 65,
|
|
62
|
+
KeyS: 83,
|
|
63
|
+
KeyD: 68,
|
|
64
|
+
KeyF: 70,
|
|
65
|
+
KeyG: 71,
|
|
66
|
+
KeyH: 72,
|
|
67
|
+
KeyJ: 74,
|
|
68
|
+
KeyK: 75,
|
|
69
|
+
KeyL: 76,
|
|
70
|
+
Semicolon: 186,
|
|
71
|
+
Quote: 222,
|
|
72
|
+
Backquote: 192,
|
|
73
|
+
ShiftLeft: 16,
|
|
74
|
+
Backslash: 220,
|
|
75
|
+
KeyZ: 90,
|
|
76
|
+
KeyX: 88,
|
|
77
|
+
KeyC: 67,
|
|
78
|
+
KeyV: 86,
|
|
79
|
+
KeyB: 66,
|
|
80
|
+
KeyN: 78,
|
|
81
|
+
KeyM: 77,
|
|
82
|
+
Comma: 188,
|
|
83
|
+
Period: 190,
|
|
84
|
+
Slash: 191,
|
|
85
|
+
ShiftRight: 253,
|
|
86
|
+
AltLeft: 18,
|
|
87
|
+
Space: 32,
|
|
88
|
+
CapsLock: 20,
|
|
89
|
+
F1: 112,
|
|
90
|
+
F2: 113,
|
|
91
|
+
F3: 114,
|
|
92
|
+
F4: 115,
|
|
93
|
+
F5: 116,
|
|
94
|
+
F6: 117,
|
|
95
|
+
F7: 118,
|
|
96
|
+
F8: 119,
|
|
97
|
+
F9: 120,
|
|
98
|
+
F10: 121,
|
|
99
|
+
F11: 122,
|
|
100
|
+
F12: 123,
|
|
101
|
+
Pause: 19,
|
|
102
|
+
ScrollLock: 145,
|
|
103
|
+
NumpadDivide: 111,
|
|
104
|
+
NumpadMultiply: 106,
|
|
105
|
+
NumpadSubtract: 109,
|
|
106
|
+
NumpadAdd: 107,
|
|
107
|
+
NumpadDecimal: 110,
|
|
108
|
+
Numpad9: 105,
|
|
109
|
+
Numpad8: 104,
|
|
110
|
+
Numpad7: 103,
|
|
111
|
+
Numpad6: 102,
|
|
112
|
+
Numpad5: 101,
|
|
113
|
+
Numpad4: 100,
|
|
114
|
+
Numpad3: 99,
|
|
115
|
+
Numpad2: 98,
|
|
116
|
+
Numpad1: 97,
|
|
117
|
+
Numpad0: 96,
|
|
118
|
+
NumLock: 144,
|
|
119
|
+
ControlRight: 254,
|
|
120
|
+
AltRight: 255,
|
|
121
|
+
Home: 36,
|
|
122
|
+
End: 35,
|
|
123
|
+
ArrowUp: 38,
|
|
124
|
+
ArrowLeft: 37,
|
|
125
|
+
ArrowRight: 39,
|
|
126
|
+
ArrowDown: 40,
|
|
127
|
+
PageUp: 33,
|
|
128
|
+
PageDown: 34,
|
|
129
|
+
Insert: 45,
|
|
130
|
+
Delete: 46,
|
|
131
|
+
ContextMenu: 93
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @param toStreamerMessagesProvider Stream message provider class object
|
|
136
|
+
* @param config The applications configuration. We're interested in the suppress browser keys option
|
|
137
|
+
* @param activeKeysProvider Active keys provider class object
|
|
138
|
+
*/
|
|
139
|
+
constructor(
|
|
140
|
+
toStreamerMessagesProvider: StreamMessageController,
|
|
141
|
+
config: Config,
|
|
142
|
+
activeKeysProvider: ActiveKeys
|
|
143
|
+
) {
|
|
144
|
+
this.toStreamerMessagesProvider = toStreamerMessagesProvider;
|
|
145
|
+
this.config = config;
|
|
146
|
+
this.activeKeysProvider = activeKeysProvider;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Registers document keyboard events with the controller
|
|
151
|
+
*/
|
|
152
|
+
registerKeyBoardEvents() {
|
|
153
|
+
const keyDownHandler = (ev: KeyboardEvent) => this.handleOnKeyDown(ev);
|
|
154
|
+
const keyUpHandler = (ev: KeyboardEvent) => this.handleOnKeyUp(ev);
|
|
155
|
+
const keyPressHandler = (ev: KeyboardEvent) => this.handleOnKeyPress(ev);
|
|
156
|
+
|
|
157
|
+
document.addEventListener("keydown", keyDownHandler);
|
|
158
|
+
document.addEventListener("keyup", keyUpHandler);
|
|
159
|
+
|
|
160
|
+
//This has been deprecated as at Jun 13 2021
|
|
161
|
+
document.addEventListener("keypress", keyPressHandler);
|
|
162
|
+
|
|
163
|
+
this.keyboardEventListenerTracker.addUnregisterCallback(
|
|
164
|
+
() => document.removeEventListener("keydown", keyDownHandler)
|
|
165
|
+
);
|
|
166
|
+
this.keyboardEventListenerTracker.addUnregisterCallback(
|
|
167
|
+
() => document.removeEventListener("keyup", keyUpHandler)
|
|
168
|
+
);
|
|
169
|
+
this.keyboardEventListenerTracker.addUnregisterCallback(
|
|
170
|
+
() => document.removeEventListener("keypress", keyPressHandler)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Unregisters document keyboard events
|
|
176
|
+
*/
|
|
177
|
+
unregisterKeyBoardEvents() {
|
|
178
|
+
this.keyboardEventListenerTracker.unregisterAll();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Handles When a key is down
|
|
183
|
+
* @param keyboardEvent - Keyboard event
|
|
184
|
+
*/
|
|
185
|
+
handleOnKeyDown(keyboardEvent: KeyboardEvent) {
|
|
186
|
+
const keyCode = this.getKeycode(keyboardEvent);
|
|
187
|
+
if (!keyCode) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
Logger.Log(
|
|
192
|
+
Logger.GetStackTrace(),
|
|
193
|
+
`key down ${keyCode}, repeat = ${keyboardEvent.repeat}`,
|
|
194
|
+
6
|
|
195
|
+
);
|
|
196
|
+
const toStreamerHandlers =
|
|
197
|
+
this.toStreamerMessagesProvider.toStreamerHandlers;
|
|
198
|
+
toStreamerHandlers.get('KeyDown')([
|
|
199
|
+
this.getKeycode(keyboardEvent),
|
|
200
|
+
keyboardEvent.repeat ? 1 : 0
|
|
201
|
+
]);
|
|
202
|
+
const activeKeys = this.activeKeysProvider.getActiveKeys();
|
|
203
|
+
activeKeys.push(keyCode);
|
|
204
|
+
// Backspace is not considered a keypress in JavaScript but we need it
|
|
205
|
+
// to be so characters may be deleted in a UE text entry field.
|
|
206
|
+
if (keyCode === SpecialKeyCodes.backSpace) {
|
|
207
|
+
document.dispatchEvent(
|
|
208
|
+
new KeyboardEvent('keypress', {
|
|
209
|
+
charCode: SpecialKeyCodes.backSpace
|
|
210
|
+
})
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (
|
|
215
|
+
this.config.isFlagEnabled(Flags.SuppressBrowserKeys) &&
|
|
216
|
+
this.isKeyCodeBrowserKey(keyCode)
|
|
217
|
+
) {
|
|
218
|
+
keyboardEvent.preventDefault();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* handles when a key is up
|
|
224
|
+
* @param keyboardEvent - Keyboard event
|
|
225
|
+
*/
|
|
226
|
+
handleOnKeyUp(keyboardEvent: KeyboardEvent) {
|
|
227
|
+
const keyCode = this.getKeycode(keyboardEvent);
|
|
228
|
+
if (!keyCode) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
Logger.Log(Logger.GetStackTrace(), `key up ${keyCode}`, 6);
|
|
233
|
+
const toStreamerHandlers =
|
|
234
|
+
this.toStreamerMessagesProvider.toStreamerHandlers;
|
|
235
|
+
toStreamerHandlers.get('KeyUp')([ keyCode ]);
|
|
236
|
+
|
|
237
|
+
if (
|
|
238
|
+
this.config.isFlagEnabled(Flags.SuppressBrowserKeys) &&
|
|
239
|
+
this.isKeyCodeBrowserKey(keyCode)
|
|
240
|
+
) {
|
|
241
|
+
keyboardEvent.preventDefault();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Handles when a key is press
|
|
247
|
+
* @param keyboard - Keyboard Event
|
|
248
|
+
*/
|
|
249
|
+
handleOnKeyPress(keyboard: KeyboardEvent) {
|
|
250
|
+
if (!('charCode' in keyboard)) {
|
|
251
|
+
Logger.Warning(
|
|
252
|
+
Logger.GetStackTrace(),
|
|
253
|
+
'KeyboardEvent.charCode is deprecated in this browser, cannot send key press.'
|
|
254
|
+
);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const charCode = keyboard.charCode;
|
|
259
|
+
Logger.Log(Logger.GetStackTrace(), `key press ${charCode}`, 6);
|
|
260
|
+
|
|
261
|
+
const toStreamerHandlers =
|
|
262
|
+
this.toStreamerMessagesProvider.toStreamerHandlers;
|
|
263
|
+
toStreamerHandlers.get('KeyPress')([charCode]);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Gets the Keycode of the Key pressed
|
|
268
|
+
* @param keyboardEvent - Key board Event
|
|
269
|
+
* @returns - the key code of the Key
|
|
270
|
+
*/
|
|
271
|
+
getKeycode(keyboardEvent: KeyboardEvent) {
|
|
272
|
+
// If we don't have keyCode property because browser API is deprecated then use KeyboardEvent.code instead.
|
|
273
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode#constants_for_keycode_value
|
|
274
|
+
if (!('keyCode' in keyboardEvent)) {
|
|
275
|
+
// Convert KeyboardEvent.code string into integer-based key code for backwards compatibility reasons.
|
|
276
|
+
const event = keyboardEvent as KeyboardEvent;
|
|
277
|
+
if (event.code in this.CodeToKeyCode) {
|
|
278
|
+
return this.CodeToKeyCode[event.code];
|
|
279
|
+
} else {
|
|
280
|
+
Logger.Warning(
|
|
281
|
+
Logger.GetStackTrace(),
|
|
282
|
+
`Keyboard code of ${event.code} is not supported in our mapping, ignoring this key.`
|
|
283
|
+
);
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// If we made it here KeyboardEvent.keyCode is still supported so we can safely use it.
|
|
289
|
+
|
|
290
|
+
if (
|
|
291
|
+
keyboardEvent.keyCode === SpecialKeyCodes.shift &&
|
|
292
|
+
keyboardEvent.code === 'ShiftRight'
|
|
293
|
+
) {
|
|
294
|
+
return SpecialKeyCodes.rightShift;
|
|
295
|
+
} else if (
|
|
296
|
+
keyboardEvent.keyCode === SpecialKeyCodes.control &&
|
|
297
|
+
keyboardEvent.code === 'ControlRight'
|
|
298
|
+
) {
|
|
299
|
+
return SpecialKeyCodes.rightControl;
|
|
300
|
+
} else if (
|
|
301
|
+
keyboardEvent.keyCode === SpecialKeyCodes.alt &&
|
|
302
|
+
keyboardEvent.code === 'AltRight'
|
|
303
|
+
) {
|
|
304
|
+
return SpecialKeyCodes.rightAlt;
|
|
305
|
+
} else {
|
|
306
|
+
return keyboardEvent.keyCode;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Browser keys do not have a charCode so we only need to test keyCode.
|
|
312
|
+
* @param keyCode - the browser keycode number
|
|
313
|
+
*/
|
|
314
|
+
isKeyCodeBrowserKey(keyCode: number) {
|
|
315
|
+
// Function keys or tab key are considered "browser keys" that we may wish to suppress by preventing them being process by browser.
|
|
316
|
+
return (keyCode >= 112 && keyCode <= 123) || keyCode === 9;
|
|
317
|
+
}
|
|
318
|
+
}
|