Skip to content

Commit

Permalink
Only allow selecting existing profiles in gamepad settings, add profi…
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelsin authored Sep 28, 2024
1 parent e943bd1 commit 209de48
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion www/src/Locales/de-DE/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
'first-win': 'Erster Gewinnt',
off: 'Aus',
},
'profile-number-label': 'Profil Nummer',
'profile-label': 'Profil',
'debounce-delay-label': 'Entprellverzögerung in Millisekunden',
'hotkey-settings-label': 'Hotkey Einstellungen',
'hotkey-settings-sub-header':
Expand Down
2 changes: 1 addition & 1 deletion www/src/Locales/en/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default {
'first-win': 'First Win',
off: 'Off',
},
'profile-number-label': 'Profile Number',
'profile-label': 'Profile',
'debounce-delay-label': 'Debounce Delay in milliseconds',
'ps4-mode-explanation-text':
'PS4 mode allows GP2040-CE to run as an authenticated PS4 controller.',
Expand Down
2 changes: 1 addition & 1 deletion www/src/Locales/ja-JP/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default {
'first-win': '先入力優先',
off: '無効',
},
'profile-number-label': 'プロファイル番号',
'profile-label': 'プロファイル',
'debounce-delay-label': 'チャタリング除去ディレイ(ミリ秒)',
'ps4-mode-explanation-text':
'PS4モードはGP2040-CEコントローラを認証済みPS4コントローラとして動作させることができます。',
Expand Down
2 changes: 1 addition & 1 deletion www/src/Locales/pt-BR/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
'first-win': 'Primeira Vitória',
off: 'Desativado',
},
'profile-number-label': 'Número de Perfil',
'profile-label': 'Perfil',
'hotkey-settings-label': 'Configurações de Teclas de Atalho',
'hotkey-settings-sub-header':
'O controle deslizante <strong>Fn</strong> fornece um botão de função mapeável na página de <link_pinmap>Mapeamento de Pinos</link_pinmap>. Ao selecionar a opção de controle deslizante <strong>Fn</strong>, o botão de função deve ser mantido junto com as configurações de teclas de atalho selecionadas.<br />Além disso, selecione <strong>Nenhum</strong> no menu suspenso para desatribuir qualquer botão.',
Expand Down
1 change: 0 additions & 1 deletion www/src/Locales/zh-CN/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default {
'first-win': '先输入优先',
off: '关闭',
},
'profile-number-label': '档案编号',
'debounce-delay-label': '去抖动延迟 (以毫秒为单位)',
'ps4-mode-explanation-text':
'PS4 模式允许 GP2040-CE 作为经过认证的 PS4 控制器运行。',
Expand Down
32 changes: 23 additions & 9 deletions www/src/Pages/SettingsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import * as yup from 'yup';
import { Trans, useTranslation } from 'react-i18next';
import JSEncrypt from 'jsencrypt';
import isNil from 'lodash/isNil';
import ContextualHelpOverlay from '../Components/ContextualHelpOverlay';

import useProfilesStore from '../Store/useProfilesStore';
import { AppContext } from '../Contexts/AppContext';

import ContextualHelpOverlay from '../Components/ContextualHelpOverlay';
import KeyboardMapper, { validateMappings } from '../Components/KeyboardMapper';
import Section from '../Components/Section';
import WebApi, { baseButtonMappings } from '../Services/WebApi';
Expand Down Expand Up @@ -120,7 +122,8 @@ const SHA256 = (ascii) => {
};

const INPUT_MODES = [
{ labelKey: 'input-mode-options.xinput',
{
labelKey: 'input-mode-options.xinput',
value: 0,
group: 'primary',
optional: ['usb'],
Expand Down Expand Up @@ -476,11 +479,17 @@ export default function SettingsPage() {
buttonLabels,
setButtonLabels,
getAvailablePeripherals,
getSelectedPeripheral,
getAvailableAddons,
updateAddons,
updatePeripherals,
} = useContext(AppContext);

const fetchProfiles = useProfilesStore((state) => state.fetchProfiles);
const profiles = useProfilesStore((state) => state.profiles);

useEffect(() => {
fetchProfiles();
}, []);

const [saveMessage, setSaveMessage] = useState('');
const [warning, setWarning] = useState({ show: false, acceptText: '' });
const [validated, setValidated] = useState(false);
Expand Down Expand Up @@ -1312,7 +1321,7 @@ export default function SettingsPage() {
</Form.Group>
<Form.Group className="row mb-3">
<Form.Label>
{t('SettingsPage:profile-number-label')}
{t('SettingsPage:profile-label')}
</Form.Label>
<Col sm={3}>
<Form.Select
Expand All @@ -1322,12 +1331,17 @@ export default function SettingsPage() {
onChange={handleChange}
isInvalid={errors.profileNumber}
>
{[1, 2, 3, 4].map((i) => (
{profiles.map((profile, index) => (
<option
key={`button-profileNumber-option-${i}`}
value={i}
key={`button-profileNumber-option-${
index + 1
}`}
value={index + 1}
>
{i}
{profile.profileLabel ||
t('PinMapping:profile-label-default', {
profileNumber: index + 1,
})}
</option>
))}
</Form.Select>
Expand Down

0 comments on commit 209de48

Please sign in to comment.