// 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((
{t('GAMEPAD_CONTROLS_TITLE')}
{t('GAMEPAD_SECTION_NAVIGATION')}
{L_STICK} {t('GAMEPAD_ACTION_NAVIGATE')}
{CROSS} {t('GAMEPAD_ACTION_SELECT')}
{CIRCLE} {t('GAMEPAD_ACTION_BACK')}
{TRIANGLE} {t('GAMEPAD_ACTION_FULLSCREEN')}
{SQUARE} {t('GAMEPAD_ACTION_GUIDE')}
{L1} {t('GAMEPAD_ACTION_PREV_TAB')}
{R1} {t('GAMEPAD_ACTION_NEXT_TAB')}
{t('GAMEPAD_SECTION_PLAYER')}
{SQUARE} {t('GAMEPAD_ACTION_PLAY_PAUSE')}
{R_STICK} {LEFT} {t('GAMEPAD_ACTION_SEEK_BACK')}
{R_STICK} {RIGHT} {t('GAMEPAD_ACTION_SEEK_FWD')}
{R_STICK} {UP} {t('GAMEPAD_ACTION_VOL_UP')}
{R_STICK} {DOWN} {t('GAMEPAD_ACTION_VOL_DOWN')}
), document.body); }; export default GamepadModal;