import { useMemo } from "react"; import { useHidStore, useMouseStore, useRTCStore, useSettingsStore, useVideoStore, VideoState } from "@hooks/stores"; import { useHidRpc } from "@hooks/useHidRpc"; import { keys, modifiers } from "@/keyboardMappings"; import { cx } from "@/cva.config"; import { m } from "@localizations/messages.js"; export default function InfoBar() { const { keysDownState } = useHidStore(); const { mouseX, mouseY, mouseMove } = useMouseStore(); const { rpcHidStatus } = useHidRpc(); const videoClientSize = useVideoStore( (state: VideoState) => `${Math.round(state.clientWidth)}x${Math.round(state.clientHeight)}`, ); const videoSize = useVideoStore( (state: VideoState) => `${Math.round(state.width)}x${Math.round(state.height)}`, ); const { debugMode, mouseMode, showPressedKeys } = useSettingsStore(); const { isPasteInProgress } = useHidStore(); const { keyboardLedState, usbState } = useHidStore(); const { isTurnServerInUse } = useRTCStore(); const { hdmiState } = useVideoStore(); const displayKeys = useMemo(() => { if (!showPressedKeys) return ""; const activeModifierMask = keysDownState.modifier || 0; const keysDown = keysDownState.keys || []; const modifierNames = Object.entries(modifiers) .filter(([_, mask]) => (activeModifierMask & mask) !== 0) .map(([name]) => name); const keyNames = Object.entries(keys) .filter(([_, value]) => keysDown.includes(value)) .map(([name]) => name); return [...modifierNames, ...keyNames].join(", "); }, [keysDownState, showPressedKeys]); return (