fix: Fixed issues on windows
feat: Implemented mouse and gamepad automatic switching fix: Made touch screen work better on the steam deck
This commit is contained in:
parent
e4df8fb9fb
commit
b4a89385d0
24 changed files with 334 additions and 137 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { GamepadButtonEvent } from '../scripts/gamepads';
|
||||
import useActiveControl, { GamepadButtonEvent } from '../scripts/gamepads';
|
||||
import { GamePadButtonCode, Shortcut } from '../scripts/shortcuts';
|
||||
import ShortcutPrompt from './ShortcutPrompt';
|
||||
import { IconType } from './SvgIcon';
|
||||
|
|
@ -23,16 +23,38 @@ const iconMap: Record<GamePadButtonCode, IconType> = {
|
|||
[GamePadButtonCode.Steam]: 'steamdeck_button_quickaccess'
|
||||
};
|
||||
|
||||
const keyboardMap: Record<GamePadButtonCode, string> = {
|
||||
[GamePadButtonCode.A]: 'ENTER',
|
||||
[GamePadButtonCode.B]: 'ESC',
|
||||
[GamePadButtonCode.X]: 'BACKSPACE',
|
||||
[GamePadButtonCode.Y]: 'SPACE',
|
||||
[GamePadButtonCode.L1]: 'Q',
|
||||
[GamePadButtonCode.R1]: 'E',
|
||||
[GamePadButtonCode.L2]: '',
|
||||
[GamePadButtonCode.R2]: '',
|
||||
[GamePadButtonCode.Select]: '',
|
||||
[GamePadButtonCode.Start]: '',
|
||||
[GamePadButtonCode.LJoy]: '',
|
||||
[GamePadButtonCode.RJoy]: '',
|
||||
[GamePadButtonCode.Up]: '',
|
||||
[GamePadButtonCode.Down]: '',
|
||||
[GamePadButtonCode.Left]: '',
|
||||
[GamePadButtonCode.Right]: '',
|
||||
[GamePadButtonCode.Steam]: ''
|
||||
};
|
||||
|
||||
export default function Shortcuts (data: { shortcuts?: Shortcut[]; })
|
||||
{
|
||||
const { control } = useActiveControl();
|
||||
const showKeyboard = control === 'keyboard' || control === 'mouse';
|
||||
return (
|
||||
<div className="flex gap-2 z-1000">
|
||||
{data.shortcuts?.filter(s => !!s.label).map((s, i) => <ShortcutPrompt
|
||||
key={s.button}
|
||||
id={`shortcut-${s.button}`}
|
||||
onClick={e => s.action?.(new GamepadButtonEvent('gamepadbuttondown', { button: s.button, isClick: true }))}
|
||||
icon={iconMap[s.button]}
|
||||
label={s.label} />
|
||||
icon={showKeyboard ? undefined : iconMap[s.button]}
|
||||
label={showKeyboard ? `${keyboardMap[s.button]} | ${s.label}` : s.label} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue