import { clsx } from "clsx"; import { useState } from "react"; import { BUTTON_CAPABILITIES } from "@/constants/controls"; import { Badge } from "@/components/common/Badge"; import { Button } from "@/components/common/Button"; import { Panel } from "@/components/common/Panel"; import { ControllerDiagram, type ControllerView } from "@/components/controller/ControllerDiagram"; import { PageShell } from "@/components/layout/PageShell"; import { EventLog } from "@/components/visualizations/EventLog"; import { mockControllerBackend } from "@/services/mockControllerBackend"; import { useControllerStore } from "@/stores/controllerStore"; import { useProfileStore } from "@/stores/profileStore"; export function InputTester() { const [view, setView] = useState("front"); const activeController = useControllerStore((s) => s.activeController()); const liveState = useControllerStore((s) => s.liveState); const eventLog = useControllerStore((s) => s.eventLog); const pollRateHz = useControllerStore((s) => s.pollRateHz); const latencyEstimateMs = useControllerStore((s) => s.latencyEstimateMs); const clearEventLog = useControllerStore((s) => s.clearEventLog); const activeProfile = useProfileStore((s) => s.activeProfile); const buttons = liveState?.buttons ?? {}; const axes = liveState?.axes ?? {}; const hasGyro = activeController?.capabilities.hasGyro ?? false; return (
Active profile
{activeProfile?.name ?? "—"}
Poll rate
{pollRateHz ? `${pollRateHz} Hz` : "—"}
Latency estimate
{latencyEstimateMs ? `${latencyEstimateMs} ms` : "—"}
Controller
{activeController ? "Connected" : "None"}
left_stick_x
{(axes.left_stick_x ?? 0).toFixed(3)}
left_stick_y
{(axes.left_stick_y ?? 0).toFixed(3)}
right_stick_x
{(axes.right_stick_x ?? 0).toFixed(3)}
right_stick_y
{(axes.right_stick_y ?? 0).toFixed(3)}
left_trigger
{(axes.left_trigger ?? 0).toFixed(3)}
right_trigger
{(axes.right_trigger ?? 0).toFixed(3)}
{hasGyro ? ( <>
gyro_x
{(axes.gyro_x ?? 0).toFixed(3)}
gyro_y
{(axes.gyro_y ?? 0).toFixed(3)}
gyro_z
{(axes.gyro_z ?? 0).toFixed(3)}
) : (
No gyroscope detected
)}
} >
mockControllerBackend.pulseButton(id)} />
{BUTTON_CAPABILITIES.map((button) => { const pressed = Boolean(buttons[button.id]); return ( ); })}
} >
); }