NS 归档
This commit is contained in:
parent
b2525bb68f
commit
13c99dfb31
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class AxiHttpTest : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.T))
|
||||
{
|
||||
//for (int i = 0; i < 1000; i++)
|
||||
StartCoroutine(DownloadFromURL("http://emu.axibug.com/UserSav/12/Nes/190/1/1.sav", "D:/1.bin", null));
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator DownloadFromURL(string url, string path, Action<byte[]> callback)
|
||||
{
|
||||
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
AxiHttpProxy.SendDownLoadProxy request = AxiHttpProxy.GetDownLoad(url);
|
||||
|
||||
while (!request.downloadHandler.isDone)
|
||||
{
|
||||
Debug.Log($"下载进度:{request.downloadHandler.DownLoadPr} ->{request.downloadHandler.loadedLenght}/{request.downloadHandler.NeedloadedLenght}");
|
||||
yield return null;
|
||||
}
|
||||
AxiHttpProxy.ShowAxiHttpDebugInfo(request.downloadHandler);
|
||||
Debug.Log($"下载进度完毕:data.Length=>" + request.downloadHandler.data.Length);
|
||||
}
|
||||
|
||||
|
||||
//if (!request.downloadHandler.bHadErr)
|
||||
//{
|
||||
// AxiIO.Directory.CreateDirectory(path);
|
||||
// AxiIO.File.WriteAllBytes($"{path}/{url.GetHashCode()}", request.downloadHandler.data, false);
|
||||
// callback?.Invoke(request.downloadHandler.data);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// callback?.Invoke(null);
|
||||
//}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 873427ab0a955e64fa2444505ef0775c
|
||||
@ -12,7 +12,7 @@ public class UEGKeyboard : MonoBehaviour
|
||||
{
|
||||
public EssgeeControllerMapper ControllerMapper { get; private set; }
|
||||
public Dictionary<ulong, EssgeeMotionKey> dictKey2Motion = new Dictionary<ulong, EssgeeMotionKey>();
|
||||
public Dictionary<ulong, KeyCode> dictMotion2RealKey = new Dictionary<ulong, KeyCode>()
|
||||
/*public Dictionary<ulong, KeyCode> dictMotion2RealKey = new Dictionary<ulong, KeyCode>()
|
||||
{
|
||||
{ EssgeeUnityKey.P1_UP,KeyCode.W},
|
||||
{ EssgeeUnityKey.P1_DOWN,KeyCode.S},
|
||||
@ -54,7 +54,7 @@ public class UEGKeyboard : MonoBehaviour
|
||||
{ EssgeeUnityKey.P4_BTN_4,KeyCode.F12},
|
||||
{ EssgeeUnityKey.P4_POTION_1,KeyCode.F12},
|
||||
{ EssgeeUnityKey.P4_POTION_2,KeyCode.F12},
|
||||
};
|
||||
};*/
|
||||
public ulong[] CheckList;
|
||||
public EssgeeMotionKey[] mCurrKey = new EssgeeMotionKey[0];
|
||||
List<EssgeeMotionKey> temp = new List<EssgeeMotionKey>();
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Event;
|
||||
using AxibugEmuOnline.Client.Settings;
|
||||
using StoicGooseUnity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -6,12 +9,14 @@ using UnityEngine;
|
||||
|
||||
public class SGKeyboard : MonoBehaviour
|
||||
{
|
||||
Dictionary<KeyCode, StoicGooseKey> dictKey2SGKey = new Dictionary<KeyCode, StoicGooseKey>();
|
||||
KeyCode[] checkKeys;
|
||||
public SGControllerMapper ControllerMapper { get; private set; }
|
||||
//Dictionary<KeyCode, StoicGooseKey> dictKey2SGKey = new Dictionary<KeyCode, StoicGooseKey>();
|
||||
//KeyCode[] checkKeys;
|
||||
long currInput;
|
||||
private void Awake()
|
||||
{
|
||||
SetVerticalOrientation(false);
|
||||
ControllerMapper = new SGControllerMapper();
|
||||
//SetVerticalOrientation(false);
|
||||
}
|
||||
|
||||
|
||||
@ -22,31 +27,187 @@ public class SGKeyboard : MonoBehaviour
|
||||
|
||||
internal void SetVerticalOrientation(bool isVerticalOrientation)
|
||||
{
|
||||
dictKey2SGKey[KeyCode.Return] = StoicGooseKey.Start;
|
||||
dictKey2SGKey[KeyCode.W] = StoicGooseKey.X1;
|
||||
dictKey2SGKey[KeyCode.S] = StoicGooseKey.X2;
|
||||
dictKey2SGKey[KeyCode.A] = StoicGooseKey.X3;
|
||||
dictKey2SGKey[KeyCode.D] = StoicGooseKey.X4;
|
||||
dictKey2SGKey[KeyCode.G] = StoicGooseKey.Y1;
|
||||
dictKey2SGKey[KeyCode.V] = StoicGooseKey.Y2;
|
||||
dictKey2SGKey[KeyCode.C] = StoicGooseKey.Y3;
|
||||
dictKey2SGKey[KeyCode.B] = StoicGooseKey.Y4;
|
||||
dictKey2SGKey[KeyCode.Return] = StoicGooseKey.Start;
|
||||
dictKey2SGKey[KeyCode.J] = StoicGooseKey.B;
|
||||
dictKey2SGKey[KeyCode.K] = StoicGooseKey.A;
|
||||
checkKeys = dictKey2SGKey.Keys.ToArray();
|
||||
//TODO 横屏竖屏
|
||||
|
||||
//dictKey2SGKey[KeyCode.Return] = StoicGooseKey.Start;
|
||||
//dictKey2SGKey[KeyCode.W] = StoicGooseKey.X1;
|
||||
//dictKey2SGKey[KeyCode.S] = StoicGooseKey.X2;
|
||||
//dictKey2SGKey[KeyCode.A] = StoicGooseKey.X3;
|
||||
//dictKey2SGKey[KeyCode.D] = StoicGooseKey.X4;
|
||||
//dictKey2SGKey[KeyCode.G] = StoicGooseKey.Y1;
|
||||
//dictKey2SGKey[KeyCode.V] = StoicGooseKey.Y2;
|
||||
//dictKey2SGKey[KeyCode.C] = StoicGooseKey.Y3;
|
||||
//dictKey2SGKey[KeyCode.B] = StoicGooseKey.Y4;
|
||||
//dictKey2SGKey[KeyCode.Return] = StoicGooseKey.Start;
|
||||
//dictKey2SGKey[KeyCode.J] = StoicGooseKey.B;
|
||||
//dictKey2SGKey[KeyCode.K] = StoicGooseKey.A;
|
||||
//checkKeys = dictKey2SGKey.Keys.ToArray();
|
||||
}
|
||||
|
||||
public void Update_InputData()
|
||||
internal void SetInputData(ulong inputData)
|
||||
{
|
||||
currInput = 0;
|
||||
for (int i = 0; i < checkKeys.Length; i++)
|
||||
currInput = (long)inputData;
|
||||
}
|
||||
|
||||
public ulong Update_InputData()
|
||||
{
|
||||
ulong tempLocalInputAllData = 0;
|
||||
tempLocalInputAllData |= ControllerMapper.Controller0.GetSingleAllInput();
|
||||
tempLocalInputAllData |= ControllerMapper.Controller1.GetSingleAllInput();
|
||||
tempLocalInputAllData |= ControllerMapper.Controller2.GetSingleAllInput();
|
||||
tempLocalInputAllData |= ControllerMapper.Controller3.GetSingleAllInput();
|
||||
return tempLocalInputAllData;
|
||||
//currInput = tempLocalInputAllData;
|
||||
|
||||
//currInput = 0;
|
||||
//for (int i = 0; i < checkKeys.Length; i++)
|
||||
//{
|
||||
// KeyCode key = checkKeys[i];
|
||||
// if (Input.GetKey(key))
|
||||
// {
|
||||
// currInput |= (long)dictKey2SGKey[key];
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class SGControllerMapper : IControllerSetuper
|
||||
{
|
||||
public SGController Controller0 = new SGController(0);
|
||||
public SGController Controller1 = new SGController(1);
|
||||
public SGController Controller2 = new SGController(2);
|
||||
public SGController Controller3 = new SGController(3);
|
||||
|
||||
ulong mCurrAllInput;
|
||||
|
||||
public void SetConnect(uint? con0ToSlot = null,
|
||||
uint? con1ToSlot = null,
|
||||
uint? con2ToSlot = null,
|
||||
uint? con3ToSlot = null)
|
||||
{
|
||||
Controller0.ConnectSlot = con0ToSlot;
|
||||
Controller1.ConnectSlot = con1ToSlot;
|
||||
Controller2.ConnectSlot = con2ToSlot;
|
||||
Controller3.ConnectSlot = con3ToSlot;
|
||||
}
|
||||
public int? GetSlotConnectingControllerIndex(int slotIndex)
|
||||
{
|
||||
if (Controller0.ConnectSlot.HasValue && Controller0.ConnectSlot.Value == slotIndex) return 0;
|
||||
else if (Controller1.ConnectSlot.HasValue && Controller1.ConnectSlot.Value == slotIndex) return 1;
|
||||
else if (Controller2.ConnectSlot.HasValue && Controller2.ConnectSlot.Value == slotIndex) return 2;
|
||||
else if (Controller3.ConnectSlot.HasValue && Controller3.ConnectSlot.Value == slotIndex) return 3;
|
||||
else return null;
|
||||
}
|
||||
public IController GetSlotConnectingController(int slotIndex)
|
||||
{
|
||||
if (Controller0.ConnectSlot.HasValue && Controller0.ConnectSlot.Value == slotIndex) return Controller0;
|
||||
else if (Controller1.ConnectSlot.HasValue && Controller1.ConnectSlot.Value == slotIndex) return Controller1;
|
||||
else if (Controller2.ConnectSlot.HasValue && Controller2.ConnectSlot.Value == slotIndex) return Controller2;
|
||||
else if (Controller3.ConnectSlot.HasValue && Controller3.ConnectSlot.Value == slotIndex) return Controller3;
|
||||
else return null;
|
||||
}
|
||||
static HashSet<uint> s_temp = new HashSet<uint>();
|
||||
public uint? GetFreeSlotIndex()
|
||||
{
|
||||
s_temp.Clear();
|
||||
s_temp.Add(0);
|
||||
s_temp.Add(1);
|
||||
s_temp.Add(2);
|
||||
s_temp.Add(3);
|
||||
|
||||
if (Controller0.ConnectSlot.HasValue) s_temp.Remove(Controller0.ConnectSlot.Value);
|
||||
if (Controller1.ConnectSlot.HasValue) s_temp.Remove(Controller1.ConnectSlot.Value);
|
||||
if (Controller2.ConnectSlot.HasValue) s_temp.Remove(Controller2.ConnectSlot.Value);
|
||||
if (Controller3.ConnectSlot.HasValue) s_temp.Remove(Controller3.ConnectSlot.Value);
|
||||
|
||||
if (s_temp.Count > 0) return s_temp.First();
|
||||
else return null;
|
||||
}
|
||||
public void LetControllerConnect(int conIndex, uint slotIndex)
|
||||
{
|
||||
SGController targetController;
|
||||
switch (conIndex)
|
||||
{
|
||||
KeyCode key = checkKeys[i];
|
||||
if (Input.GetKey(key))
|
||||
{
|
||||
currInput |= (long)dictKey2SGKey[key];
|
||||
}
|
||||
case 0: targetController = Controller0; break;
|
||||
case 1: targetController = Controller1; break;
|
||||
case 2: targetController = Controller2; break;
|
||||
case 3: targetController = Controller3; break;
|
||||
default:
|
||||
throw new System.Exception($"Not Allowed conIndex Range: {conIndex}");
|
||||
break;
|
||||
}
|
||||
if (targetController.ConnectSlot.HasValue) return;
|
||||
|
||||
targetController.ConnectSlot = slotIndex;
|
||||
Eventer.Instance.PostEvent(EEvent.OnControllerConnectChanged);
|
||||
}
|
||||
|
||||
}
|
||||
public class SGController : IController
|
||||
{
|
||||
public ulong CurrLocalSingleAllInput { get; private set; }
|
||||
|
||||
int mControllerIndex;
|
||||
uint? mConnectSlot;
|
||||
|
||||
/// <summary>
|
||||
/// 指示该手柄连接的手柄插槽
|
||||
/// <para><c>这个值代表了该手柄在实际游戏中控制的Player</c></para>
|
||||
/// <value>[0,3] 例外:为空代表未连接</value>
|
||||
/// </summary>
|
||||
public uint? ConnectSlot
|
||||
{
|
||||
get { return mConnectSlot; }
|
||||
set { mConnectSlot = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制器编号
|
||||
/// <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();*/ }
|
||||
}
|
||||
|
||||
public SGController(int controllerIndex)
|
||||
{
|
||||
ControllerIndex = controllerIndex;
|
||||
}
|
||||
|
||||
public bool AnyButtonDown()
|
||||
{
|
||||
return GetKeyMapper().AnyKeyDown(mControllerIndex);
|
||||
}
|
||||
|
||||
public StoicGooseBinding GetKeyMapper()
|
||||
{
|
||||
return App.settings.KeyMapper.GetBinder<StoicGooseBinding>(UStoicGoose.instance.Platform);
|
||||
}
|
||||
|
||||
public ulong GetSingleAllInput()
|
||||
{
|
||||
if (!ConnectSlot.HasValue)
|
||||
return 0;
|
||||
CurrLocalSingleAllInput = 0;
|
||||
|
||||
StoicGooseBinding essgeeKeys = GetKeyMapper();
|
||||
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.X1, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.X1;
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.X2, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.X2;
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.X3, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.X3;
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.X4, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.X4;
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.Y1, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.Y1;
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.Y2, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.Y2;
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.Y3, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.Y3;
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.Y4, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.Y4;
|
||||
if (essgeeKeys.GetKey(StoicGooseKey.Start, mControllerIndex)) CurrLocalSingleAllInput |= (ulong)StoicGooseKey.Start;
|
||||
|
||||
return CurrLocalSingleAllInput;
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,12 @@ public class SGSoundPlayer : MonoBehaviour//, ISoundPlayer
|
||||
private TimeSpan lastElapsed;
|
||||
public double audioFPS { get; private set; }
|
||||
|
||||
//TODO 是否需要和 AudioConfiguration关联起来
|
||||
[HideInInspector]
|
||||
public int sampleRate = 44100;
|
||||
[HideInInspector]
|
||||
public int channle = 2;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// »ñÈ¡µ±Ç°ÒôƵÅäÖÃ
|
||||
|
||||
@ -93,7 +93,6 @@ public class UStoicGoose : EmuCore<ulong>
|
||||
|
||||
Init();
|
||||
|
||||
|
||||
//保存当前正在进行的游戏存档
|
||||
if (emulatorHandler != null && !emulatorHandler.IsRunning)
|
||||
{
|
||||
@ -123,11 +122,17 @@ public class UStoicGoose : EmuCore<ulong>
|
||||
|
||||
public override IControllerSetuper GetControllerSetuper()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return inputHandler.ControllerMapper;
|
||||
}
|
||||
protected override bool OnPushEmulatorFrame(ulong InputData)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
if (!emulatorHandler.IsRunning) return false;
|
||||
//if (!bLogicUpdatePause) return false;
|
||||
|
||||
inputHandler.SetInputData(InputData);
|
||||
|
||||
emulatorHandler.Frame_Update();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override ulong ConvertInputDataFromNet(ReplayStep step)
|
||||
@ -142,17 +147,17 @@ public class UStoicGoose : EmuCore<ulong>
|
||||
|
||||
protected override ulong GetLocalInput()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return inputHandler.Update_InputData();
|
||||
}
|
||||
|
||||
protected override void AfterPushFrame()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void GetAudioParams(out int frequency, out int channels)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
channels = soundHandler.channle;
|
||||
frequency = soundHandler.sampleRate;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@ -177,15 +182,16 @@ public class UStoicGoose : EmuCore<ulong>
|
||||
//Init();
|
||||
//LoadAndRunCartridge("G:/BaiduNetdiskDownload/Rockman & Forte - Mirai Kara no Chousen Sha (J) [M][!].ws");
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (!emulatorHandler.IsRunning)
|
||||
return;
|
||||
|
||||
inputHandler.Update_InputData();
|
||||
//依靠外部核心驱动
|
||||
//private void Update()
|
||||
//{
|
||||
// if (!emulatorHandler.IsRunning)
|
||||
// return;
|
||||
// inputHandler.Update_InputData();
|
||||
// emulatorHandler.Frame_Update();
|
||||
//}
|
||||
|
||||
emulatorHandler.Frame_Update();
|
||||
}
|
||||
void OnDestroy()
|
||||
{
|
||||
EmuClose();
|
||||
|
||||
@ -408,27 +408,28 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
/// 发送修改玩家槽位,但是增量
|
||||
/// </summary>
|
||||
/// <param name="dictSlotIdx2LocalJoyIdx">玩家占用房间GamePlaySlot和LocalJoyIdx字典</param>
|
||||
public void SendChangePlaySlotIdxWithJoyIdx(uint localJoyIndex, uint slotIndex, GamePadType localGamePadType)
|
||||
public void SendChangePlaySlotIdxWithJoyIdx(uint localJoyIndex, uint slotIndex)
|
||||
{
|
||||
if (!App.roomMgr.InRoom) return;
|
||||
|
||||
Dictionary<uint, ValueTuple<uint, GamePadType>> temp = new Dictionary<uint, ValueTuple<uint, GamePadType>>();
|
||||
Dictionary<uint, uint> temp = new Dictionary<uint, uint>();
|
||||
for (int i = 0; i < App.roomMgr.mineRoomMiniInfo.GamePlaySlotList.Count; i++)
|
||||
{
|
||||
var item = App.roomMgr.mineRoomMiniInfo.GamePlaySlotList[i];
|
||||
if (item.PlayerUID <= 0) continue;
|
||||
if (item.PlayerUID != App.user.userdata.UID) return;
|
||||
temp[(uint)i] = new ValueTuple<uint, GamePadType>((uint)item.PlayerLocalJoyIdx, item.PlayerLocalGamePadType);
|
||||
temp[(uint)i] = (uint)item.PlayerLocalJoyIdx;
|
||||
}
|
||||
temp[slotIndex] = new ValueTuple<uint, GamePadType>(localJoyIndex, localGamePadType);
|
||||
temp[slotIndex] = localJoyIndex;
|
||||
|
||||
SendChangePlaySlotIdxWithJoyIdx(temp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送修改玩家槽位,全量
|
||||
/// </summary>
|
||||
/// <param name="dictSlotIdx2LocalJoyIdx">玩家占用房间GamePlaySlot和LocalJoyIdx字典</param>
|
||||
public void SendChangePlaySlotIdxWithJoyIdx(Dictionary<uint, ValueTuple<uint, GamePadType>> dictSlotIdx2LocalJoyIdx)
|
||||
public void SendChangePlaySlotIdxWithJoyIdx(Dictionary<uint, uint> dictSlotIdx2LocalJoyIdx)
|
||||
{
|
||||
if (!InRoom)
|
||||
return;
|
||||
@ -440,8 +441,7 @@ namespace AxibugEmuOnline.Client.Manager
|
||||
_Protobuf_Room_Change_PlaySlotWithJoy.SlotWithJoy.Add(new Protobuf_PlaySlotIdxWithJoyIdx()
|
||||
{
|
||||
PlayerSlotIdx = (int)slotdata.Key,
|
||||
PlayerLocalJoyIdx = (int)slotdata.Value.Item1,
|
||||
PlayerLocalGamePadType = slotdata.Value.Item2,
|
||||
PlayerLocalJoyIdx = (int)slotdata.Value,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ namespace AxibugEmuOnline.Client.Settings
|
||||
Dictionary<Type, InternalEmuCoreBinder> m_bindersByType = new Dictionary<Type, InternalEmuCoreBinder>();
|
||||
public KeyMapperSetting()
|
||||
{
|
||||
//反射拿所有核心的键位绑定
|
||||
var baseType = typeof(InternalEmuCoreBinder);
|
||||
foreach (var t in baseType.Assembly.ExportedTypes)
|
||||
{
|
||||
|
||||
@ -167,8 +167,8 @@ namespace AxibugEmuOnline.Client.Settings
|
||||
controller.SetBinding(UMAMEKSingleKey.DOWN, device.Down, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.LEFT, device.Left, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.RIGHT, device.Right, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.BTN_A, device.A, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.BTN_B, device.B, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.BTN_A, device.B, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.BTN_B, device.A, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.BTN_C, device.X, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.BTN_D, device.Y, 0);
|
||||
controller.SetBinding(UMAMEKSingleKey.BTN_E, device.LeftSL, 0);
|
||||
|
||||
@ -8,8 +8,9 @@ using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟器核心控制器键位绑定器
|
||||
/// <para>用于实现来自<see cref="InputDevicesManager"/>中的输入设备和模拟器的控制器的按键绑定</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T">模拟器平台的控制器类型枚举</typeparam>
|
||||
public abstract class EmuCoreBinder<T> : InternalEmuCoreBinder,
|
||||
IDeviceBinder<T, Keyboard_D>,
|
||||
IDeviceBinder<T, GamePad_D>,
|
||||
@ -20,6 +21,13 @@ public abstract class EmuCoreBinder<T> : InternalEmuCoreBinder,
|
||||
IDeviceBinder<T, SwitchJoyCon_D>
|
||||
where T : Enum
|
||||
{
|
||||
/// <summary>
|
||||
/// 忽略输入设备的独占属性
|
||||
/// false:标记为独占的设备(Exclusive==true)只能绑定到一个控制器上
|
||||
/// true:设备可以被绑定到所有控制器上,无视设备的独占属性
|
||||
/// </summary>
|
||||
protected virtual bool IgnoreInputDeviceExclusive => false;
|
||||
|
||||
//每一个实例代表一个对应模拟器平台的控制器索引
|
||||
List<ControllerBinder> m_controllerBinders = new List<ControllerBinder>();
|
||||
|
||||
@ -36,7 +44,7 @@ public abstract class EmuCoreBinder<T> : InternalEmuCoreBinder,
|
||||
{
|
||||
foreach (var binding in m_controllerBinders)
|
||||
{
|
||||
if (device.Exclusive && GetRegistedBinder(device) != null) continue;
|
||||
if (!CheckDeviceCanBind(device)) break;
|
||||
|
||||
binding.RegistInputDevice(device);
|
||||
}
|
||||
@ -63,11 +71,20 @@ public abstract class EmuCoreBinder<T> : InternalEmuCoreBinder,
|
||||
{
|
||||
foreach (var binding in m_controllerBinders)
|
||||
{
|
||||
if (connectDevice.Exclusive && GetRegistedBinder(connectDevice) != null) continue;
|
||||
if (!CheckDeviceCanBind(connectDevice)) return;
|
||||
binding.RegistInputDevice(connectDevice);
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckDeviceCanBind(InputDevice_D device)
|
||||
{
|
||||
if (IgnoreInputDeviceExclusive) return true;
|
||||
if (!device.Exclusive) return true;
|
||||
|
||||
//当一个输入设备的Exclusive为true时,只能绑定到一个控制器
|
||||
return GetRegistedBinder(device) == null;
|
||||
}
|
||||
|
||||
private void InputDevicesMgr_OnDeviceLost(InputDevice_D lostDevice)
|
||||
{
|
||||
foreach (var binding in m_controllerBinders)
|
||||
|
||||
@ -0,0 +1,155 @@
|
||||
using AxibugEmuOnline.Client.InputDevices;
|
||||
using AxibugProtobuf;
|
||||
using StoicGooseUnity;
|
||||
|
||||
namespace AxibugEmuOnline.Client.Settings
|
||||
{
|
||||
public abstract class StoicGooseBinding : EmuCoreBinder<StoicGooseKey>
|
||||
{
|
||||
public override void Bind(Keyboard_D device, ControllerBinder controller)
|
||||
{
|
||||
switch (controller.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
controller.SetBinding(StoicGooseKey.Start, device.Return, 0);
|
||||
controller.SetBinding(StoicGooseKey.X1, device.W, 0);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.S, 0);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.A, 0);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.D, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y1, device.G, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y2, device.V, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y3, device.C, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y4, device.B, 0);
|
||||
controller.SetBinding(StoicGooseKey.B, device.J, 0);
|
||||
controller.SetBinding(StoicGooseKey.A, device.K, 0);
|
||||
break;
|
||||
case 1:
|
||||
controller.SetBinding(StoicGooseKey.Start, device.KeypadEnter, 0);
|
||||
controller.SetBinding(StoicGooseKey.X1, device.UpArrow, 0);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.DownArrow, 0);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.LeftArrow, 0);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.RightArrow, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y1, device.Home, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y2, device.End, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y3, device.Delete, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y4, device.PageDown, 0);
|
||||
controller.SetBinding(StoicGooseKey.B, device.Keypad1, 0);
|
||||
controller.SetBinding(StoicGooseKey.A, device.Keypad2, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public override void Bind(PSVController_D device, ControllerBinder controller)
|
||||
{
|
||||
switch (controller.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
|
||||
|
||||
controller.SetBinding(StoicGooseKey.Start, device.Start, 0);
|
||||
controller.SetBinding(StoicGooseKey.X1, device.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y1, device.RightStick.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y2, device.RightStick.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y3, device.RightStick.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y4, device.RightStick.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.B, device.Cross, 0);
|
||||
controller.SetBinding(StoicGooseKey.A, device.Circle, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
public override void Bind(DualShockController_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(StoicGooseKey.Start, device.Options, 0);
|
||||
controller.SetBinding(StoicGooseKey.X1, device.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y1, device.RightStick.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y2, device.RightStick.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y3, device.RightStick.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y4, device.RightStick.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.B, device.Cross, 0);
|
||||
controller.SetBinding(StoicGooseKey.A, device.Circle, 0);
|
||||
}
|
||||
public override void Bind(GamePad_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(StoicGooseKey.Start, device.Start, 0);
|
||||
controller.SetBinding(StoicGooseKey.X1, device.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y1, device.RightStick.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y2, device.RightStick.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y3, device.RightStick.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y4, device.RightStick.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.B, device.South, 0);
|
||||
controller.SetBinding(StoicGooseKey.A, device.East, 0);
|
||||
}
|
||||
public override void Bind(XboxController_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(StoicGooseKey.Start, device.Menu, 0);
|
||||
controller.SetBinding(StoicGooseKey.X1, device.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y1, device.RightStick.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y2, device.RightStick.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y3, device.RightStick.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y4, device.RightStick.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.B, device.A, 0);
|
||||
controller.SetBinding(StoicGooseKey.A, device.B, 0);
|
||||
}
|
||||
public override void Bind(ScreenGamepad_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(StoicGooseKey.Start, device.OPTION_1, 0);
|
||||
controller.SetBinding(StoicGooseKey.X1, device.UP, 0);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.DOWN, 0);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.LEFT, 0);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.RIGHT, 0);
|
||||
|
||||
controller.SetBinding(StoicGooseKey.X1, device.JOYSTICK.Left, 1);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.JOYSTICK.Right, 1);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.JOYSTICK.Up, 1);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.JOYSTICK.Down, 1);
|
||||
|
||||
//屏幕暂时没有第二个方向控制暂时用CDEF代替
|
||||
controller.SetBinding(StoicGooseKey.Y1, device.BTN_C, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y2, device.BTN_D, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y3, device.BTN_E, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y4, device.BTN_F, 0);
|
||||
|
||||
controller.SetBinding(StoicGooseKey.B, device.BTN_A, 0);
|
||||
controller.SetBinding(StoicGooseKey.A, device.BTN_B, 0);
|
||||
}
|
||||
|
||||
public override void Bind(SwitchJoyCon_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(StoicGooseKey.Start, device.Plus, 0);
|
||||
controller.SetBinding(StoicGooseKey.X1, device.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.X2, device.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.X3, device.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.X4, device.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y1, device.RightStick.Up, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y2, device.RightStick.Down, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y3, device.RightStick.Left, 0);
|
||||
controller.SetBinding(StoicGooseKey.Y4, device.RightStick.Right, 0);
|
||||
controller.SetBinding(StoicGooseKey.B, device.A, 0);
|
||||
controller.SetBinding(StoicGooseKey.A, device.B, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public class WonderSwanColorKeyBinding : StoicGooseBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.WonderSwanColor;
|
||||
public override int ControllerCount => 1;
|
||||
}
|
||||
|
||||
public class WonderSwanBinding : StoicGooseBinding
|
||||
{
|
||||
public override RomPlatformType Platform => RomPlatformType.WonderSwan;
|
||||
public override int ControllerCount => 1;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faa0295df1a7a0c43bf9fc9f717f7513
|
||||
@ -1,10 +1,12 @@
|
||||
using AxibugEmuOnline.Client.InputDevices;
|
||||
using AxibugProtobuf;
|
||||
using static AxibugEmuOnline.Client.NesControllerMapper;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class XMBKeyBinding : EmuCoreBinder<EnumCommand>
|
||||
{
|
||||
protected override bool IgnoreInputDeviceExclusive => true;
|
||||
public override RomPlatformType Platform => RomPlatformType.Invalid;
|
||||
public override int ControllerCount => 2;
|
||||
|
||||
@ -39,93 +41,145 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
public override void Bind(DualShockController_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(EnumCommand.Back, device.Circle, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.Cross, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Options, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
switch (controller.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
controller.SetBinding(EnumCommand.Back, device.Circle, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.Cross, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Options, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
break;
|
||||
case 1:
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.TouchpadBtn, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.R3, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public override void Bind(GamePad_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(EnumCommand.Back, device.East, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.South, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Start, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
switch (controller.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
controller.SetBinding(EnumCommand.Back, device.East, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.South, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Start, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
break;
|
||||
case 1:
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.RightStickPress, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
}
|
||||
public override void Bind(PSVController_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(EnumCommand.Back, device.Circle, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.Cross, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Start, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
switch (controller.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
controller.SetBinding(EnumCommand.Back, device.Circle, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.Cross, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Start, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
break;
|
||||
case 1:
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Triangle, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
}
|
||||
public override void Bind(XboxController_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(EnumCommand.Back, device.B, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.A, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Menu, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
switch (controller.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
controller.SetBinding(EnumCommand.Back, device.B, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.A, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Menu, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
break;
|
||||
case 1:
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.RightStickPress, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
}
|
||||
public override void Bind(ScreenGamepad_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(EnumCommand.Back, device.BTN_A, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.BTN_B, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.OPTION_1, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.DOWN, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LEFT, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.RIGHT, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.UP, 0);
|
||||
switch (controller.ControllerIndex)
|
||||
{
|
||||
case 0:
|
||||
controller.SetBinding(EnumCommand.Back, device.BTN_A, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.BTN_B, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.OPTION_1, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.DOWN, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LEFT, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.RIGHT, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.UP, 0);
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.JOYSTICK.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.JOYSTICK.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.JOYSTICK.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.JOYSTICK.Up, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.JOYSTICK.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.JOYSTICK.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.JOYSTICK.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.JOYSTICK.Up, 1);
|
||||
break;
|
||||
case 1:
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.HOME, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public override void Bind(SwitchJoyCon_D device, ControllerBinder controller)
|
||||
{
|
||||
controller.SetBinding(EnumCommand.Back, device.A, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.B, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Plus, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
switch (controller.ControllerIndex)
|
||||
{
|
||||
case 0://设置标准UI控制
|
||||
controller.SetBinding(EnumCommand.Back, device.B, 0);
|
||||
controller.SetBinding(EnumCommand.Enter, device.A, 0);
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.Plus, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.Down, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.Left, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.Right, 0);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.Up, 0);
|
||||
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemDown, device.LeftStick.Down, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemLeft, device.LeftStick.Left, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemRight, device.LeftStick.Right, 1);
|
||||
controller.SetBinding(EnumCommand.SelectItemUp, device.LeftStick.Up, 1);
|
||||
break;
|
||||
case 1://游戏中UI控制
|
||||
controller.SetBinding(EnumCommand.OptionMenu, device.RightStickPress, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,13 @@ public interface IControllerSetuper
|
||||
uint? con2ToSlot = null,
|
||||
uint? con3ToSlot = null);
|
||||
|
||||
/// <summary>
|
||||
/// 增量式的修改一个手柄和一个槽位的连接关系
|
||||
/// </summary>
|
||||
/// <param name="conIndex"></param>
|
||||
/// <param name="slotIndex"></param>
|
||||
void LetControllerConnect(int conIndex, uint slotIndex);
|
||||
|
||||
/// <summary>
|
||||
/// 指定手柄插槽位,获取当前槽位连接的本地手柄序号
|
||||
/// </summary>
|
||||
@ -26,12 +33,7 @@ public interface IControllerSetuper
|
||||
/// <returns></returns>
|
||||
uint? GetFreeSlotIndex();
|
||||
|
||||
/// <summary>
|
||||
/// 增量式的修改一个手柄和一个槽位的连接关系
|
||||
/// </summary>
|
||||
/// <param name="conIndex"></param>
|
||||
/// <param name="slotIndex"></param>
|
||||
void LetControllerConnect(int conIndex, uint slotIndex);
|
||||
|
||||
}
|
||||
public interface IController
|
||||
{
|
||||
|
||||
@ -18,20 +18,22 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
{
|
||||
var axis = GetVector2();
|
||||
|
||||
Up.m_performing = axis.y > 0f;
|
||||
var dir = GetDirection(axis, 0.15f);
|
||||
Up.m_performing = dir == Direction.Up;
|
||||
Up.Update();
|
||||
|
||||
Down.m_performing = axis.y < 0f;
|
||||
Down.m_performing = dir == Direction.Down;
|
||||
Down.Update();
|
||||
|
||||
Left.m_performing = axis.x < 0f;
|
||||
Left.m_performing = dir == Direction.Left;
|
||||
Left.Update();
|
||||
|
||||
Right.m_performing = axis.x > 0f;
|
||||
Right.m_performing = dir == Direction.Right;
|
||||
Right.Update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class VirtualButton : InputControl_C
|
||||
{
|
||||
internal bool m_performing;
|
||||
@ -53,5 +55,66 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
return Performing ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
enum Direction
|
||||
{
|
||||
None,
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
|
||||
static Direction GetDirection(Vector2 input, float deadzone)
|
||||
{
|
||||
// 检查死区:如果点在死区半径内,返回无
|
||||
if (input.magnitude <= deadzone)
|
||||
{
|
||||
return Direction.None;
|
||||
}
|
||||
|
||||
// 标准化向量(确保在单位圆上)
|
||||
Vector2 normalized = input.normalized;
|
||||
|
||||
// 计算点与四个方向基准向量的点积
|
||||
float dotUp = Vector2.Dot(normalized, Vector2.up); // (0, 1)
|
||||
float dotDown = Vector2.Dot(normalized, Vector2.down); // (0, -1)
|
||||
float dotRight = Vector2.Dot(normalized, Vector2.right); // (1, 0)
|
||||
float dotLeft = Vector2.Dot(normalized, Vector2.left); // (-1, 0)
|
||||
|
||||
// 找出最大点积对应的方向
|
||||
Direction bestDirection = Direction.None;
|
||||
float maxDot = -1f; // 初始化为最小值
|
||||
|
||||
// 检查上方向
|
||||
if (dotUp > maxDot)
|
||||
{
|
||||
maxDot = dotUp;
|
||||
bestDirection = Direction.Up;
|
||||
}
|
||||
|
||||
// 检查下方向
|
||||
if (dotDown > maxDot)
|
||||
{
|
||||
maxDot = dotDown;
|
||||
bestDirection = Direction.Down;
|
||||
}
|
||||
|
||||
// 检查右方向
|
||||
if (dotRight > maxDot)
|
||||
{
|
||||
maxDot = dotRight;
|
||||
bestDirection = Direction.Right;
|
||||
}
|
||||
|
||||
// 检查左方向
|
||||
if (dotLeft > maxDot)
|
||||
{
|
||||
bestDirection = Direction.Left;
|
||||
}
|
||||
|
||||
return bestDirection;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,9 +6,21 @@ namespace AxibugEmuOnline.Client.InputDevices
|
||||
{
|
||||
public override GamePadType PadType => GamePadType.PsvitaControl;
|
||||
|
||||
/// <summary>
|
||||
/// X
|
||||
/// </summary>
|
||||
public Button_C Cross;
|
||||
/// <summary>
|
||||
/// O
|
||||
/// </summary>
|
||||
public Button_C Circle;
|
||||
/// <summary>
|
||||
/// 方框
|
||||
/// </summary>
|
||||
public Button_C Square;
|
||||
/// <summary>
|
||||
/// 三角
|
||||
/// </summary>
|
||||
public Button_C Triangle;
|
||||
public Button_C L;
|
||||
public Button_C R;
|
||||
|
||||
@ -125,16 +125,13 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
m_delayCreateRoom = false;
|
||||
//延迟创建房间成功后,同步本地手柄连接状态
|
||||
Dictionary<uint, ValueTuple<uint, GamePadType>> temp = new Dictionary<uint, ValueTuple<uint, GamePadType>>();
|
||||
Dictionary<uint, uint> temp = new Dictionary<uint, uint>();
|
||||
var setuper = App.emu.Core.GetControllerSetuper();
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (uint i = 0; i < 4; i++)
|
||||
{
|
||||
var joyIndex = setuper.GetSlotConnectingControllerIndex(i);
|
||||
var joyIndex = setuper.GetSlotConnectingControllerIndex((int)i);
|
||||
|
||||
//TODO 手柄类型
|
||||
GamePadType gpType = GamePadType.GlobalGamePad;
|
||||
|
||||
if (joyIndex != null) temp[(uint)i] = new ValueTuple<uint, GamePadType>((uint)joyIndex.Value, gpType);
|
||||
if (joyIndex != null) temp[i] = (uint)joyIndex.Value;
|
||||
}
|
||||
App.roomMgr.SendChangePlaySlotIdxWithJoyIdx(temp);
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ public class ControllerInfo : MonoBehaviour
|
||||
[SerializeField]
|
||||
Text m_playerName;
|
||||
private bool m_islocal;
|
||||
private Tweener m_tween;
|
||||
|
||||
public int SlotIndex
|
||||
{
|
||||
@ -67,7 +68,16 @@ public class ControllerInfo : MonoBehaviour
|
||||
if (controller == null) return;
|
||||
if (!controller.AnyButtonDown()) return;
|
||||
|
||||
m_indexIcon.rectTransform.DOShakePosition(0.1f);
|
||||
if (m_tween != null)
|
||||
{
|
||||
m_indexIcon.rectTransform.anchoredPosition = Vector2.zero;
|
||||
m_tween.Kill();
|
||||
m_tween = null;
|
||||
}
|
||||
m_tween = m_indexIcon.rectTransform.DOShakePosition(0.1f).SetLink(gameObject).OnComplete(() =>
|
||||
{
|
||||
m_tween = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +104,6 @@ public class ControllerInfo : MonoBehaviour
|
||||
{
|
||||
SetDisconnect();
|
||||
return;
|
||||
|
||||
}
|
||||
var connecter = App.emu.Core.GetControllerSetuper();
|
||||
|
||||
|
||||
@ -28,10 +28,7 @@ public class ControllerInfoPanel : MonoBehaviour
|
||||
//找到第一个空闲手柄插槽
|
||||
var freeSlotIndex = s_freeSlots[0];
|
||||
|
||||
//TODO 手柄类型
|
||||
GamePadType gpType = GamePadType.GlobalGamePad;
|
||||
|
||||
App.roomMgr.SendChangePlaySlotIdxWithJoyIdx((uint)joyIndex, (uint)freeSlotIndex, gpType);
|
||||
App.roomMgr.SendChangePlaySlotIdxWithJoyIdx((uint)joyIndex, (uint)freeSlotIndex);
|
||||
}
|
||||
else //不在房间中,直接设置
|
||||
{
|
||||
|
||||
@ -347,14 +347,13 @@ namespace VirtualNes.Core
|
||||
catch (Exception ex)
|
||||
{
|
||||
fp?.Close();
|
||||
Debuger.LogError($"Loading TurboFile Error.\n{ex}");
|
||||
//Debuger.LogError($"Loading TurboFile Error.\n{ex}");
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadDISK()
|
||||
{
|
||||
//todo : 磁碟机读取支持
|
||||
Debuger.LogError($"磁碟机尚未支持");
|
||||
//todo : 磁碟机读取支持 by alienjack
|
||||
}
|
||||
|
||||
private void LoadSRAM()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user