import { memo, type CSSProperties } from 'react' import { bindingLabel, compactBindingLabel, type ControllerIconStyle, } from '../input' const FACE_BUTTONS: Record>> = { xbox: { 0: { color: '#107c10', label: 'A' }, 1: { color: '#d13438', label: 'B' }, 2: { color: '#0078d4', label: 'X' }, 3: { color: '#ffb900', label: 'Y' }, }, playstation: { 0: { color: '#0070d1', label: '×' }, 1: { color: '#df0024', label: '○' }, 2: { color: '#f27ab8', label: '□' }, 3: { color: '#00a35a', label: '△' }, }, nintendo: { 0: { color: '#e60012', label: 'B' }, 1: { color: '#e60012', label: 'A' }, 2: { color: '#e60012', label: 'Y' }, 3: { color: '#e60012', label: 'X' }, }, } function faceButtonFor(binding: string, iconStyle: ControllerIconStyle) { if (!binding.startsWith('Button')) return null return FACE_BUTTONS[iconStyle][Number(binding.slice(6))] ?? null } const FaceIcon = memo(function FaceIcon({ color, iconStyle, label, title, }: { color: string iconStyle: ControllerIconStyle label: string title: string }) { return ( {label} ) }) export const ControllerBindingLabel = memo(function ControllerBindingLabel({ binding, compact = false, iconStyle, }: { binding: string compact?: boolean iconStyle: ControllerIconStyle }) { const faceButton = faceButtonFor(binding, iconStyle) const title = bindingLabel(binding, iconStyle) if (faceButton) { return ( ) } return <>{compact ? compactBindingLabel(binding, iconStyle) : title} }) export const ControllerStylePreview = memo(function ControllerStylePreview({ iconStyle }: { iconStyle: ControllerIconStyle }) { return ( ) })