forked from sin365/AxibugEmuOnline
InputManager迭代
This commit is contained in:
parent
a93f6449c8
commit
811b0b2a48
@ -23,8 +23,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
public static AppLogin login;
|
||||
public static AppChat chat;
|
||||
public static UserDataManager user;
|
||||
public static AppInput input;
|
||||
public static InputDevicesManager inputDevicesMgr;
|
||||
public static InputDevicesManager input;
|
||||
public static AppEmu emu;
|
||||
public static HttpAPI httpAPI;
|
||||
public static CacheManager CacheMgr;
|
||||
@ -78,8 +77,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
//其他平台必要的初始化
|
||||
if (UnityEngine.Application.platform == RuntimePlatform.PSP2) PSP2Init();
|
||||
|
||||
input = new AppInput();
|
||||
inputDevicesMgr = new InputDevicesManager();
|
||||
input = new InputDevicesManager();
|
||||
FileDownloader = new FileDownloader();
|
||||
settings = new AppSettings();
|
||||
network = new NetworkHelper();
|
||||
@ -232,7 +230,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
foreach (var romLib in s_romLibs.Values) romLib.ExecuteFetchRomInfo();
|
||||
starRomLib.ExecuteFetchRomInfo();
|
||||
FileDownloader.Update();
|
||||
|
||||
input.Update();
|
||||
}
|
||||
|
||||
public static Coroutine StartCoroutine(IEnumerator itor)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxiInputSP.Setting
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxiInputSP.Setting
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxiInputSP.Setting
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxiInputSP.Setting
|
||||
|
@ -1,24 +1,10 @@
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxiInputSP.Setting
|
||||
{
|
||||
[Flags]
|
||||
public enum EssgeeSingleKey : ushort
|
||||
{
|
||||
NONE = 0,
|
||||
UP = 1,
|
||||
DOWN = 1 << 1,
|
||||
LEFT = 1 << 2,
|
||||
RIGHT = 1 << 3,
|
||||
BTN_1 = 1 << 4,
|
||||
BTN_2 = 1 << 5,
|
||||
BTN_3 = 1 << 6,
|
||||
BTN_4 = 1 << 7,
|
||||
OPTION_1 = 1 << 8,
|
||||
OPTION_2 = 1 << 9,
|
||||
}
|
||||
public class MasterSystemMultiKeysSetting : MultiKeysSettingBase
|
||||
{
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxiInputSP.Setting
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxiInputSP.Setting
|
||||
|
@ -1,23 +1,9 @@
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxiInputSP.Setting
|
||||
{
|
||||
public enum UMAMEKSingleKey
|
||||
{
|
||||
INSERT_COIN,
|
||||
GAMESTART,
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
BTN_A,
|
||||
BTN_B,
|
||||
BTN_C,
|
||||
BTN_D,
|
||||
BTN_E,
|
||||
BTN_F
|
||||
}
|
||||
public class UMAMEMultiKeysSetting : MultiKeysSettingBase
|
||||
{
|
||||
public UMAMEMultiKeysSetting()
|
||||
|
@ -1,7 +1,8 @@
|
||||
using AxibugEmuOnline.Client;
|
||||
using AxibugEmuOnline.Client;
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using AxibugEmuOnline.Client.Manager;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using AxiInputSP.Setting;
|
||||
using AxiReplay;
|
||||
using System;
|
||||
@ -318,7 +319,7 @@ public class UEGKeyboard : MonoBehaviour
|
||||
|
||||
public bool SampleInput()
|
||||
{
|
||||
//Net模式
|
||||
//Net模式
|
||||
if (InGameUI.Instance.IsNetPlay)
|
||||
{
|
||||
bool bHadNetData = false;
|
||||
@ -334,18 +335,18 @@ public class UEGKeyboard : MonoBehaviour
|
||||
SetCurrKeyArr(CurrRemoteInpuAllData);
|
||||
bHadNetData = true;
|
||||
}
|
||||
else//无输入
|
||||
else//无输入
|
||||
{
|
||||
CurrRemoteInpuAllData = 0;
|
||||
}
|
||||
|
||||
//发送本地操作
|
||||
//发送本地操作
|
||||
App.roomMgr.SendRoomSingelPlayerInput(UEssgee.instance.Frame,
|
||||
DoLocalPressedKeys());
|
||||
|
||||
return bHadNetData;
|
||||
}
|
||||
//单机模式
|
||||
//单机模式
|
||||
else
|
||||
{
|
||||
ulong inputData = DoLocalPressedKeys();
|
||||
@ -550,9 +551,9 @@ public class EssgssSingleController : IController
|
||||
uint? mConnectSlot;
|
||||
|
||||
/// <summary>
|
||||
/// 指示该手柄连接的手柄插槽
|
||||
/// <para><c>这个值代表了该手柄在实际游戏中控制的Player</c></para>
|
||||
/// <value>[0,3] 例外:为空代表未连接</value>
|
||||
/// 指示该手柄连接的手柄插槽
|
||||
/// <para><c>这个值代表了该手柄在实际游戏中控制的Player</c></para>
|
||||
/// <value>[0,3] 例外:为空代表未连接</value>
|
||||
/// </summary>
|
||||
public uint? ConnectSlot
|
||||
{
|
||||
@ -561,8 +562,8 @@ public class EssgssSingleController : IController
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制器编号
|
||||
/// <para><c>此编号并非对应游戏中的player1,player2,player3,player4,仅仅作为本地4个手柄的实例</c></para>
|
||||
/// 控制器编号
|
||||
/// <para><c>此编号并非对应游戏中的player1,player2,player3,player4,仅仅作为本地4个手柄的实例</c></para>
|
||||
/// <value>[0,3]</value>
|
||||
/// </summary>
|
||||
public int ControllerIndex
|
||||
@ -578,34 +579,12 @@ public class EssgssSingleController : IController
|
||||
|
||||
public bool AnyButtonDown()
|
||||
{
|
||||
//if (Input.GetKeyDown(UP)) return true;
|
||||
//if (Input.GetKeyDown(DOWN)) return true;
|
||||
//if (Input.GetKeyDown(LEFT)) return true;
|
||||
//if (Input.GetKeyDown(RIGHT)) return true;
|
||||
//if (Input.GetKeyDown(BTN_1)) return true;
|
||||
//if (Input.GetKeyDown(BTN_2)) return true;
|
||||
//if (Input.GetKeyDown(BTN_3)) return true;
|
||||
//if (Input.GetKeyDown(BTN_4)) return true;
|
||||
//if (Input.GetKeyDown(OPTION_1)) return true;
|
||||
//if (Input.GetKeyDown(OPTION_2)) return true;
|
||||
//return false;
|
||||
|
||||
return GetSingleKeys().HadAnyKeyDown();
|
||||
return GetKeyMapper().AnyKeyDown(mControllerIndex);
|
||||
}
|
||||
|
||||
public SingleKeySettingBase GetSingleKeys()
|
||||
public EssgeeKeyBinding GetKeyMapper()
|
||||
{
|
||||
switch (UEssgee.instance.Platform)
|
||||
{
|
||||
case AxibugProtobuf.RomPlatformType.MasterSystem: return App.input.sms.controllers[mControllerIndex];
|
||||
case AxibugProtobuf.RomPlatformType.GameBoy: return App.input.gb.controllers[mControllerIndex];
|
||||
case AxibugProtobuf.RomPlatformType.GameBoyColor: return App.input.gbc.controllers[mControllerIndex];
|
||||
case AxibugProtobuf.RomPlatformType.ColecoVision: return App.input.cv.controllers[mControllerIndex];
|
||||
case AxibugProtobuf.RomPlatformType.GameGear: return App.input.gg.controllers[mControllerIndex];
|
||||
case AxibugProtobuf.RomPlatformType.Sc3000: return App.input.sc3000.controllers[mControllerIndex];
|
||||
case AxibugProtobuf.RomPlatformType.Sg1000: return App.input.sg1000.controllers[mControllerIndex];
|
||||
default: throw new NotImplementedException("err essgee platform");
|
||||
}
|
||||
return App.settings.KeyMapper.GetBinder<EssgeeKeyBinding>(UEssgee.instance.Platform);
|
||||
}
|
||||
|
||||
public ulong GetSingleAllInput()
|
||||
@ -614,29 +593,19 @@ public class EssgssSingleController : IController
|
||||
return 0;
|
||||
CurrLocalSingleAllInput = 0;
|
||||
|
||||
SingleKeySettingBase essgeeKeys = GetSingleKeys();
|
||||
EssgeeKeyBinding essgeeKeys = GetKeyMapper();
|
||||
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.UP)) CurrLocalSingleAllInput |= (ulong)tg_UP;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.DOWN)) CurrLocalSingleAllInput |= (ulong)tg_DOWN;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.LEFT)) CurrLocalSingleAllInput |= (ulong)tg_LEFT;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.RIGHT)) CurrLocalSingleAllInput |= (ulong)tg_RIGHT;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.BTN_1)) CurrLocalSingleAllInput |= (ulong)tg_BTN_1;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.BTN_2)) CurrLocalSingleAllInput |= (ulong)tg_BTN_2;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.BTN_3)) CurrLocalSingleAllInput |= (ulong)tg_BTN_3;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.BTN_4)) CurrLocalSingleAllInput |= (ulong)tg_BTN_4;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.OPTION_1)) CurrLocalSingleAllInput |= (ulong)tg_OPTION_1;
|
||||
if (essgeeKeys.GetKey((ulong)EssgeeSingleKey.OPTION_2)) CurrLocalSingleAllInput |= (ulong)tg_OPTION_2;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.UP, mControllerIndex)) CurrLocalSingleAllInput |= tg_UP;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.DOWN, mControllerIndex)) CurrLocalSingleAllInput |= tg_DOWN;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.LEFT, mControllerIndex)) CurrLocalSingleAllInput |= tg_LEFT;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.RIGHT, mControllerIndex)) CurrLocalSingleAllInput |= tg_RIGHT;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.BTN_1, mControllerIndex)) CurrLocalSingleAllInput |= tg_BTN_1;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.BTN_2, mControllerIndex)) CurrLocalSingleAllInput |= tg_BTN_2;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.BTN_3, mControllerIndex)) CurrLocalSingleAllInput |= tg_BTN_3;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.BTN_4, mControllerIndex)) CurrLocalSingleAllInput |= tg_BTN_4;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.OPTION_1, mControllerIndex)) CurrLocalSingleAllInput |= tg_OPTION_1;
|
||||
if (essgeeKeys.GetKey(EssgeeSingleKey.OPTION_2, mControllerIndex)) CurrLocalSingleAllInput |= tg_OPTION_2;
|
||||
|
||||
//if (Input.GetKey(UP)) CurrLocalSingleAllInput |= (ulong)tg_UP;
|
||||
//if (Input.GetKey(DOWN)) CurrLocalSingleAllInput |= (ulong)tg_DOWN;
|
||||
//if (Input.GetKey(LEFT)) CurrLocalSingleAllInput |= (ulong)tg_LEFT;
|
||||
//if (Input.GetKey(RIGHT)) CurrLocalSingleAllInput |= (ulong)tg_RIGHT;
|
||||
//if (Input.GetKey(BTN_1)) CurrLocalSingleAllInput |= (ulong)tg_BTN_1;
|
||||
//if (Input.GetKey(BTN_2)) CurrLocalSingleAllInput |= (ulong)tg_BTN_2;
|
||||
//if (Input.GetKey(BTN_3)) CurrLocalSingleAllInput |= (ulong)tg_BTN_3;
|
||||
//if (Input.GetKey(BTN_4)) CurrLocalSingleAllInput |= (ulong)tg_BTN_4;
|
||||
//if (Input.GetKey(OPTION_1)) CurrLocalSingleAllInput |= (ulong)tg_OPTION_1;
|
||||
//if (Input.GetKey(OPTION_2)) CurrLocalSingleAllInput |= (ulong)tg_OPTION_1;
|
||||
return CurrLocalSingleAllInput;
|
||||
}
|
||||
}
|
||||
@ -646,7 +615,7 @@ public static class EssgssSingleControllerSetter
|
||||
{
|
||||
//public static void LoadControlKeyForConfig(this EssgssSingleController singlecontrol)
|
||||
//{
|
||||
// //TODO 等待支持配置,或统一
|
||||
// //TODO 等待支持配置,或统一
|
||||
// switch (singlecontrol.ControllerIndex)
|
||||
// {
|
||||
// case 0:
|
||||
|
@ -1,6 +1,7 @@
|
||||
using AxibugEmuOnline.Client;
|
||||
using AxibugEmuOnline.Client;
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using AxiInputSP.Setting;
|
||||
using AxiReplay;
|
||||
using MAME.Core;
|
||||
@ -25,9 +26,9 @@ public class UniKeyboard : MonoBehaviour, IKeyboard
|
||||
public ulong GetPressedKeys()
|
||||
{
|
||||
ulong InputData;
|
||||
if (!bReplayMode)//游玩模式(单机或联机)
|
||||
if (!bReplayMode)//游玩模式(单机或联机)
|
||||
return mPlayMode.GetPressedKeys();
|
||||
else//Replay模式
|
||||
else//Replay模式
|
||||
return mReplayMode.GetPressedKeys();
|
||||
}
|
||||
|
||||
@ -82,7 +83,7 @@ public class UniKeyboard : MonoBehaviour, IKeyboard
|
||||
|
||||
public bool SampleInput()
|
||||
{
|
||||
//Net模式
|
||||
//Net模式
|
||||
if (InGameUI.Instance.IsNetPlay)
|
||||
{
|
||||
bool bHadNetData = false;
|
||||
@ -98,15 +99,15 @@ public class UniKeyboard : MonoBehaviour, IKeyboard
|
||||
|
||||
bHadNetData = true;
|
||||
}
|
||||
else//无输入
|
||||
else//无输入
|
||||
{
|
||||
CurrRemoteInpuAllData = 0;
|
||||
}
|
||||
//发送本地操作
|
||||
//发送本地操作
|
||||
App.roomMgr.SendRoomSingelPlayerInput(UMAME.instance.Frame, DoLocalPressedKeys());
|
||||
return bHadNetData;
|
||||
}
|
||||
//单人模式
|
||||
//单人模式
|
||||
else
|
||||
{
|
||||
DoLocalPressedKeys();
|
||||
@ -135,7 +136,7 @@ public class UniKeyboard : MonoBehaviour, IKeyboard
|
||||
#endif
|
||||
|
||||
CurrLocalInpuAllData = tempLocalInputAllData;
|
||||
//写入replay
|
||||
//写入replay
|
||||
UMAME.instance.mReplayWriter.NextFramebyFrameIdx((int)UMAME.instance.mUniVideoPlayer.mFrame, CurrLocalInpuAllData);
|
||||
|
||||
CheckPlayerSlotChanged();
|
||||
@ -146,16 +147,16 @@ public class UniKeyboard : MonoBehaviour, IKeyboard
|
||||
|
||||
void CheckPlayerSlotChanged()
|
||||
{
|
||||
if (!mUniKeyboard.ControllerMapper.Controller0.ConnectSlot.HasValue && mUniKeyboard.ControllerMapper.Controller0.AnyButtonDown())
|
||||
if (!mUniKeyboard.ControllerMapper.Controller0.ConnectSlot.HasValue && mUniKeyboard.ControllerMapper.Controller0.AnyButtonDown())
|
||||
Eventer.Instance.PostEvent(EEvent.OnLocalJoyDesireInvert, 0);
|
||||
|
||||
if (!mUniKeyboard.ControllerMapper.Controller1.ConnectSlot.HasValue && mUniKeyboard.ControllerMapper.Controller1.AnyButtonDown())
|
||||
Eventer.Instance.PostEvent(EEvent.OnLocalJoyDesireInvert, 1);
|
||||
|
||||
if (!mUniKeyboard.ControllerMapper.Controller2.ConnectSlot.HasValue && mUniKeyboard.ControllerMapper.Controller2.AnyButtonDown())
|
||||
Eventer.Instance.PostEvent(EEvent.OnLocalJoyDesireInvert, 2);
|
||||
|
||||
if (!mUniKeyboard.ControllerMapper.Controller3.ConnectSlot.HasValue && mUniKeyboard.ControllerMapper.Controller3.AnyButtonDown())
|
||||
if (!mUniKeyboard.ControllerMapper.Controller1.ConnectSlot.HasValue && mUniKeyboard.ControllerMapper.Controller1.AnyButtonDown())
|
||||
Eventer.Instance.PostEvent(EEvent.OnLocalJoyDesireInvert, 1);
|
||||
|
||||
if (!mUniKeyboard.ControllerMapper.Controller2.ConnectSlot.HasValue && mUniKeyboard.ControllerMapper.Controller2.AnyButtonDown())
|
||||
Eventer.Instance.PostEvent(EEvent.OnLocalJoyDesireInvert, 2);
|
||||
|
||||
if (!mUniKeyboard.ControllerMapper.Controller3.ConnectSlot.HasValue && mUniKeyboard.ControllerMapper.Controller3.AnyButtonDown())
|
||||
Eventer.Instance.PostEvent(EEvent.OnLocalJoyDesireInvert, 3);
|
||||
}
|
||||
|
||||
@ -172,7 +173,7 @@ public class UniKeyboard : MonoBehaviour, IKeyboard
|
||||
{
|
||||
int targetFrame = (int)UMAME.instance.mUniVideoPlayer.mFrame;
|
||||
AxiReplay.ReplayStep stepData;
|
||||
//有变化
|
||||
//有变化
|
||||
if (UMAME.instance.mReplayReader.NextFramebyFrameIdx(targetFrame, out stepData))
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
@ -265,7 +266,7 @@ public class MameControllerMapper : IControllerSetuper
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MAME控制器
|
||||
/// MAME控制器
|
||||
/// </summary>
|
||||
public class MameSingleConoller : IController
|
||||
{
|
||||
@ -277,15 +278,16 @@ public class MameSingleConoller : IController
|
||||
tg_UP, tg_DOWN, tg_LEFT, tg_RIGHT,
|
||||
tg_BTN_A, tg_BTN_B, tg_BTN_C, tg_BTN_D, tg_BTN_E, tg_BTN_F;
|
||||
|
||||
public ulong CurrLocalSingleAllInput { get; private set; }
|
||||
|
||||
public ulong CurrLocalSingleAllInput { get; private set; }
|
||||
|
||||
private MAMEKeyBinding m_keyMapper;
|
||||
int mControllerIndex;
|
||||
uint? mConnectSlot;
|
||||
|
||||
/// <summary>
|
||||
/// 指示该手柄连接的手柄插槽
|
||||
/// <para><c>这个值代表了该手柄在实际游戏中控制的Player</c></para>
|
||||
/// <value>[0,3] 例外:为空代表未连接</value>
|
||||
/// 指示该手柄连接的手柄插槽
|
||||
/// <para><c>这个值代表了该手柄在实际游戏中控制的Player</c></para>
|
||||
/// <value>[0,3] 例外:为空代表未连接</value>
|
||||
/// </summary>
|
||||
public uint? ConnectSlot
|
||||
{
|
||||
@ -294,26 +296,29 @@ public class MameSingleConoller : IController
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制器编号
|
||||
/// <para><c>此编号并非对应游戏中的player1,player2,player3,player4,仅仅作为本地4个手柄的实例</c></para>
|
||||
/// 控制器编号
|
||||
/// <para><c>此编号并非对应游戏中的player1,player2,player3,player4,仅仅作为本地4个手柄的实例</c></para>
|
||||
/// <value>[0,3]</value>
|
||||
/// </summary>
|
||||
public int ControllerIndex
|
||||
{
|
||||
get { return mControllerIndex; }
|
||||
set { mControllerIndex = value;
|
||||
//this.LoadControlKeyForConfig();
|
||||
//走统一配置
|
||||
set
|
||||
{
|
||||
mControllerIndex = value;
|
||||
//this.LoadControlKeyForConfig();
|
||||
//走统一配置
|
||||
}
|
||||
}
|
||||
public MameSingleConoller(int controllerIndex)
|
||||
{
|
||||
ControllerIndex = controllerIndex;
|
||||
m_keyMapper = App.settings.KeyMapper.GetBinder<MAMEKeyBinding>(UMAME.instance.Platform);
|
||||
}
|
||||
|
||||
public bool AnyButtonDown()
|
||||
{
|
||||
return App.input.mame.HadAnyKeyDown(ControllerIndex);
|
||||
return m_keyMapper.AnyKeyDown(ControllerIndex);
|
||||
//if (Input.GetKeyDown(INSERT_COIN)) return true;
|
||||
//if (Input.GetKeyDown(GAMESTART)) return true;
|
||||
//if (Input.GetKeyDown(UP)) return true;
|
||||
@ -334,19 +339,19 @@ public class MameSingleConoller : IController
|
||||
return 0;
|
||||
CurrLocalSingleAllInput = 0;
|
||||
|
||||
var keys = App.input.mame.controllers[ControllerIndex];
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.INSERT_COIN)) CurrLocalSingleAllInput |= (ulong)tg_INSERT_COIN;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.GAMESTART)) CurrLocalSingleAllInput |= (ulong)tg_GAMESTART;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.UP)) CurrLocalSingleAllInput |= (ulong)tg_UP;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.DOWN)) CurrLocalSingleAllInput |= (ulong)tg_DOWN;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.LEFT)) CurrLocalSingleAllInput |= (ulong)tg_LEFT;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.RIGHT)) CurrLocalSingleAllInput |= (ulong)tg_RIGHT;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.BTN_A)) CurrLocalSingleAllInput |= (ulong)tg_BTN_A;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.BTN_B)) CurrLocalSingleAllInput |= (ulong)tg_BTN_B;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.BTN_C)) CurrLocalSingleAllInput |= (ulong)tg_BTN_C;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.BTN_D)) CurrLocalSingleAllInput |= (ulong)tg_BTN_D;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.BTN_E)) CurrLocalSingleAllInput |= (ulong)tg_BTN_E;
|
||||
if (keys.GetKey((ulong)UMAMEKSingleKey.BTN_F)) CurrLocalSingleAllInput |= (ulong)tg_BTN_F;
|
||||
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.INSERT_COIN, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_INSERT_COIN;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.GAMESTART, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_GAMESTART;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.UP, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_UP;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.DOWN, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_DOWN;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.LEFT, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_LEFT;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.RIGHT, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_RIGHT;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.BTN_A, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_BTN_A;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.BTN_B, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_BTN_B;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.BTN_C, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_BTN_C;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.BTN_D, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_BTN_D;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.BTN_E, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_BTN_E;
|
||||
if (m_keyMapper.GetKey(UMAMEKSingleKey.BTN_F, ControllerIndex)) CurrLocalSingleAllInput |= (ulong)tg_BTN_F;
|
||||
|
||||
//if (Input.GetKey(INSERT_COIN)) CurrLocalSingleAllInput |= (ulong)tg_INSERT_COIN;
|
||||
//if (Input.GetKey(GAMESTART)) CurrLocalSingleAllInput |= (ulong)tg_GAMESTART;
|
||||
@ -367,10 +372,10 @@ public class MameSingleConoller : IController
|
||||
}
|
||||
public static class MameSingleControllSetter
|
||||
{
|
||||
//不再需要
|
||||
//不再需要
|
||||
//public static void LoadControlKeyForConfig(this MameSingleConoller singlecontrol)
|
||||
//{
|
||||
// //TODO 等待支持配置,或统一
|
||||
// //TODO 等待支持配置,或统一
|
||||
// switch (singlecontrol.ControllerIndex)
|
||||
// {
|
||||
// case 0:
|
||||
@ -456,7 +461,7 @@ public static class MameSingleControllSetter
|
||||
singlecontrol.tg_BTN_E = MotionKey.P2_BTN_5;
|
||||
singlecontrol.tg_BTN_F = MotionKey.P2_BTN_6;
|
||||
break;
|
||||
//后续修改后 支持P3 P4
|
||||
//后续修改后 支持P3 P4
|
||||
case 2:
|
||||
singlecontrol.tg_INSERT_COIN = MotionKey.FinalKey;
|
||||
singlecontrol.tg_GAMESTART = MotionKey.FinalKey;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Common;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using NUnit.Framework.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -1,3 +1,5 @@
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public static class EventInvoker
|
||||
|
@ -1,4 +1,6 @@
|
||||
namespace AxibugEmuOnline.Client
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class AppSettings
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
namespace AxibugEmuOnline.Client.Settings
|
||||
{
|
||||
/// <summary> 颜色设置 </summary>
|
||||
public class BgColorSettings
|
||||
|
@ -8,7 +8,7 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using static AxibugEmuOnline.Client.FilterEffect;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
namespace AxibugEmuOnline.Client.Settings
|
||||
{
|
||||
public class FilterManager
|
||||
{
|
||||
|
@ -0,0 +1,163 @@
|
||||
using AxibugEmuOnline.Client.InputDevices;
|
||||
using AxibugProtobuf;
|
||||
using AxiInputSP;
|
||||
using System;
|
||||
|
||||
namespace AxibugEmuOnline.Client.Settings
|
||||
{
|
||||
[Flags]
|
||||
public enum EssgeeSingleKey : ushort
|
||||
{
|
||||
NONE = 0,
|
||||
UP = 1,
|
||||
DOWN = 1 << 1,
|
||||
LEFT = 1 << 2,
|
||||
RIGHT = 1 << 3,
|
||||
BTN_1 = 1 << 4,
|
||||
BTN_2 = 1 << 5,
|
||||
BTN_3 = 1 << 6,
|
||||
BTN_4 = 1 << 7,
|
||||
OPTION_1 = 1 << 8,
|
||||
OPTION_2 = 1 << 9,
|
||||
}
|
||||
|
||||
public abstract class EssgeeKeyBinding : EmuCoreControllerKeyBinding<EssgeeSingleKey>
|
||||
{
|
||||
protected override void OnRegistDevices(InputDevice device, BindingPage binding)
|
||||
{
|
||||
if (device is KeyBoard keyboard)
|
||||
{
|
||||
switch (binding.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_1, keyboard.Return, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_2, keyboard.RightShift, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.UP, keyboard.W, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.DOWN, keyboard.S, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.LEFT, keyboard.A, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.RIGHT, keyboard.D, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_1, keyboard.J, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_2, keyboard.K, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_3, keyboard.U, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_4, keyboard.I, 0);
|
||||
break;
|
||||
case 1:
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_1, keyboard.Keypad0, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_2, keyboard.Delete, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.UP, keyboard.UpArrow, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.DOWN, keyboard.DownArrow, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.LEFT, keyboard.LeftArrow, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.RIGHT, keyboard.RightArrow, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_1, keyboard.Keypad1, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_2, keyboard.Keypad2, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_3, keyboard.Keypad3, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_4, keyboard.Keypad4, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (device is PSVController psvCon && binding.ControllerIndex == 0)
|
||||
{
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_1, psvCon.Start, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_2, psvCon.Select, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.UP, psvCon.Up, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.DOWN, psvCon.Down, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.LEFT, psvCon.Left, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.RIGHT, psvCon.Right, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_1, psvCon.Cross, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_2, psvCon.Circle, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_3, psvCon.Square, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_4, psvCon.Triangle, 0);
|
||||
//PSV 摇杆
|
||||
binding.SetBinding(EssgeeSingleKey.UP, psvCon.LeftStick.UP, 1);
|
||||
binding.SetBinding(EssgeeSingleKey.DOWN, psvCon.LeftStick.Down, 1);
|
||||
binding.SetBinding(EssgeeSingleKey.LEFT, psvCon.LeftStick.Left, 1);
|
||||
binding.SetBinding(EssgeeSingleKey.RIGHT, psvCon.LeftStick.Right, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MasterSystemKeyBinding : EssgeeKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.MasterSystem;
|
||||
public override int ControllerCount => 2;
|
||||
}
|
||||
|
||||
public class SG1000KeyBinding : EssgeeKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.Sg1000;
|
||||
public override int ControllerCount => 2;
|
||||
}
|
||||
|
||||
public class ColecoVisionKeyBinding : EssgeeKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.ColecoVision;
|
||||
public override int ControllerCount => 2;
|
||||
}
|
||||
|
||||
public class GameBoyColorKeyBinding : EssgeeKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.GameBoyColor;
|
||||
public override int ControllerCount => 1;
|
||||
|
||||
protected override void OnRegistDevices(InputDevice device, BindingPage binding)
|
||||
{
|
||||
if (device is KeyBoard keyboard)
|
||||
{
|
||||
switch (binding.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_1, keyboard.Return, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_2, keyboard.RightShift, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.UP, keyboard.W, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.DOWN, keyboard.S, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.LEFT, keyboard.A, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.RIGHT, keyboard.D, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_1, keyboard.J, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_2, keyboard.K, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_3, keyboard.U, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_4, keyboard.I, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class GameBoyKeyBinding : EssgeeKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.GameBoy;
|
||||
public override int ControllerCount => 1;
|
||||
|
||||
protected override void OnRegistDevices(InputDevice device, BindingPage binding)
|
||||
{
|
||||
if (device is KeyBoard keyboard)
|
||||
{
|
||||
switch (binding.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_1, keyboard.Return, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.OPTION_2, keyboard.RightShift, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.UP, keyboard.W, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.DOWN, keyboard.S, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.LEFT, keyboard.A, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.RIGHT, keyboard.D, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_1, keyboard.J, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_2, keyboard.K, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_3, keyboard.U, 0);
|
||||
binding.SetBinding(EssgeeSingleKey.BTN_4, keyboard.I, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GameGearKeyBinding : EssgeeKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.GameGear;
|
||||
public override int ControllerCount => 2;
|
||||
}
|
||||
|
||||
public class SC3000KeyBinding : EssgeeKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.Sc3000;
|
||||
public override int ControllerCount => 2;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f55743cde04853247be4bd9f7681edf4
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
namespace AxibugEmuOnline.Client.Settings
|
||||
{
|
||||
/// <summary>
|
||||
/// 管理键位映射设置
|
||||
@ -34,6 +34,12 @@ namespace AxibugEmuOnline.Client
|
||||
m_bindersByType.TryGetValue(typeof(T), out var binder);
|
||||
return binder as T;
|
||||
}
|
||||
|
||||
public T GetBinder<T>(RomPlatformType romType) where T : EmuCoreControllerKeyBinding
|
||||
{
|
||||
m_binders.TryGetValue(romType, out var binder);
|
||||
return binder as T;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -55,7 +61,6 @@ namespace AxibugEmuOnline.Client
|
||||
where T : Enum
|
||||
{
|
||||
List<BindingPage> m_bindingPages = new List<BindingPage>();
|
||||
KeyBoard m_currentKeyboard;
|
||||
|
||||
public EmuCoreControllerKeyBinding()
|
||||
{
|
||||
@ -63,30 +68,56 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
m_bindingPages.Add(new BindingPage(i, this));
|
||||
}
|
||||
m_currentKeyboard = App.inputDevicesMgr.GetKeyboard();
|
||||
|
||||
if (m_currentKeyboard != null)
|
||||
LoadKeyboardMapper();
|
||||
var keyboard = App.input.GetDevice<KeyBoard>();
|
||||
if (keyboard != null)
|
||||
{
|
||||
foreach (var binding in m_bindingPages)
|
||||
{
|
||||
binding.RegistInputDevice(keyboard);
|
||||
}
|
||||
}
|
||||
|
||||
App.inputDevicesMgr.OnDeviceLost += InputDevicesMgr_OnDeviceLost;
|
||||
App.inputDevicesMgr.OnDeviceConnected += InputDevicesMgr_OnDeviceConnected;
|
||||
var psvController = App.input.GetDevice<PSVController>();
|
||||
if (psvController != null)
|
||||
{
|
||||
foreach (var binding in m_bindingPages)
|
||||
{
|
||||
binding.RegistInputDevice(psvController);
|
||||
}
|
||||
}
|
||||
|
||||
App.input.OnDeviceLost += InputDevicesMgr_OnDeviceLost;
|
||||
App.input.OnDeviceConnected += InputDevicesMgr_OnDeviceConnected;
|
||||
}
|
||||
|
||||
private void InputDevicesMgr_OnDeviceConnected(InputDevice connectDevice)
|
||||
{
|
||||
if (m_currentKeyboard == null && connectDevice is KeyBoard) //未建立键盘按键映射设置时,并且有新的键盘连接时,建立键盘映射设置
|
||||
if (connectDevice is KeyBoard)
|
||||
{
|
||||
m_currentKeyboard = connectDevice as KeyBoard;
|
||||
LoadKeyboardMapper();
|
||||
foreach (var binding in m_bindingPages)
|
||||
{
|
||||
binding.RegistInputDevice(connectDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InputDevicesMgr_OnDeviceLost(InputDevice lostDevice)
|
||||
{
|
||||
if (lostDevice == m_currentKeyboard) //当前键盘设备丢失,与其他键盘重新建立连接
|
||||
foreach (var binding in m_bindingPages)
|
||||
{
|
||||
m_currentKeyboard = App.inputDevicesMgr.GetKeyboard();
|
||||
LoadKeyboardMapper();
|
||||
binding.UnregistInputDevice(lostDevice);
|
||||
}
|
||||
if (lostDevice is KeyBoard) //键盘丢失,立即查找还存在的键盘并建立连接
|
||||
{
|
||||
var anotherKeyboard = App.input.GetDevice<KeyBoard>();
|
||||
if (anotherKeyboard != null)
|
||||
{
|
||||
foreach (var binding in m_bindingPages)
|
||||
{
|
||||
binding.UnregistInputDevice(lostDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,22 +126,11 @@ namespace AxibugEmuOnline.Client
|
||||
return Enum.GetValues(typeof(T)).Cast<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载键盘映射配置
|
||||
/// </summary>
|
||||
void LoadKeyboardMapper()
|
||||
internal void RaiseDeviceRegist(InputDevice device, BindingPage binding)
|
||||
{
|
||||
foreach (var binding in m_bindingPages)
|
||||
{
|
||||
binding.ClearKeyboardBinding();
|
||||
if (m_currentKeyboard != null) OnLoadKeyboardMapper(m_currentKeyboard, binding);
|
||||
}
|
||||
OnRegistDevices(device, binding);
|
||||
}
|
||||
|
||||
/// <summary> 当加载键盘映射设置时触发 </summary>
|
||||
/// <param name="keyboard"></param>
|
||||
/// <param name="binding"></param>
|
||||
protected abstract void OnLoadKeyboardMapper(KeyBoard keyboard, BindingPage binding);
|
||||
protected abstract void OnRegistDevices(InputDevice device, BindingPage binding);
|
||||
|
||||
public bool Start(T emuControl, int controllerIndex)
|
||||
{
|
||||
@ -214,6 +234,7 @@ namespace AxibugEmuOnline.Client
|
||||
public class BindingPage
|
||||
{
|
||||
Dictionary<T, List<InputDevice.InputControl>> m_mapSetting = new Dictionary<T, List<InputDevice.InputControl>>();
|
||||
Dictionary<Type, InputDevice> m_registedDevices = new Dictionary<Type, InputDevice>();
|
||||
|
||||
public int ControllerIndex { get; }
|
||||
public EmuCoreControllerKeyBinding<T> Host { get; }
|
||||
@ -227,17 +248,38 @@ namespace AxibugEmuOnline.Client
|
||||
m_mapSetting[emuBtn] = new List<InputDevice.InputControl>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除与键盘设备建立的绑定设置
|
||||
/// </summary>
|
||||
internal void ClearKeyboardBinding()
|
||||
internal bool IsRegisted<DEVICE>() where DEVICE : InputDevice
|
||||
{
|
||||
var type = typeof(T);
|
||||
return IsRegisted(type);
|
||||
}
|
||||
internal bool IsRegisted(Type deviceType)
|
||||
{
|
||||
return m_registedDevices.ContainsKey(deviceType);
|
||||
}
|
||||
|
||||
internal void RegistInputDevice(InputDevice device)
|
||||
{
|
||||
var type = device.GetType();
|
||||
if (IsRegisted(type)) return;
|
||||
|
||||
m_registedDevices.Add(type, device);
|
||||
Host.RaiseDeviceRegist(device, this);
|
||||
}
|
||||
|
||||
internal void UnregistInputDevice(InputDevice device)
|
||||
{
|
||||
var type = device.GetType();
|
||||
if (!IsRegisted(type)) return;
|
||||
|
||||
m_registedDevices.Remove(type);
|
||||
|
||||
foreach (var list in m_mapSetting.Values)
|
||||
{
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
var inputControl = list[i];
|
||||
if (inputControl.Device is KeyBoard)
|
||||
if (inputControl.Device == device)
|
||||
{
|
||||
list.RemoveAt(i);
|
||||
i--;
|
||||
@ -248,6 +290,11 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void SetBinding(T emuBtn, InputDevice.InputControl key, int settingSlot)
|
||||
{
|
||||
var device = key.Device;
|
||||
m_registedDevices.TryGetValue(device.GetType(), out var inputDevice);
|
||||
|
||||
Debug.Assert(inputDevice == device);
|
||||
|
||||
var settingList = m_mapSetting[emuBtn];
|
||||
|
||||
int needFixCount = settingSlot - settingList.Count + 1;
|
||||
|
@ -0,0 +1,89 @@
|
||||
using AxibugEmuOnline.Client.InputDevices;
|
||||
using AxibugProtobuf;
|
||||
|
||||
namespace AxibugEmuOnline.Client.Settings
|
||||
{
|
||||
public enum UMAMEKSingleKey
|
||||
{
|
||||
INSERT_COIN,
|
||||
GAMESTART,
|
||||
UP,
|
||||
DOWN,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
BTN_A,
|
||||
BTN_B,
|
||||
BTN_C,
|
||||
BTN_D,
|
||||
BTN_E,
|
||||
BTN_F
|
||||
}
|
||||
|
||||
public abstract class MAMEKeyBinding : EmuCoreControllerKeyBinding<UMAMEKSingleKey>
|
||||
{
|
||||
public override int ControllerCount => 4;
|
||||
|
||||
protected override void OnRegistDevices(InputDevice device, BindingPage binding)
|
||||
{
|
||||
if (device is KeyBoard keyboard)
|
||||
{
|
||||
switch (binding.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
binding.SetBinding(UMAMEKSingleKey.INSERT_COIN, keyboard.Q, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.GAMESTART, keyboard.E, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.UP, keyboard.W, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.DOWN, keyboard.S, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.LEFT, keyboard.A, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.RIGHT, keyboard.D, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_A, keyboard.J, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_B, keyboard.K, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_C, keyboard.L, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_D, keyboard.U, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_E, keyboard.I, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_F, keyboard.O, 0);
|
||||
break;
|
||||
case 1:
|
||||
binding.SetBinding(UMAMEKSingleKey.INSERT_COIN, keyboard.Delete, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.GAMESTART, keyboard.PageDown, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.UP, keyboard.UpArrow, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.DOWN, keyboard.DownArrow, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.LEFT, keyboard.LeftArrow, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.RIGHT, keyboard.RightArrow, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_A, keyboard.Keypad1, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_B, keyboard.Keypad2, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_C, keyboard.Keypad3, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_D, keyboard.Keypad4, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_E, keyboard.Keypad5, 0);
|
||||
binding.SetBinding(UMAMEKSingleKey.BTN_F, keyboard.Keypad6, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NEOGEOKeyBinding : MAMEKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.Neogeo;
|
||||
}
|
||||
|
||||
public class CPS1KeyBinding : MAMEKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.Cps1;
|
||||
}
|
||||
|
||||
public class CPS2KeyBinding : MAMEKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.Cps2;
|
||||
}
|
||||
|
||||
public class IGSKeyBinding : MAMEKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.Igs;
|
||||
}
|
||||
|
||||
public class OldArcadeKeyBinding : MAMEKeyBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.ArcadeOld;
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef759672134881f4ca7df82e984a8c87
|
@ -1,40 +1,42 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.InputDevices;
|
||||
using AxibugEmuOnline.Client.InputDevices;
|
||||
using AxibugProtobuf;
|
||||
using VirtualNes.Core;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
namespace AxibugEmuOnline.Client.Settings
|
||||
{
|
||||
public class NesKeyBinding : EmuCoreControllerKeyBinding<EnumButtonType>
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.Nes;
|
||||
public override int ControllerCount => 4;
|
||||
|
||||
protected override void OnLoadKeyboardMapper(KeyBoard keyboard, BindingPage binding)
|
||||
protected override void OnRegistDevices(InputDevice device, BindingPage binding)
|
||||
{
|
||||
switch (binding.ControllerIndex)
|
||||
if (device is KeyBoard keyboard)
|
||||
{
|
||||
case 0:
|
||||
binding.SetBinding(EnumButtonType.LEFT, keyboard.A, 0);
|
||||
binding.SetBinding(EnumButtonType.RIGHT, keyboard.D, 0);
|
||||
binding.SetBinding(EnumButtonType.UP, keyboard.W, 0);
|
||||
binding.SetBinding(EnumButtonType.DOWN, keyboard.S, 0);
|
||||
binding.SetBinding(EnumButtonType.A, keyboard.K, 0);
|
||||
binding.SetBinding(EnumButtonType.B, keyboard.J, 0);
|
||||
binding.SetBinding(EnumButtonType.SELECT, keyboard.V, 0);
|
||||
binding.SetBinding(EnumButtonType.START, keyboard.B, 0);
|
||||
binding.SetBinding(EnumButtonType.MIC, keyboard.M, 0);
|
||||
break;
|
||||
case 1:
|
||||
binding.SetBinding(EnumButtonType.UP, keyboard.UpArrow, 0);
|
||||
binding.SetBinding(EnumButtonType.DOWN, keyboard.DownArrow, 0);
|
||||
binding.SetBinding(EnumButtonType.LEFT, keyboard.LeftArrow, 0);
|
||||
binding.SetBinding(EnumButtonType.RIGHT, keyboard.RightArrow, 0);
|
||||
binding.SetBinding(EnumButtonType.A, keyboard.Keypad2, 0);
|
||||
binding.SetBinding(EnumButtonType.B, keyboard.Keypad1, 0);
|
||||
binding.SetBinding(EnumButtonType.SELECT, keyboard.Keypad0, 0);
|
||||
binding.SetBinding(EnumButtonType.START, keyboard.KeypadPeriod, 0);
|
||||
break;
|
||||
switch (binding.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
binding.SetBinding(EnumButtonType.LEFT, keyboard.A, 0);
|
||||
binding.SetBinding(EnumButtonType.RIGHT, keyboard.D, 0);
|
||||
binding.SetBinding(EnumButtonType.UP, keyboard.W, 0);
|
||||
binding.SetBinding(EnumButtonType.DOWN, keyboard.S, 0);
|
||||
binding.SetBinding(EnumButtonType.A, keyboard.K, 0);
|
||||
binding.SetBinding(EnumButtonType.B, keyboard.J, 0);
|
||||
binding.SetBinding(EnumButtonType.SELECT, keyboard.V, 0);
|
||||
binding.SetBinding(EnumButtonType.START, keyboard.B, 0);
|
||||
binding.SetBinding(EnumButtonType.MIC, keyboard.M, 0);
|
||||
break;
|
||||
case 1:
|
||||
binding.SetBinding(EnumButtonType.UP, keyboard.UpArrow, 0);
|
||||
binding.SetBinding(EnumButtonType.DOWN, keyboard.DownArrow, 0);
|
||||
binding.SetBinding(EnumButtonType.LEFT, keyboard.LeftArrow, 0);
|
||||
binding.SetBinding(EnumButtonType.RIGHT, keyboard.RightArrow, 0);
|
||||
binding.SetBinding(EnumButtonType.A, keyboard.Keypad2, 0);
|
||||
binding.SetBinding(EnumButtonType.B, keyboard.Keypad1, 0);
|
||||
binding.SetBinding(EnumButtonType.SELECT, keyboard.Keypad0, 0);
|
||||
binding.SetBinding(EnumButtonType.START, keyboard.KeypadPeriod, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.InputDevices;
|
||||
using AxibugEmuOnline.Client.InputDevices;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using AxibugProtobuf;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
@ -9,36 +9,38 @@ namespace AxibugEmuOnline.Client
|
||||
public override RomPlatformType Platform => RomPlatformType.Invalid;
|
||||
public override int ControllerCount => 2;
|
||||
|
||||
protected override void OnLoadKeyboardMapper(KeyBoard keyboard, BindingPage binding)
|
||||
protected override void OnRegistDevices(InputDevice device, BindingPage binding)
|
||||
{
|
||||
switch (binding.ControllerIndex)
|
||||
if (device is KeyBoard keyboard)
|
||||
{
|
||||
case 0://设置标准UI控制
|
||||
//第一套控制布局 WSAD+JKLI
|
||||
binding.SetBinding(EnumCommand.Back, keyboard.L, 0);
|
||||
binding.SetBinding(EnumCommand.Enter, keyboard.K, 0);
|
||||
binding.SetBinding(EnumCommand.OptionMenu, keyboard.I, 0);
|
||||
binding.SetBinding(EnumCommand.SelectItemDown, keyboard.S, 0);
|
||||
binding.SetBinding(EnumCommand.SelectItemLeft, keyboard.A, 0);
|
||||
binding.SetBinding(EnumCommand.SelectItemRight, keyboard.D, 0);
|
||||
binding.SetBinding(EnumCommand.SelectItemUp, keyboard.W, 0);
|
||||
switch (binding.ControllerIndex)
|
||||
{
|
||||
case 0://设置标准UI控制
|
||||
//第一套控制布局 WSAD+JKLI
|
||||
binding.SetBinding(EnumCommand.Back, keyboard.L, 0);
|
||||
binding.SetBinding(EnumCommand.Enter, keyboard.K, 0);
|
||||
binding.SetBinding(EnumCommand.OptionMenu, keyboard.I, 0);
|
||||
binding.SetBinding(EnumCommand.SelectItemDown, keyboard.S, 0);
|
||||
binding.SetBinding(EnumCommand.SelectItemLeft, keyboard.A, 0);
|
||||
binding.SetBinding(EnumCommand.SelectItemRight, keyboard.D, 0);
|
||||
binding.SetBinding(EnumCommand.SelectItemUp, keyboard.W, 0);
|
||||
|
||||
//第二套控制布局 LOWB用
|
||||
binding.SetBinding(EnumCommand.Back, keyboard.Escape, 1);
|
||||
binding.SetBinding(EnumCommand.Back, keyboard.Backspace, 2);
|
||||
binding.SetBinding(EnumCommand.Enter, keyboard.Return, 1);
|
||||
binding.SetBinding(EnumCommand.OptionMenu, keyboard.LeftShift, 1);
|
||||
binding.SetBinding(EnumCommand.OptionMenu, keyboard.RightShift, 2);
|
||||
binding.SetBinding(EnumCommand.SelectItemDown, keyboard.DownArrow, 1);
|
||||
binding.SetBinding(EnumCommand.SelectItemLeft, keyboard.LeftArrow, 1);
|
||||
binding.SetBinding(EnumCommand.SelectItemRight, keyboard.RightArrow, 1);
|
||||
binding.SetBinding(EnumCommand.SelectItemUp, keyboard.UpArrow, 1);
|
||||
break;
|
||||
case 1://游戏中UI控制
|
||||
binding.SetBinding(EnumCommand.OptionMenu, keyboard.Escape, 0);
|
||||
break;
|
||||
//第二套控制布局 LOWB用
|
||||
binding.SetBinding(EnumCommand.Back, keyboard.Escape, 1);
|
||||
binding.SetBinding(EnumCommand.Back, keyboard.Backspace, 2);
|
||||
binding.SetBinding(EnumCommand.Enter, keyboard.Return, 1);
|
||||
binding.SetBinding(EnumCommand.OptionMenu, keyboard.LeftShift, 1);
|
||||
binding.SetBinding(EnumCommand.OptionMenu, keyboard.RightShift, 2);
|
||||
binding.SetBinding(EnumCommand.SelectItemDown, keyboard.DownArrow, 1);
|
||||
binding.SetBinding(EnumCommand.SelectItemLeft, keyboard.LeftArrow, 1);
|
||||
binding.SetBinding(EnumCommand.SelectItemRight, keyboard.RightArrow, 1);
|
||||
binding.SetBinding(EnumCommand.SelectItemUp, keyboard.UpArrow, 1);
|
||||
break;
|
||||
case 1://游戏中UI控制
|
||||
binding.SetBinding(EnumCommand.OptionMenu, keyboard.Escape, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
namespace AxibugEmuOnline.Client.Settings
|
||||
{
|
||||
/// <summary>
|
||||
/// 实现模拟器输出画面的比例调整类
|
||||
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c72c157b8f11c634991ba09272065d1e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -13,12 +13,12 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
|
||||
public KeyBoard(InputResolver resolver) : base(resolver) { }
|
||||
|
||||
protected override IEnumerable<InputControl> DefineControls()
|
||||
protected override List<InputControl> DefineControls()
|
||||
{
|
||||
var keys = s_keyboardKeys.Select(kc => new KeyboardKey(kc, this) as InputControl);
|
||||
var keys = s_keyboardKeys.Select(kc => new KeyboardKey(kc, this) as InputControl).ToList();
|
||||
foreach (KeyboardKey key in keys)
|
||||
{
|
||||
m_keyControllerMap[key.m_keycode] = key;
|
||||
m_keyControllerMap.Add(key.m_keycode, key);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
@ -27,8 +27,6 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
{
|
||||
internal KeyCode m_keycode;
|
||||
|
||||
public override bool Start => Device.Resolver.GetKeyDown(Device as KeyBoard, m_keycode);
|
||||
public override bool Release => Device.Resolver.GetKeyUp(Device as KeyBoard, m_keycode);
|
||||
public override bool Performing => Device.Resolver.GetKey(Device as KeyBoard, m_keycode);
|
||||
|
||||
internal KeyboardKey(KeyCode listenKey, KeyBoard keyboard)
|
||||
@ -69,7 +67,6 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
// 功能键 F1-F15
|
||||
KeyCode.F1, KeyCode.F2, KeyCode.F3, KeyCode.F4, KeyCode.F5, KeyCode.F6,
|
||||
KeyCode.F7, KeyCode.F8, KeyCode.F9, KeyCode.F10, KeyCode.F11, KeyCode.F12,
|
||||
KeyCode.F13, KeyCode.F14, KeyCode.F15,
|
||||
|
||||
// 方向键
|
||||
KeyCode.UpArrow, KeyCode.DownArrow, KeyCode.LeftArrow, KeyCode.RightArrow,
|
||||
@ -78,12 +75,12 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
KeyCode.Space, KeyCode.Return, KeyCode.Escape, KeyCode.Tab, KeyCode.Backspace,
|
||||
KeyCode.CapsLock, KeyCode.LeftShift, KeyCode.RightShift, KeyCode.LeftControl,
|
||||
KeyCode.RightControl, KeyCode.LeftAlt, KeyCode.RightAlt, KeyCode.LeftCommand,
|
||||
KeyCode.RightCommand, KeyCode.Menu,
|
||||
KeyCode.RightCommand,
|
||||
|
||||
// 符号键
|
||||
KeyCode.Comma, KeyCode.Period, KeyCode.Slash, KeyCode.BackQuote, KeyCode.Quote,
|
||||
KeyCode.Semicolon, KeyCode.LeftBracket, KeyCode.RightBracket, KeyCode.Backslash,
|
||||
KeyCode.Minus, KeyCode.Equals, KeyCode.Tilde,
|
||||
KeyCode.Minus, KeyCode.Equals,
|
||||
|
||||
// 小键盘
|
||||
KeyCode.Keypad0, KeyCode.Keypad1, KeyCode.Keypad2, KeyCode.Keypad3, KeyCode.Keypad4,
|
||||
@ -94,7 +91,6 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
// 其他标准键
|
||||
KeyCode.Print, KeyCode.Insert, KeyCode.Delete, KeyCode.Home,
|
||||
KeyCode.End, KeyCode.PageUp, KeyCode.PageDown, KeyCode.Pause, KeyCode.ScrollLock,
|
||||
KeyCode.Clear
|
||||
};
|
||||
|
||||
public KeyboardKey A => m_keyControllerMap[KeyCode.A];
|
||||
@ -166,7 +162,6 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
public KeyboardKey RightAlt => m_keyControllerMap[KeyCode.RightAlt];
|
||||
public KeyboardKey LeftCommand => m_keyControllerMap[KeyCode.LeftCommand];
|
||||
public KeyboardKey RightCommand => m_keyControllerMap[KeyCode.RightCommand];
|
||||
public KeyboardKey Menu => m_keyControllerMap[KeyCode.Menu];
|
||||
public KeyboardKey Comma => m_keyControllerMap[KeyCode.Comma];
|
||||
public KeyboardKey Period => m_keyControllerMap[KeyCode.Period];
|
||||
public KeyboardKey Slash => m_keyControllerMap[KeyCode.Slash];
|
||||
@ -178,7 +173,6 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
public KeyboardKey Backslash => m_keyControllerMap[KeyCode.Backslash];
|
||||
public KeyboardKey Minus => m_keyControllerMap[KeyCode.Minus];
|
||||
public KeyboardKey Equals_k => m_keyControllerMap[KeyCode.Equals];
|
||||
public KeyboardKey Tilde => m_keyControllerMap[KeyCode.Tilde];
|
||||
public KeyboardKey Keypad0 => m_keyControllerMap[KeyCode.Keypad0];
|
||||
public KeyboardKey Keypad1 => m_keyControllerMap[KeyCode.Keypad1];
|
||||
public KeyboardKey Keypad2 => m_keyControllerMap[KeyCode.Keypad2];
|
||||
@ -205,7 +199,6 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
public KeyboardKey PageDown => m_keyControllerMap[KeyCode.PageDown];
|
||||
public KeyboardKey Pause => m_keyControllerMap[KeyCode.Pause];
|
||||
public KeyboardKey ScrollLock => m_keyControllerMap[KeyCode.ScrollLock];
|
||||
public KeyboardKey Clear => m_keyControllerMap[KeyCode.Clear];
|
||||
}
|
||||
#endregion
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.InputDevices
|
||||
{
|
||||
public class PSVController : InputDevice
|
||||
{
|
||||
/// <summary> × </summary>
|
||||
public Button Cross { get; private set; }
|
||||
/// <summary> ○ </summary>
|
||||
public Button Circle { get; private set; }
|
||||
/// <summary> □ </summary>
|
||||
public Button Square { get; private set; }
|
||||
/// <summary> △ </summary>
|
||||
public Button Triangle { get; private set; }
|
||||
public Button L { get; private set; }
|
||||
public Button R { get; private set; }
|
||||
public Button Select { get; private set; }
|
||||
public Button Start { get; private set; }
|
||||
public Button Up { get; private set; }
|
||||
public Button Right { get; private set; }
|
||||
public Button Down { get; private set; }
|
||||
public Button Left { get; private set; }
|
||||
|
||||
public Stick LeftStick { get; private set; }
|
||||
public Stick RightStick { get; private set; }
|
||||
|
||||
public PSVController(InputResolver resolver) : base(resolver) { }
|
||||
|
||||
protected override List<InputControl> DefineControls()
|
||||
{
|
||||
List<InputControl> result = new List<InputControl>();
|
||||
|
||||
Cross = new Button(KeyCode.Joystick1Button0, this, "X");
|
||||
Circle = new Button(KeyCode.Joystick1Button1, this, "⭕");
|
||||
Square = new Button(KeyCode.Joystick1Button2, this, "□");
|
||||
Triangle = new Button(KeyCode.Joystick1Button3, this, "△");
|
||||
|
||||
L = new Button(KeyCode.Joystick1Button4, this, "L");
|
||||
R = new Button(KeyCode.Joystick1Button5, this, "R");
|
||||
|
||||
Select = new Button(KeyCode.Joystick1Button6, this, "SELECT");
|
||||
Start = new Button(KeyCode.Joystick1Button7, this, "START");
|
||||
|
||||
Up = new Button(KeyCode.Joystick1Button8, this, "UP");
|
||||
Right = new Button(KeyCode.Joystick1Button9, this, "RIGHT");
|
||||
Down = new Button(KeyCode.Joystick1Button10, this, "DOWN");
|
||||
Left = new Button(KeyCode.Joystick1Button11, this, "LEFT");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public class Button : InputControl
|
||||
{
|
||||
private KeyCode m_keyCode;
|
||||
private string m_controlName;
|
||||
|
||||
public Button(KeyCode keycode, InputDevice device, string controlName) : base(device)
|
||||
{
|
||||
m_keyCode = keycode;
|
||||
m_controlName = controlName;
|
||||
}
|
||||
|
||||
public override bool Performing => Input.GetKey(m_keyCode);
|
||||
|
||||
public override Vector2 GetVector2()
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
public override float GetFlaot()
|
||||
{
|
||||
return Performing ? 1 : 0;
|
||||
}
|
||||
|
||||
public override string ControlName => m_controlName;
|
||||
}
|
||||
|
||||
public class Stick : InputControl
|
||||
{
|
||||
private bool m_left;
|
||||
|
||||
public VirtualButton UP { get; private set; }
|
||||
public VirtualButton Down { get; private set; }
|
||||
public VirtualButton Left { get; private set; }
|
||||
public VirtualButton Right { get; private set; }
|
||||
|
||||
public Stick(InputDevice device, bool left) : base(device)
|
||||
{
|
||||
m_left = left;
|
||||
|
||||
UP = new VirtualButton(device);
|
||||
Down = new VirtualButton(device);
|
||||
Left = new VirtualButton(device);
|
||||
Right = new VirtualButton(device);
|
||||
}
|
||||
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
var axis = GetVector2();
|
||||
|
||||
UP.m_performing = axis.y > 0f;
|
||||
UP.Update();
|
||||
|
||||
Down.m_performing = axis.y < 0f;
|
||||
Down.Update();
|
||||
|
||||
Left.m_performing = axis.x < 0f;
|
||||
Left.Update();
|
||||
|
||||
Right.m_performing = axis.x > 0f;
|
||||
Right.Update();
|
||||
}
|
||||
|
||||
public override bool Performing => GetVector2().x != 0 || GetVector2().y != 0;
|
||||
|
||||
public override Vector2 GetVector2()
|
||||
{
|
||||
Vector2 result = Vector2.zero;
|
||||
|
||||
if (m_left)
|
||||
{
|
||||
result.x = Input.GetAxis("Horizontal");
|
||||
result.y = Input.GetAxis("Vertical");
|
||||
}
|
||||
else
|
||||
{
|
||||
result.x = Input.GetAxis("HorizontalR");
|
||||
result.y = Input.GetAxis("VerticalR");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override float GetFlaot()
|
||||
{
|
||||
return Performing ? 1 : 0;
|
||||
}
|
||||
|
||||
public override string ControlName => $"{nameof(Stick)}_{(m_left ? "left" : "right")}";
|
||||
|
||||
public class VirtualButton : InputControl
|
||||
{
|
||||
internal bool m_performing;
|
||||
|
||||
public VirtualButton(InputDevice device) : base(device) { }
|
||||
|
||||
public override bool Performing
|
||||
{
|
||||
get => m_performing;
|
||||
}
|
||||
|
||||
public override Vector2 GetVector2()
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
public override float GetFlaot()
|
||||
{
|
||||
return Performing ? 1 : 0;
|
||||
}
|
||||
|
||||
public override string ControlName => "VirtualStickButton";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f5d8205d647a4741a9c4e8d7894f040
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.InputDevices
|
||||
@ -44,13 +45,13 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得一个键盘设备
|
||||
/// 获得一个指定类型的设备
|
||||
/// </summary>
|
||||
public KeyBoard GetKeyboard()
|
||||
public T GetDevice<T>() where T : InputDevice
|
||||
{
|
||||
foreach (var d in m_devices.Values)
|
||||
{
|
||||
if (d is KeyBoard kb) return kb;
|
||||
if (d is T) return d as T;
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -92,6 +93,7 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
|
||||
foreach (var control in m_controlMapper.Values)
|
||||
{
|
||||
control.Update();
|
||||
if (control.Start)
|
||||
{
|
||||
AnyKeyDown = true;
|
||||
@ -101,7 +103,7 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
|
||||
/// <summary> 用于列出这个输入设备的所有输入控件实例 </summary>
|
||||
/// <returns></returns>
|
||||
protected abstract IEnumerable<InputControl> DefineControls();
|
||||
protected abstract List<InputControl> DefineControls();
|
||||
|
||||
/// <summary> 通过控件名称,找到对应的控件 </summary>
|
||||
/// <param name="keyName"></param>
|
||||
@ -121,9 +123,11 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
public InputDevice Device { get; internal set; }
|
||||
|
||||
/// <summary> 获取该控件是否在当前调用帧被激发 </summary>
|
||||
public abstract bool Start { get; }
|
||||
public bool Start { get; private set; }
|
||||
/// <summary> 获取该控件是否在当前调用帧被释放 </summary>
|
||||
public abstract bool Release { get; }
|
||||
public bool Release { get; private set; }
|
||||
|
||||
bool m_performingLastFrame;
|
||||
/// <summary> 获取该控件是否在当前调用帧是否处于活动状态 </summary>
|
||||
public abstract bool Performing { get; }
|
||||
|
||||
@ -133,6 +137,29 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
/// <summary> 获得该控件的以浮点数表达的值 </summary>
|
||||
public abstract float GetFlaot();
|
||||
|
||||
internal void Update()
|
||||
{
|
||||
UpdateReleaseStartState();
|
||||
OnUpdate();
|
||||
}
|
||||
|
||||
private void UpdateReleaseStartState()
|
||||
{
|
||||
var oldPerforming = m_performingLastFrame;
|
||||
var newPerforming = Performing;
|
||||
|
||||
Start = false;
|
||||
Release = false;
|
||||
if (oldPerforming != newPerforming)
|
||||
{
|
||||
if (oldPerforming == false) Start = true;
|
||||
else Release = true;
|
||||
}
|
||||
m_performingLastFrame = Performing;
|
||||
}
|
||||
|
||||
protected virtual void OnUpdate() { }
|
||||
|
||||
/// <summary> 控件名,这个控件名称必须是唯一的 </summary>
|
||||
public abstract string ControlName { get; }
|
||||
|
||||
|
@ -9,11 +9,11 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM //InputSystem
|
||||
return new ForInputSystem.InputSystemResolver();
|
||||
#elif UNITY_PSP2 //SDK
|
||||
throw new System.NotImplementedException();
|
||||
#elif UNITY_PSP2 //特化实现
|
||||
return new ForPSV.PSVResolver();
|
||||
#elif UNITY_PS3 //SDK
|
||||
throw new System.NotImplementedException();
|
||||
#else //使用旧Input
|
||||
#else
|
||||
throw new System.NotImplementedException();
|
||||
#endif
|
||||
}
|
||||
@ -55,19 +55,6 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
OnDeviceConnected?.Invoke(connectDevice);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个键盘设备的指定按键当前调用帧是否触发了按下动作
|
||||
/// </summary>
|
||||
/// <param name="keyboard">键盘设备实例,来自Resolver提供的设备实例</param>
|
||||
/// <param name="key">键盘按键枚举值</param>
|
||||
/// <returns></returns>
|
||||
public abstract bool GetKeyDown(KeyBoard keyboard, KeyCode key);
|
||||
/// <summary>
|
||||
/// 获取一个键盘设备的指定按键当前调用帧是否触发了放开动作
|
||||
/// </summary>
|
||||
/// <param name="keyboard">键盘设备实例,来自Resolver提供的设备实例</param>
|
||||
/// <param name="key">键盘按键枚举值</param>
|
||||
public abstract bool GetKeyUp(KeyBoard keyboard, KeyCode key);
|
||||
/// <summary>
|
||||
/// 获取一个键盘设备的指定按键当前调用帧是否处于按下状态
|
||||
/// </summary>
|
||||
|
@ -68,34 +68,6 @@ namespace AxibugEmuOnline.Client.InputDevices.ForInputSystem
|
||||
return m_devices.Values;
|
||||
}
|
||||
|
||||
public override bool GetKeyDown(KeyBoard keyboard, KeyCode key)
|
||||
{
|
||||
if (m_devices.TryGetKey(keyboard, out var ipdev))
|
||||
{
|
||||
var ipKeyboard = ipdev as IPKeyboard;
|
||||
if (ipKeyboard == null) return false;
|
||||
|
||||
var k = GetIPKeyboardKey(ipKeyboard, key);
|
||||
return k.wasPressedThisFrame;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetKeyUp(KeyBoard keyboard, KeyCode key)
|
||||
{
|
||||
if (m_devices.TryGetKey(keyboard, out var ipdev))
|
||||
{
|
||||
var ipKeyboard = ipdev as IPKeyboard;
|
||||
if (ipKeyboard == null) return false;
|
||||
|
||||
var k = GetIPKeyboardKey(ipKeyboard, key);
|
||||
return k.wasReleasedThisFrame;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool GetKey(KeyBoard keyboard, KeyCode key)
|
||||
{
|
||||
if (m_devices.TryGetKey(keyboard, out var ipdev))
|
||||
|
@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client.InputDevices.ForPSV
|
||||
{
|
||||
public class PSVResolver : InputResolver
|
||||
{
|
||||
List<InputDevice> m_devices = new List<InputDevice>();
|
||||
PSVController m_psvController;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
m_psvController = new PSVController(this);
|
||||
m_devices.Add(m_psvController);
|
||||
}
|
||||
|
||||
public override IEnumerable<InputDevice> GetDevices()
|
||||
{
|
||||
return m_devices;
|
||||
}
|
||||
|
||||
public override bool CheckOnline(InputDevice device)
|
||||
{
|
||||
return device == m_psvController;
|
||||
}
|
||||
|
||||
public override bool GetKey(KeyBoard keyboard, KeyCode key)
|
||||
{
|
||||
return Input.GetKeyDown(key);
|
||||
}
|
||||
|
||||
public override string GetDeviceName(InputDevice inputDevice)
|
||||
{
|
||||
Debug.Assert(inputDevice == m_psvController, "只支持psv控制器");
|
||||
|
||||
return nameof(PSVController);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4347b81ba3ae8e148813290b685e8df0
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using AxibugEmuOnline.Client.UI;
|
||||
using DG.Tweening;
|
||||
using DG.Tweening.Core;
|
||||
|
@ -4,7 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using static AxibugEmuOnline.Client.FilterManager;
|
||||
using static AxibugEmuOnline.Client.Settings.FilterManager;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using AxibugEmuOnline.Client.UI;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
|
@ -1,7 +1,7 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static AxibugEmuOnline.Client.FilterManager;
|
||||
using static AxibugEmuOnline.Client.Settings.FilterManager;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static AxibugEmuOnline.Client.ScreenScaler;
|
||||
using static AxibugEmuOnline.Client.Settings.ScreenScaler;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using Coffee.UIExtensions;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -37,6 +37,38 @@ InputManager:
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Horizontal
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 1
|
||||
- serializedVersion: 3
|
||||
m_Name: Vertical
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 1
|
||||
- serializedVersion: 3
|
||||
m_Name: Horizontal
|
||||
descriptiveName:
|
||||
@ -69,3 +101,36 @@ InputManager:
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: HorizontalR
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 3
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: VerticalR
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 4
|
||||
joyNum: 0
|
||||
m_UsePhysicalKeys: 1
|
||||
|
Loading…
Reference in New Issue
Block a user