import { useEffect, useState, type RefObject, type CSSProperties } from "react"; import { neutralAxes, type OperatorAxes } from "../lib/operator-input"; /** 显示已提交的客户端通道值;不把它描述为串口回执或真实机构速度。 */ export function OperatorMapping({ source, synthetic }: { source: RefObject; synthetic: boolean }) { const [axes, setAxes] = useState(neutralAxes); useEffect(() => { const timer = window.setInterval(() => setAxes({ ...source.current }), 40); return () => window.clearInterval(timer); }, [source]); const channels = [["CH0", "W / S", "前后", axes.forward], ["CH1", "A / D", "左右", axes.strafe], ["CH2", "MOUSE X", "水平", axes.yaw], ["CH3", "MOUSE Y", "俯仰", axes.pitch]] as const; return
CONTROL / MAPPING{synthetic ? "合成输入" : "客户端输入"}
键鼠→UDP→C3 / UART
{channels.map(([id, input, label, value]) =>
{input}{id} / {label}{value > 0 ? "+" : ""}{value}
)}
LMB → FIRE {Number(axes.fire)}±1000 · 速度比例ESC 退出
; }