NesGamingScheme实现

This commit is contained in:
ALIENJACK\alien 2024-09-23 18:31:05 +08:00
parent d5be477dd8
commit ad021664db
5 changed files with 40 additions and 7 deletions

View File

@ -27,6 +27,6 @@ namespace AxibugEmuOnline.Client.Common
public static KeyCode Up => KeyCode.Joystick1Button8;
public static KeyCode Right => KeyCode.Joystick1Button9;
public static KeyCode Down => KeyCode.Joystick1Button10;
public static KeyCode Left => KeyCode.Joystick1Button11
public static KeyCode Left => KeyCode.Joystick1Button11;
}
}

View File

@ -13,7 +13,9 @@ namespace AxibugEmuOnline.Client
{
m_current = value;
m_current.SetUIKeys(CommandDispatcher.Instance.GetKeyMapper());
Dictionary<KeyCode, EnumCommand> mapper = new Dictionary<KeyCode, EnumCommand>();
m_current.SetUIKeys(mapper);
CommandDispatcher.Instance.SetKeyMapper(mapper);
}
}
@ -21,8 +23,6 @@ namespace AxibugEmuOnline.Client
public virtual void SetUIKeys(Dictionary<KeyCode, EnumCommand> uiKeyMapper)
{
uiKeyMapper.Clear();
uiKeyMapper[KeyCode.A] = EnumCommand.SelectItemLeft;
uiKeyMapper[KeyCode.D] = EnumCommand.SelectItemRight;
uiKeyMapper[KeyCode.W] = EnumCommand.SelectItemUp;
@ -39,6 +39,17 @@ namespace AxibugEmuOnline.Client
uiKeyMapper[KeyCode.Escape] = EnumCommand.Back;
uiKeyMapper[KeyCode.RightShift] = EnumCommand.OptionMenu;
uiKeyMapper[KeyCode.LeftShift] = EnumCommand.OptionMenu;
if (Application.platform == RuntimePlatform.PSP2)
{
uiKeyMapper[Common.PSVitaKey.Left] = EnumCommand.SelectItemLeft;
uiKeyMapper[Common.PSVitaKey.Right] = EnumCommand.SelectItemRight;
uiKeyMapper[Common.PSVitaKey.Up] = EnumCommand.SelectItemUp;
uiKeyMapper[Common.PSVitaKey.Down] = EnumCommand.SelectItemDown;
uiKeyMapper[Common.PSVitaKey.Circle] = EnumCommand.Enter;
uiKeyMapper[Common.PSVitaKey.Cross] = EnumCommand.Back;
uiKeyMapper[Common.PSVitaKey.Triangle] = EnumCommand.OptionMenu;
}
}
}
}

View File

@ -7,7 +7,13 @@ namespace AxibugEmuOnline.Client
{
public override void SetUIKeys(Dictionary<KeyCode, EnumCommand> uiKeyMapper)
{
base.SetUIKeys(uiKeyMapper);
uiKeyMapper[KeyCode.Escape] = EnumCommand.OptionMenu;
if (Application.platform == RuntimePlatform.PSP2)
{
uiKeyMapper[Common.PSVitaKey.L] = EnumCommand.OptionMenu;
uiKeyMapper[Common.PSVitaKey.R] = EnumCommand.OptionMenu;
}
}
}

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using UnityEngine;
@ -14,8 +15,6 @@ namespace AxibugEmuOnline.Client
Dictionary<KeyCode, EnumCommand> m_keyMapper = new Dictionary<KeyCode, EnumCommand>();
public Dictionary<KeyCode, EnumCommand> GetKeyMapper() => m_keyMapper;
private void Awake()
{
Instance = this;
@ -74,6 +73,15 @@ namespace AxibugEmuOnline.Client
}
}
}
if (m_waitMapperSetting != null)
m_keyMapper = m_waitMapperSetting;
}
private Dictionary<KeyCode, EnumCommand> m_waitMapperSetting = null;
public void SetKeyMapper(Dictionary<KeyCode, EnumCommand> mapper)
{
m_waitMapperSetting = mapper;
}
private List<CommandExecuter> peekRegister(List<CommandExecuter> results)
@ -103,12 +111,14 @@ namespace AxibugEmuOnline.Client
return results;
}
#if UNITY_EDITOR
public void GetRegisters(out IReadOnlyList<CommandExecuter> normal, out IReadOnlyList<CommandExecuter> alone)
{
normal = m_register;
alone = m_registerHigh;
}
#endif
}
}

View File

@ -110,6 +110,7 @@ namespace AxibugEmuOnline.Client
}
}
ControlScheme m_lastCS;
public void Pop(List<OptionMenu> menus, int defaultIndex = 0)
{
ReleaseRuntimeMenus();
@ -144,7 +145,10 @@ namespace AxibugEmuOnline.Client
0.3f
).SetEase(Ease.OutCubic);
m_lastCS = ControlScheme.Current;
ControlScheme.Current = ControlSchemeSetts.Normal;
}
}
public void Hide()
@ -172,6 +176,8 @@ namespace AxibugEmuOnline.Client
).SetEase(Ease.OutCubic);
m_bPoped = false;
ControlScheme.Current = m_lastCS;
}
}