封装GUI虚拟按键功能组件
This commit is contained in:
parent
41b0562f7c
commit
f7633ea341
AxibugEmuOnline.Client/Assets/Script/AppMain
AxiInput
AxiInputSP.Settings.metaAxiInputSP.Settings
ColecoVisionMultiKeysSetting.csColecoVisionMultiKeysSetting.cs.metaGameBoyColorMultiKeysSetting.csGameBoyColorMultiKeysSetting.cs.metaGameBoyMultiKeysSetting.csGameBoyMultiKeysSetting.cs.metaGameGearMultiKeysSetting.csGameGearMultiKeysSetting.cs.metaGamingMultiKeysSetting.csGamingMultiKeysSetting.cs.metaMasterSystemMultiKeysSetting.csMasterSystemMultiKeysSetting.cs.metaNESMultiKeysSetting.csNESMultiKeysSetting.cs.metaSC3000MultiKeysSetting.csSC3000MultiKeysSetting.cs.metaSG1000MultiKeysSetting.csSG1000MultiKeysSetting.cs.metaUMAMEMultiKeysSetting.csUMAMEMultiKeysSetting.cs.metaXMBMultiKeysSetting.csXMBMultiKeysSetting.cs.meta
AxiInputSP.metaAxiInputSP
AxiInput.Struct.csAxiInput.Struct.cs.metaAxiInputEx.csAxiInputEx.cs.metaAxiInputUGUICenter.cs.metaAxiInputUGUIHandle.cs.meta
Axis
PC_XBOXKEY.csPSVitaKey.csUGUI
Emulator/NesEmulator
IkeyMapperChanger
Manager
UI/CommandDispatcher
@ -1,27 +0,0 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput
|
|
||||||
{
|
|
||||||
public abstract class AxiInputUGUIHandleBase : IDisposable
|
|
||||||
{
|
|
||||||
public int Handle { get; private set; }
|
|
||||||
public AxiInputUGuiBtnType UguiBtnType { get; private set; }
|
|
||||||
|
|
||||||
public AxiInputUGUIHandleBase(AxiInputUGuiBtnType uguiBtnType)
|
|
||||||
{
|
|
||||||
|
|
||||||
Handle = AxiInputUGUICenter.GetNextSeed();
|
|
||||||
this.UguiBtnType = uguiBtnType;
|
|
||||||
AxiInputUGUICenter.RegHandle(this);
|
|
||||||
}
|
|
||||||
public abstract bool GetKeyDown();
|
|
||||||
public abstract bool GetKey();
|
|
||||||
public abstract bool GetKeyUp();
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
AxiInputUGUICenter.UnregHandle(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class ColecoVisionMultiKeysSetting : MultiKeysSettingBase
|
public class ColecoVisionMultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class GameBoyColorMultiKeysSetting : MultiKeysSettingBase
|
public class GameBoyColorMultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class GameBoyMultiKeysSetting : MultiKeysSettingBase
|
public class GameBoyMultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class GameGearMultiKeysSetting : MultiKeysSettingBase
|
public class GameGearMultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -3,7 +3,7 @@ using AxibugEmuOnline.Client.Common;
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class GamingMultiKeysSetting : MultiKeysSettingBase
|
public class GamingMultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -2,7 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum EssgeeSingleKey : ushort
|
public enum EssgeeSingleKey : ushort
|
@ -1,8 +1,9 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
|
using AxiInputSP;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VirtualNes.Core;
|
using VirtualNes.Core;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class NESMultiKeysSetting : MultiKeysSettingBase
|
public class NESMultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class SC3000MultiKeysSetting : MultiKeysSettingBase
|
public class SC3000MultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class SG1000MultiKeysSetting : MultiKeysSettingBase
|
public class SG1000MultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -1,7 +1,7 @@
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public enum UMAMEKSingleKey
|
public enum UMAMEKSingleKey
|
||||||
{
|
{
|
@ -3,7 +3,7 @@ using AxibugEmuOnline.Client.Common;
|
|||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput.Settings
|
namespace AxiInputSP.Setting
|
||||||
{
|
{
|
||||||
public class XMBMultiKeysSetting : MultiKeysSettingBase
|
public class XMBMultiKeysSetting : MultiKeysSettingBase
|
||||||
{
|
{
|
@ -2,7 +2,7 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput
|
namespace AxiInputSP
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Explicit, Size = 8)]
|
[StructLayout(LayoutKind.Explicit, Size = 8)]
|
||||||
public struct AxiInput
|
public struct AxiInput
|
@ -1,6 +1,8 @@
|
|||||||
using UnityEngine;
|
using AxiInputSP.Axis;
|
||||||
|
using AxiInputSP.UGUI;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput
|
namespace AxiInputSP
|
||||||
{
|
{
|
||||||
public static class AxiInputEx
|
public static class AxiInputEx
|
||||||
{
|
{
|
@ -1,13 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput
|
namespace AxiInputSP.Axis
|
||||||
{
|
{
|
||||||
public static class AxiInputAxisCenter
|
public static class AxiInputAxisCenter
|
||||||
{
|
{
|
||||||
static long LastCheckFrame = -1;
|
static long LastCheckFrame = -1;
|
||||||
|
|
||||||
public enum AxisState
|
enum AxisState
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
KeyUp,
|
KeyUp,
|
@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client.Common
|
namespace AxiInputSP
|
||||||
{
|
{
|
||||||
public static class PC_XBOXKEY
|
public static class PC_XBOXKEY
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client.Common
|
namespace AxiInputSP
|
||||||
{
|
{
|
||||||
public static class PSVitaKey
|
public static class PSVitaKey
|
||||||
{
|
{
|
@ -1,34 +1,34 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Assets.Script.AppMain.AxiInput
|
namespace AxiInputSP.UGUI
|
||||||
{
|
{
|
||||||
public static class AxiInputUGUICenter
|
public static class AxiInputUGUICenter
|
||||||
{
|
{
|
||||||
static int handleSeed = 0;
|
static int handleSeed = 0;
|
||||||
static Dictionary<int, AxiInputUGUIHandleBase> dictHandle2AxiUgui = new Dictionary<int, AxiInputUGUIHandleBase>();
|
static Dictionary<int, AxiInputUGUIHandle> dictHandle2AxiUgui = new Dictionary<int, AxiInputUGUIHandle>();
|
||||||
static Dictionary<AxiInputUGuiBtnType, List<AxiInputUGUIHandleBase>> dictBtnType2BtnList = new Dictionary<AxiInputUGuiBtnType, List<AxiInputUGUIHandleBase>>();
|
static Dictionary<AxiInputUGuiBtnType, List<AxiInputUGUIHandle>> dictBtnType2BtnList = new Dictionary<AxiInputUGuiBtnType, List<AxiInputUGUIHandle>>();
|
||||||
|
|
||||||
public static int GetNextSeed()
|
public static int GetNextSeed()
|
||||||
{
|
{
|
||||||
return ++handleSeed;
|
return ++handleSeed;
|
||||||
}
|
}
|
||||||
public static void RegHandle(AxiInputUGUIHandleBase uiHandle)
|
public static void RegHandle(AxiInputUGUIHandle uiHandle)
|
||||||
{
|
{
|
||||||
dictHandle2AxiUgui[uiHandle.Handle] = uiHandle;
|
dictHandle2AxiUgui[uiHandle.Handle] = uiHandle;
|
||||||
List<AxiInputUGUIHandleBase> list;
|
List<AxiInputUGUIHandle> list;
|
||||||
if (dictBtnType2BtnList.TryGetValue(uiHandle.UguiBtnType, out list))
|
if (dictBtnType2BtnList.TryGetValue(uiHandle.UguiBtnType, out list))
|
||||||
list = dictBtnType2BtnList[uiHandle.UguiBtnType] = new List<AxiInputUGUIHandleBase>();
|
list = dictBtnType2BtnList[uiHandle.UguiBtnType] = new List<AxiInputUGUIHandle>();
|
||||||
|
|
||||||
if (!list.Contains(uiHandle))
|
if (!list.Contains(uiHandle))
|
||||||
list.Add(uiHandle);
|
list.Add(uiHandle);
|
||||||
}
|
}
|
||||||
public static void UnregHandle(AxiInputUGUIHandleBase uiHandle)
|
public static void UnregHandle(AxiInputUGUIHandle uiHandle)
|
||||||
{
|
{
|
||||||
if (!dictHandle2AxiUgui.ContainsKey(uiHandle.Handle))
|
if (!dictHandle2AxiUgui.ContainsKey(uiHandle.Handle))
|
||||||
return;
|
return;
|
||||||
dictHandle2AxiUgui.Remove(uiHandle.Handle);
|
dictHandle2AxiUgui.Remove(uiHandle.Handle);
|
||||||
|
|
||||||
List<AxiInputUGUIHandleBase> list;
|
List<AxiInputUGUIHandle> list;
|
||||||
if (dictBtnType2BtnList.TryGetValue(uiHandle.UguiBtnType, out list))
|
if (dictBtnType2BtnList.TryGetValue(uiHandle.UguiBtnType, out list))
|
||||||
{
|
{
|
||||||
if (list.Contains(uiHandle))
|
if (list.Contains(uiHandle))
|
||||||
@ -38,7 +38,7 @@ namespace Assets.Script.AppMain.AxiInput
|
|||||||
|
|
||||||
public static bool GetKeyUp(AxiInputUGuiBtnType btntype)
|
public static bool GetKeyUp(AxiInputUGuiBtnType btntype)
|
||||||
{
|
{
|
||||||
List<AxiInputUGUIHandleBase> list;
|
List<AxiInputUGUIHandle> list;
|
||||||
if (!dictBtnType2BtnList.TryGetValue(btntype, out list))
|
if (!dictBtnType2BtnList.TryGetValue(btntype, out list))
|
||||||
return false;
|
return false;
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
@ -51,7 +51,7 @@ namespace Assets.Script.AppMain.AxiInput
|
|||||||
|
|
||||||
public static bool GetKeyDown(AxiInputUGuiBtnType btntype)
|
public static bool GetKeyDown(AxiInputUGuiBtnType btntype)
|
||||||
{
|
{
|
||||||
List<AxiInputUGUIHandleBase> list;
|
List<AxiInputUGUIHandle> list;
|
||||||
if (!dictBtnType2BtnList.TryGetValue(btntype, out list))
|
if (!dictBtnType2BtnList.TryGetValue(btntype, out list))
|
||||||
return false;
|
return false;
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
@ -64,7 +64,7 @@ namespace Assets.Script.AppMain.AxiInput
|
|||||||
|
|
||||||
public static bool GetKey(AxiInputUGuiBtnType btntype)
|
public static bool GetKey(AxiInputUGuiBtnType btntype)
|
||||||
{
|
{
|
||||||
List<AxiInputUGUIHandleBase> list;
|
List<AxiInputUGUIHandle> list;
|
||||||
if (!dictBtnType2BtnList.TryGetValue(btntype, out list))
|
if (!dictBtnType2BtnList.TryGetValue(btntype, out list))
|
||||||
return false;
|
return false;
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AxiInputSP.UGUI
|
||||||
|
{
|
||||||
|
public class AxiInputUGUIHandle
|
||||||
|
{
|
||||||
|
public int Handle { get; private set; }
|
||||||
|
public AxiInputUGuiBtnType UguiBtnType { get; private set; }
|
||||||
|
|
||||||
|
public AxiInputUGUIHandle(AxiInputUGuiBtnType uguiBtnType)
|
||||||
|
{
|
||||||
|
Handle = AxiInputUGUICenter.GetNextSeed();
|
||||||
|
this.UguiBtnType = uguiBtnType;
|
||||||
|
AxiInputUGUICenter.RegHandle(this);
|
||||||
|
}
|
||||||
|
public bool GetKey()
|
||||||
|
{
|
||||||
|
return GetKeyHandle != null ? GetKeyHandle.Invoke() : false;
|
||||||
|
}
|
||||||
|
public bool GetKeyUp()
|
||||||
|
{
|
||||||
|
return GetKeyUpHandle != null ? GetKeyUpHandle.Invoke() : false;
|
||||||
|
}
|
||||||
|
public bool GetKeyDown()
|
||||||
|
{
|
||||||
|
return GetKeyDownHandle != null ? GetKeyDownHandle.Invoke() : false;
|
||||||
|
}
|
||||||
|
public Func<bool> GetKeyHandle;
|
||||||
|
public Func<bool> GetKeyUpHandle;
|
||||||
|
public Func<bool> GetKeyDownHandle;
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
GetKeyHandle = null;
|
||||||
|
GetKeyUpHandle = null;
|
||||||
|
GetKeyDownHandle = null;
|
||||||
|
AxiInputUGUICenter.UnregHandle(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
|
namespace AxiInputSP.UGUI
|
||||||
|
{
|
||||||
|
public class AxiIptButton : UnityEngine.UI.Button
|
||||||
|
{
|
||||||
|
enum AxiButtonState
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
KeyUp,
|
||||||
|
KeyDown,
|
||||||
|
KeyHold
|
||||||
|
}
|
||||||
|
|
||||||
|
AxiInputUGUIHandle[] handles;
|
||||||
|
AxiButtonState m_state = AxiButtonState.None;
|
||||||
|
/// <summary>
|
||||||
|
/// 键值(支持组合键)
|
||||||
|
/// </summary>
|
||||||
|
public AxiInputUGuiBtnType[] axiBtnTypeList;
|
||||||
|
protected override void Awake()
|
||||||
|
{
|
||||||
|
base.Awake();
|
||||||
|
if (axiBtnTypeList != null)
|
||||||
|
{
|
||||||
|
handles = new AxiInputUGUIHandle[axiBtnTypeList.Length];
|
||||||
|
for (int i = 0; i < axiBtnTypeList.Length; i++)
|
||||||
|
{
|
||||||
|
handles[i] = new AxiInputUGUIHandle(axiBtnTypeList[i]);
|
||||||
|
handles[i].GetKeyHandle = GetKey;
|
||||||
|
handles[i].GetKeyUpHandle = GetKeyUp;
|
||||||
|
handles[i].GetKeyDownHandle = GetKeyDown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDestroy()
|
||||||
|
{
|
||||||
|
base.OnDestroy();
|
||||||
|
if (axiBtnTypeList != null)
|
||||||
|
{
|
||||||
|
handles = new AxiInputUGUIHandle[axiBtnTypeList.Length];
|
||||||
|
for (int i = 0; i < axiBtnTypeList.Length; i++)
|
||||||
|
{
|
||||||
|
handles[i].Dispose();
|
||||||
|
handles[i] = null;
|
||||||
|
}
|
||||||
|
axiBtnTypeList = null;
|
||||||
|
handles = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
protected override void OnEnable()
|
||||||
|
{
|
||||||
|
base.OnEnable();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GetKey()
|
||||||
|
{
|
||||||
|
return m_state >= AxiButtonState.KeyDown;
|
||||||
|
}
|
||||||
|
bool GetKeyUp()
|
||||||
|
{
|
||||||
|
return m_state == AxiButtonState.KeyUp;
|
||||||
|
}
|
||||||
|
bool GetKeyDown()
|
||||||
|
{
|
||||||
|
return m_state == AxiButtonState.KeyDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnPointerDown(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
base.OnPointerDown(eventData);
|
||||||
|
//如果之前帧是KeyUp或None,则为KeyDown|KeyHold
|
||||||
|
if (m_state <= AxiButtonState.KeyUp)
|
||||||
|
m_state = AxiButtonState.KeyDown;
|
||||||
|
//如果之前帧是KeyDown,则为KeyHold
|
||||||
|
else if (m_state == AxiButtonState.KeyDown)
|
||||||
|
m_state = AxiButtonState.KeyHold;
|
||||||
|
}
|
||||||
|
public override void OnPointerUp(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
base.OnPointerUp(eventData);
|
||||||
|
//如果之前帧是KeyDown|KeyHold,则为KeyUp|None
|
||||||
|
if (m_state >= AxiButtonState.KeyDown)
|
||||||
|
m_state = AxiButtonState.KeyUp;
|
||||||
|
//如果之前帧是KeyUp,则为None
|
||||||
|
else if (m_state == AxiButtonState.KeyUp)
|
||||||
|
m_state = AxiButtonState.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -201,27 +201,27 @@ namespace AxibugEmuOnline.Client
|
|||||||
// MIC.IsDown;
|
// MIC.IsDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyListener GetKey(int controllerInput, EnumButtonType nesConBtnType)
|
//public static KeyListener GetKey(int controllerInput, EnumButtonType nesConBtnType)
|
||||||
{
|
//{
|
||||||
string configKey = $"NES_{controllerInput}_{nesConBtnType}";
|
// string configKey = $"NES_{controllerInput}_{nesConBtnType}";
|
||||||
|
|
||||||
//PSV平台固定键值
|
// //PSV平台固定键值
|
||||||
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
|
// if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
|
||||||
{
|
// {
|
||||||
return KeyListener.GetPSVitaKey(controllerInput, nesConBtnType);
|
// return KeyListener.GetPSVitaKey(controllerInput, nesConBtnType);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (PlayerPrefs.HasKey(configKey))
|
// if (PlayerPrefs.HasKey(configKey))
|
||||||
{
|
// {
|
||||||
return new KeyListener(PlayerPrefs.GetString(configKey));
|
// return new KeyListener(PlayerPrefs.GetString(configKey));
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
var defaultKeyCode = KeyListener.GetDefaultKey(controllerInput, nesConBtnType);
|
// var defaultKeyCode = KeyListener.GetDefaultKey(controllerInput, nesConBtnType);
|
||||||
PlayerPrefs.SetString(configKey, defaultKeyCode.ToString());
|
// PlayerPrefs.SetString(configKey, defaultKeyCode.ToString());
|
||||||
return defaultKeyCode;
|
// return defaultKeyCode;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
@ -268,127 +268,127 @@ namespace AxibugEmuOnline.Client
|
|||||||
//low C# readonly
|
//low C# readonly
|
||||||
//public readonly struct KeyListener
|
//public readonly struct KeyListener
|
||||||
|
|
||||||
public struct KeyListener
|
//public struct KeyListener
|
||||||
{
|
//{
|
||||||
private readonly KeyCode m_key;
|
// private readonly KeyCode m_key;
|
||||||
|
|
||||||
public KeyListener(KeyCode key)
|
// public KeyListener(KeyCode key)
|
||||||
{
|
// {
|
||||||
m_key = key;
|
// m_key = key;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// <summary> 从配置字符串构建 </summary>
|
// /// <summary> 从配置字符串构建 </summary>
|
||||||
public KeyListener(string confStr)
|
// public KeyListener(string confStr)
|
||||||
{
|
// {
|
||||||
m_key = KeyCode.None;
|
// m_key = KeyCode.None;
|
||||||
|
|
||||||
int result;
|
// int result;
|
||||||
if (int.TryParse(confStr, out result))
|
// if (int.TryParse(confStr, out result))
|
||||||
m_key = (KeyCode)result;
|
// m_key = (KeyCode)result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool IsPressing()
|
// public bool IsPressing()
|
||||||
{
|
// {
|
||||||
return Input.GetKey(m_key);
|
// return Input.GetKey(m_key);
|
||||||
}
|
// }
|
||||||
public bool IsDown()
|
// public bool IsDown()
|
||||||
{
|
// {
|
||||||
return Input.GetKeyDown(m_key);
|
// return Input.GetKeyDown(m_key);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public override string ToString()
|
// public override string ToString()
|
||||||
{
|
// {
|
||||||
return ((int)(m_key)).ToString();
|
// return ((int)(m_key)).ToString();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static KeyListener GetDefaultKey(int controllerIndex, EnumButtonType nesConBtnType)
|
// public static KeyListener GetDefaultKey(int controllerIndex, EnumButtonType nesConBtnType)
|
||||||
{
|
// {
|
||||||
switch (controllerIndex)
|
// switch (controllerIndex)
|
||||||
{
|
// {
|
||||||
case 0:
|
// case 0:
|
||||||
switch (nesConBtnType)
|
// switch (nesConBtnType)
|
||||||
{
|
// {
|
||||||
case EnumButtonType.LEFT:
|
// case EnumButtonType.LEFT:
|
||||||
return new KeyListener(KeyCode.A);
|
// return new KeyListener(KeyCode.A);
|
||||||
case EnumButtonType.RIGHT:
|
// case EnumButtonType.RIGHT:
|
||||||
return new KeyListener(KeyCode.D);
|
// return new KeyListener(KeyCode.D);
|
||||||
case EnumButtonType.UP:
|
// case EnumButtonType.UP:
|
||||||
return new KeyListener(KeyCode.W);
|
// return new KeyListener(KeyCode.W);
|
||||||
case EnumButtonType.DOWN:
|
// case EnumButtonType.DOWN:
|
||||||
return new KeyListener(KeyCode.S);
|
// return new KeyListener(KeyCode.S);
|
||||||
case EnumButtonType.START:
|
// case EnumButtonType.START:
|
||||||
return new KeyListener(KeyCode.B);
|
// return new KeyListener(KeyCode.B);
|
||||||
case EnumButtonType.SELECT:
|
// case EnumButtonType.SELECT:
|
||||||
return new KeyListener(KeyCode.V);
|
// return new KeyListener(KeyCode.V);
|
||||||
case EnumButtonType.A:
|
// case EnumButtonType.A:
|
||||||
return new KeyListener(KeyCode.K);
|
// return new KeyListener(KeyCode.K);
|
||||||
case EnumButtonType.B:
|
// case EnumButtonType.B:
|
||||||
return new KeyListener(KeyCode.J);
|
// return new KeyListener(KeyCode.J);
|
||||||
case EnumButtonType.MIC:
|
// case EnumButtonType.MIC:
|
||||||
return new KeyListener(KeyCode.M);
|
// return new KeyListener(KeyCode.M);
|
||||||
}
|
// }
|
||||||
|
|
||||||
break;
|
// break;
|
||||||
case 1:
|
// case 1:
|
||||||
switch (nesConBtnType)
|
// switch (nesConBtnType)
|
||||||
{
|
// {
|
||||||
case EnumButtonType.LEFT:
|
// case EnumButtonType.LEFT:
|
||||||
return new KeyListener(KeyCode.Delete);
|
// return new KeyListener(KeyCode.Delete);
|
||||||
case EnumButtonType.RIGHT:
|
// case EnumButtonType.RIGHT:
|
||||||
return new KeyListener(KeyCode.PageDown);
|
// return new KeyListener(KeyCode.PageDown);
|
||||||
case EnumButtonType.UP:
|
// case EnumButtonType.UP:
|
||||||
return new KeyListener(KeyCode.Home);
|
// return new KeyListener(KeyCode.Home);
|
||||||
case EnumButtonType.DOWN:
|
// case EnumButtonType.DOWN:
|
||||||
return new KeyListener(KeyCode.End);
|
// return new KeyListener(KeyCode.End);
|
||||||
case EnumButtonType.START:
|
// case EnumButtonType.START:
|
||||||
return new KeyListener(KeyCode.PageUp);
|
// return new KeyListener(KeyCode.PageUp);
|
||||||
case EnumButtonType.SELECT:
|
// case EnumButtonType.SELECT:
|
||||||
return new KeyListener(KeyCode.Insert);
|
// return new KeyListener(KeyCode.Insert);
|
||||||
case EnumButtonType.A:
|
// case EnumButtonType.A:
|
||||||
return new KeyListener(KeyCode.Keypad5);
|
// return new KeyListener(KeyCode.Keypad5);
|
||||||
case EnumButtonType.B:
|
// case EnumButtonType.B:
|
||||||
return new KeyListener(KeyCode.Keypad4);
|
// return new KeyListener(KeyCode.Keypad4);
|
||||||
case EnumButtonType.MIC:
|
// case EnumButtonType.MIC:
|
||||||
return new KeyListener(KeyCode.KeypadPeriod);
|
// return new KeyListener(KeyCode.KeypadPeriod);
|
||||||
}
|
// }
|
||||||
|
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return default(KeyListener);
|
// return default(KeyListener);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public static KeyListener GetPSVitaKey(int controllerIndex, EnumButtonType nesConBtnType)
|
// //public static KeyListener GetPSVitaKey(int controllerIndex, EnumButtonType nesConBtnType)
|
||||||
{
|
// //{
|
||||||
switch (controllerIndex)
|
// // switch (controllerIndex)
|
||||||
{
|
// // {
|
||||||
case 0:
|
// // case 0:
|
||||||
switch (nesConBtnType)
|
// // switch (nesConBtnType)
|
||||||
{
|
// // {
|
||||||
case EnumButtonType.LEFT:
|
// // case EnumButtonType.LEFT:
|
||||||
return new KeyListener(PSVitaKey.Left);
|
// // return new KeyListener(PSVitaKey.Left);
|
||||||
case EnumButtonType.RIGHT:
|
// // case EnumButtonType.RIGHT:
|
||||||
return new KeyListener(PSVitaKey.Right);
|
// // return new KeyListener(PSVitaKey.Right);
|
||||||
case EnumButtonType.UP:
|
// // case EnumButtonType.UP:
|
||||||
return new KeyListener(PSVitaKey.Up);
|
// // return new KeyListener(PSVitaKey.Up);
|
||||||
case EnumButtonType.DOWN:
|
// // case EnumButtonType.DOWN:
|
||||||
return new KeyListener(PSVitaKey.Down);
|
// // return new KeyListener(PSVitaKey.Down);
|
||||||
case EnumButtonType.START:
|
// // case EnumButtonType.START:
|
||||||
return new KeyListener(PSVitaKey.Start);
|
// // return new KeyListener(PSVitaKey.Start);
|
||||||
case EnumButtonType.SELECT:
|
// // case EnumButtonType.SELECT:
|
||||||
return new KeyListener(PSVitaKey.Select);
|
// // return new KeyListener(PSVitaKey.Select);
|
||||||
case EnumButtonType.A:
|
// // case EnumButtonType.A:
|
||||||
return new KeyListener(PSVitaKey.Circle);
|
// // return new KeyListener(PSVitaKey.Circle);
|
||||||
case EnumButtonType.B:
|
// // case EnumButtonType.B:
|
||||||
return new KeyListener(PSVitaKey.Cross);
|
// // return new KeyListener(PSVitaKey.Cross);
|
||||||
case EnumButtonType.MIC:
|
// // case EnumButtonType.MIC:
|
||||||
return new KeyListener(PSVitaKey.Block);
|
// // return new KeyListener(PSVitaKey.Block);
|
||||||
}
|
// // }
|
||||||
break;
|
// // break;
|
||||||
}
|
// // }
|
||||||
return default(KeyListener);
|
// // return default(KeyListener);
|
||||||
}
|
// //}
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,5 @@
|
|||||||
using Assets.Script.AppMain.AxiInput.Settings;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
using AxibugEmuOnline.Client.ClientCore;
|
|
||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using Assets.Script.AppMain.AxiInput.Settings;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
using AxibugEmuOnline.Client.ClientCore;
|
|
||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
using Assets.Script.AppMain.AxiInput;
|
using AxibugEmuOnline.Client.Common;
|
||||||
using Assets.Script.AppMain.AxiInput.Settings;
|
using AxiInputSP;
|
||||||
using AxibugEmuOnline.Client.Common;
|
using AxiInputSP.Setting;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements.Experimental;
|
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client.Manager
|
namespace AxibugEmuOnline.Client.Manager
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
using Assets.Script.AppMain.AxiInput;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
using AxibugEmuOnline.Client.ClientCore;
|
|
||||||
using AxibugEmuOnline.Client.Manager;
|
using AxibugEmuOnline.Client.Manager;
|
||||||
using System.CodeDom.Compiler;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using static UnityEditor.Progress;
|
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user