mirror of https://github.com/jetkvm/kvm.git
Merge branch 'dev' into feat/audio-support
This commit is contained in:
commit
5b5fc40a08
|
|
@ -28,6 +28,7 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
|
||||||
// Video and stream related refs and states
|
// Video and stream related refs and states
|
||||||
const videoElm = useRef<HTMLVideoElement>(null);
|
const videoElm = useRef<HTMLVideoElement>(null);
|
||||||
const audioElementsRef = useRef<HTMLAudioElement[]>([]);
|
const audioElementsRef = useRef<HTMLAudioElement[]>([]);
|
||||||
|
const fullscreenContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const { mediaStream, peerConnectionState } = useRTCStore();
|
const { mediaStream, peerConnectionState } = useRTCStore();
|
||||||
const [isPlaying, setIsPlaying] = useState(false);
|
const [isPlaying, setIsPlaying] = useState(false);
|
||||||
const [audioAutoplayBlocked, setAudioAutoplayBlocked] = useState(false);
|
const [audioAutoplayBlocked, setAudioAutoplayBlocked] = useState(false);
|
||||||
|
|
@ -153,7 +154,7 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
|
||||||
}, [checkNavigatorPermissions, setIsKeyboardLockActive]);
|
}, [checkNavigatorPermissions, setIsKeyboardLockActive]);
|
||||||
|
|
||||||
const releaseKeyboardLock = useCallback(async () => {
|
const releaseKeyboardLock = useCallback(async () => {
|
||||||
if (videoElm.current === null || document.fullscreenElement !== videoElm.current) return;
|
if (fullscreenContainerRef.current === null || document.fullscreenElement !== fullscreenContainerRef.current) return;
|
||||||
|
|
||||||
if (navigator && "keyboard" in navigator) {
|
if (navigator && "keyboard" in navigator) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -190,7 +191,7 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
|
||||||
}, [isPointerLockPossible]);
|
}, [isPointerLockPossible]);
|
||||||
|
|
||||||
const requestFullscreen = useCallback(async () => {
|
const requestFullscreen = useCallback(async () => {
|
||||||
if (!isFullscreenEnabled || !videoElm.current) return;
|
if (!isFullscreenEnabled || !fullscreenContainerRef.current) return;
|
||||||
|
|
||||||
// per https://wicg.github.io/keyboard-lock/#system-key-press-handler
|
// per https://wicg.github.io/keyboard-lock/#system-key-press-handler
|
||||||
// If keyboard lock is activated after fullscreen is already in effect, then the user my
|
// If keyboard lock is activated after fullscreen is already in effect, then the user my
|
||||||
|
|
@ -199,7 +200,7 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
|
||||||
await requestKeyboardLock();
|
await requestKeyboardLock();
|
||||||
await requestPointerLock();
|
await requestPointerLock();
|
||||||
|
|
||||||
await videoElm.current.requestFullscreen({
|
await fullscreenContainerRef.current.requestFullscreen({
|
||||||
navigationUI: "show",
|
navigationUI: "show",
|
||||||
});
|
});
|
||||||
}, [isFullscreenEnabled, requestKeyboardLock, requestPointerLock]);
|
}, [isFullscreenEnabled, requestKeyboardLock, requestPointerLock]);
|
||||||
|
|
@ -537,7 +538,10 @@ export default function WebRTCVideo({ hasConnectionIssues }: { hasConnectionIssu
|
||||||
{/* In relative mouse mode and under https, we enable the pointer lock, and to do so we need a bar to show the user to click on the video to enable mouse control */}
|
{/* In relative mouse mode and under https, we enable the pointer lock, and to do so we need a bar to show the user to click on the video to enable mouse control */}
|
||||||
<PointerLockBar show={showPointerLockBar} />
|
<PointerLockBar show={showPointerLockBar} />
|
||||||
<div className="relative mx-4 my-2 flex items-center justify-center overflow-hidden">
|
<div className="relative mx-4 my-2 flex items-center justify-center overflow-hidden">
|
||||||
<div className="relative flex h-full w-full items-center justify-center">
|
<div
|
||||||
|
ref={fullscreenContainerRef}
|
||||||
|
className="relative flex h-full w-full items-center justify-center"
|
||||||
|
>
|
||||||
<video
|
<video
|
||||||
ref={videoElm}
|
ref={videoElm}
|
||||||
autoPlay
|
autoPlay
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,8 @@ export default function PasteModal() {
|
||||||
const macroSteps: MacroStep[] = [];
|
const macroSteps: MacroStep[] = [];
|
||||||
|
|
||||||
for (const char of text) {
|
for (const char of text) {
|
||||||
const keyprops = selectedKeyboard.chars[char];
|
const normalizedChar = char.normalize('NFC');
|
||||||
|
const keyprops = selectedKeyboard.chars[normalizedChar];
|
||||||
if (!keyprops) continue;
|
if (!keyprops) continue;
|
||||||
|
|
||||||
const { key, shift, altRight, deadKey, accentKey } = keyprops;
|
const { key, shift, altRight, deadKey, accentKey } = keyprops;
|
||||||
|
|
@ -164,7 +165,7 @@ export default function PasteModal() {
|
||||||
...new Set(
|
...new Set(
|
||||||
// @ts-expect-error TS doesn't recognize Intl.Segmenter in some environments
|
// @ts-expect-error TS doesn't recognize Intl.Segmenter in some environments
|
||||||
[...new Intl.Segmenter().segment(value)]
|
[...new Intl.Segmenter().segment(value)]
|
||||||
.map(x => x.segment)
|
.map(x => x.segment.normalize('NFC'))
|
||||||
.filter(char => !selectedKeyboard.chars[char]),
|
.filter(char => !selectedKeyboard.chars[char]),
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
|
||||||
11
webrtc.go
11
webrtc.go
|
|
@ -287,10 +287,13 @@ func newSession(config SessionConfig) (*Session, error) {
|
||||||
// Enqueue to ensure ordered processing
|
// Enqueue to ensure ordered processing
|
||||||
session.rpcQueue <- msg
|
session.rpcQueue <- msg
|
||||||
})
|
})
|
||||||
triggerOTAStateUpdate()
|
// Wait for channel to be open before sending initial state
|
||||||
triggerVideoStateUpdate()
|
d.OnOpen(func() {
|
||||||
triggerUSBStateUpdate()
|
triggerOTAStateUpdate()
|
||||||
notifyFailsafeMode(session)
|
triggerVideoStateUpdate()
|
||||||
|
triggerUSBStateUpdate()
|
||||||
|
notifyFailsafeMode(session)
|
||||||
|
})
|
||||||
case "terminal":
|
case "terminal":
|
||||||
handleTerminalChannel(d)
|
handleTerminalChannel(d)
|
||||||
case "serial":
|
case "serial":
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue