// Copyright (C) 2017-2026 Smart code 203358507 import React, { useEffect } from 'react'; import { createPortal } from 'react-dom'; import { useTranslation } from 'react-i18next'; import Icon from '@stremio/stremio-icons/react'; import { Button } from 'stremio/components'; import { useGamepad } from 'stremio/services'; import GamepadDiagram from './GamepadDiagram'; import styles from './styles.less'; const CROSS = '✕'; const CIRCLE = '○'; const TRIANGLE = '△'; const SQUARE = '□'; const L_STICK = 'L stick'; const R_STICK = 'R stick'; const L1 = 'L1'; const R1 = 'R1'; const LEFT = '←'; const RIGHT = '→'; const UP = '↑'; const DOWN = '↓'; type Props = { onClose: () => void, }; const GamepadModal = ({ onClose }: Props) => { const { t } = useTranslation(); const gamepad = useGamepad(); useEffect(() => { const onKeyDown = ({ key }: KeyboardEvent) => { key === 'Escape' && onClose(); }; document.addEventListener('keydown', onKeyDown); gamepad?.on('buttonB', 'gamepad-modal', onClose); return () => { document.removeEventListener('keydown', onKeyDown); gamepad?.off('buttonB', 'gamepad-modal'); }; }, [gamepad]); return createPortal((