forked from sin365/AxibugEmuOnline
fuck InputSystem!
This commit is contained in:
parent
08bdb552c9
commit
d7269175cd
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6178d336be6488b46aed623405e79f7b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,304 +0,0 @@
|
||||
{
|
||||
"name": "New Controls",
|
||||
"maps": [
|
||||
{
|
||||
"name": "UI_Normal",
|
||||
"id": "9a397a4f-4d88-492f-a918-bf9b8d3be756",
|
||||
"actions": [
|
||||
{
|
||||
"name": "SelectItemLeft",
|
||||
"type": "Button",
|
||||
"id": "107019fe-240c-46ff-8c62-cb385ef8b9af",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "SelectItemRight",
|
||||
"type": "Button",
|
||||
"id": "826dd3f1-2cf8-4169-97c8-dfb56b850143",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "SelectItemUp",
|
||||
"type": "Button",
|
||||
"id": "505dabb4-91f7-430c-8696-092690269639",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "SelectItemDown",
|
||||
"type": "Button",
|
||||
"id": "b3da8633-7f50-44b3-8302-50706e589307",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Enter",
|
||||
"type": "Button",
|
||||
"id": "0bdf3154-e1db-4044-af50-cacb3764a07c",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Back",
|
||||
"type": "Button",
|
||||
"id": "68074d67-61a1-4a4d-bd68-8398b0e7afe3",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "OptionMenu",
|
||||
"type": "Button",
|
||||
"id": "64b67280-c530-4e38-b3ff-8d0177591396",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "fc724bf2-7736-419c-9f46-19bd45a0d276",
|
||||
"path": "<Keyboard>/a",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "SelectItemLeft",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "02f4433e-4417-4fef-b178-a616e2941311",
|
||||
"path": "<Keyboard>/leftArrow",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "SelectItemLeft",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "cb874e72-d3db-4024-b9fb-37190acd9568",
|
||||
"path": "<Keyboard>/d",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "SelectItemRight",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "646b923b-4d3d-4b5c-9dd2-0119e9d3e2c5",
|
||||
"path": "<Keyboard>/rightArrow",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "SelectItemRight",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "28fa0139-d5a2-4e26-87af-2043e01234e6",
|
||||
"path": "<Keyboard>/w",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "SelectItemUp",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "4474efdf-70ff-4826-883c-2fdf9f96e78e",
|
||||
"path": "<Keyboard>/upArrow",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "SelectItemUp",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "392a8cbc-71f6-4282-b945-4c7b3d17ba3a",
|
||||
"path": "<Keyboard>/s",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "SelectItemDown",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "f30b6fb3-147e-4997-b628-fab3f635192b",
|
||||
"path": "<Keyboard>/downArrow",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "SelectItemDown",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "70c6db12-432b-482d-99a1-71e002c30157",
|
||||
"path": "<Keyboard>/k",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "Enter",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "48d5c450-6ac3-40fb-8ff4-66c7f3b3a00b",
|
||||
"path": "<Keyboard>/enter",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "Enter",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "ef83ae7c-a809-4f23-a206-102199a5ede3",
|
||||
"path": "<Keyboard>/l",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "Back",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "14b503c8-80a1-458c-9e0f-a3fa38f314be",
|
||||
"path": "<Keyboard>/backspace",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "Back",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "e1e12f45-fb41-4b78-adbf-add2881bd4b1",
|
||||
"path": "<Keyboard>/i",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "OptionMenu",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "0b010e17-3581-42e6-90b1-f1bf728a3a0c",
|
||||
"path": "<Keyboard>/shift",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "OptionMenu",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "UI_InGame",
|
||||
"id": "2c8af03e-03e7-4553-81c6-dcff543cdcdc",
|
||||
"actions": [
|
||||
{
|
||||
"name": "OptionMenu",
|
||||
"type": "Button",
|
||||
"id": "cab3c346-07e2-4c0c-8377-cb934dd28bd3",
|
||||
"expectedControlType": "Button",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "28d4d045-1070-4ea0-be35-b5ffb1c33bcb",
|
||||
"path": "<Keyboard>/escape",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "Keyboard",
|
||||
"action": "OptionMenu",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": [
|
||||
{
|
||||
"name": "Keyboard",
|
||||
"bindingGroup": "Keyboard",
|
||||
"devices": [
|
||||
{
|
||||
"devicePath": "<Keyboard>",
|
||||
"isOptional": false,
|
||||
"isOR": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "UniversalGamePad",
|
||||
"bindingGroup": "UniversalGamePad",
|
||||
"devices": [
|
||||
{
|
||||
"devicePath": "<Gamepad>",
|
||||
"isOptional": false,
|
||||
"isOR": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Xbox Controller",
|
||||
"bindingGroup": "Xbox Controller",
|
||||
"devices": [
|
||||
{
|
||||
"devicePath": "<XInputController>",
|
||||
"isOptional": false,
|
||||
"isOR": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PlayStation Controller",
|
||||
"bindingGroup": "PlayStation Controller",
|
||||
"devices": [
|
||||
{
|
||||
"devicePath": "<DualShockGamepad>",
|
||||
"isOptional": false,
|
||||
"isOR": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb413fd14a8483440af9652b7e4df5e1
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 0
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace: InputSystem
|
@ -458,6 +458,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 39557e19783acee499ace6c68549e8f8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
InputTemplate: {fileID: 0}
|
||||
VideoProvider: {fileID: 4232056520112715744}
|
||||
AudioProvider: {fileID: 9003897287163669553}
|
||||
m_bPause: 0
|
||||
|
@ -13427,7 +13427,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 4471d8231d16ba3469228e09d4cb3a81, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
LegacyInput: 0
|
||||
--- !u!4 &1427887270
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -13731,7 +13730,6 @@ RectTransform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_Children:
|
||||
- {fileID: 2073453794}
|
||||
- {fileID: 1983793178}
|
||||
- {fileID: 246947326}
|
||||
- {fileID: 1318590597}
|
||||
@ -13832,99 +13830,6 @@ RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 1639091784002085428, guid: 450328d5a907c8249a60bc3980ba66f6, type: 3}
|
||||
m_PrefabInstance: {fileID: 730698711}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &2073453793
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2073453794}
|
||||
- component: {fileID: 2073453795}
|
||||
m_Layer: 0
|
||||
m_Name: UI_Input
|
||||
m_TagString: UIInput
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2073453794
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2073453793}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -10799.999}
|
||||
m_LocalScale: {x: 108, y: 108, z: 108}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1599240741}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2073453795
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2073453793}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 62899f850307741f2a39c98a8b639597, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Actions: {fileID: -944628639613478452, guid: eb413fd14a8483440af9652b7e4df5e1, type: 3}
|
||||
m_NotificationBehavior: 3
|
||||
m_UIInputModule: {fileID: 74796457}
|
||||
m_DeviceLostEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_DeviceRegainedEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ControlsChangedEvent:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionEvents:
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 107019fe-240c-46ff-8c62-cb385ef8b9af
|
||||
m_ActionName: UI_Normal/SelectItemLeft
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 826dd3f1-2cf8-4169-97c8-dfb56b850143
|
||||
m_ActionName: UI_Normal/SelectItemRight
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 505dabb4-91f7-430c-8696-092690269639
|
||||
m_ActionName: UI_Normal/SelectItemUp
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: b3da8633-7f50-44b3-8302-50706e589307
|
||||
m_ActionName: UI_Normal/SelectItemDown
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 0bdf3154-e1db-4044-af50-cacb3764a07c
|
||||
m_ActionName: UI_Normal/Enter
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 68074d67-61a1-4a4d-bd68-8398b0e7afe3
|
||||
m_ActionName: UI_Normal/Back
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: 64b67280-c530-4e38-b3ff-8d0177591396
|
||||
m_ActionName: UI_Normal/OptionMenu
|
||||
- m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_ActionId: cab3c346-07e2-4c0c-8377-cb934dd28bd3
|
||||
m_ActionName: UI_InGame/OptionMenu
|
||||
m_NeverAutoSwitchControlSchemes: 0
|
||||
m_DefaultControlScheme: Keyboard
|
||||
m_DefaultActionMap: UI_Normal
|
||||
m_SplitScreenIndex: -1
|
||||
m_Camera: {fileID: 0}
|
||||
--- !u!1001 &1963501580473600373
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -5,7 +5,6 @@ using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.Scripting;
|
||||
using static AxibugEmuOnline.Client.HttpAPI;
|
||||
using static AxibugEmuOnline.Client.Manager.LogManager;
|
||||
|
||||
@ -38,11 +37,6 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
#else
|
||||
public static string PersistentDataPath => Application.persistentDataPath;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//[Preserve]
|
||||
//[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
|
||||
public static void Init()
|
||||
{
|
||||
settings = new AppSettings();
|
||||
@ -162,7 +156,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
||||
}
|
||||
static void OnNoSugarNetLog(int LogLevel, string msg)
|
||||
{
|
||||
E_LogType logType =(E_LogType)LogLevel;
|
||||
E_LogType logType = (E_LogType)LogLevel;
|
||||
switch (logType)
|
||||
{
|
||||
case E_LogType.Debug:
|
||||
|
@ -15,6 +15,7 @@ namespace AxibugEmuOnline.Client
|
||||
void SetupScheme();
|
||||
void StartGame(RomFile romFile);
|
||||
void DoReset();
|
||||
EnumPlatform Platform { get; }
|
||||
uint Frame { get; }
|
||||
}
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class GamingChanger : CommandChanger
|
||||
{
|
||||
public override object GetConfig()
|
||||
{
|
||||
return "UI_InGame";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5b6687e9412f174d82b2c15f1efc4a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,10 +0,0 @@
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class NormalChanger : CommandChanger
|
||||
{
|
||||
public override object GetConfig()
|
||||
{
|
||||
return "UI_Normal";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8aa965a6a15aa1a4195977111b1ec13b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,5 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxiReplay;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
@ -57,7 +56,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
|
||||
public EmulatorConfig Config { get; private set; } = new EmulatorConfig();
|
||||
|
||||
public NesControllerMapper ControllerMapper { get; private set; } = new NesControllerMapper();
|
||||
public void PrepareDirectory(string directPath)
|
||||
{
|
||||
Directory.CreateDirectory($"{App.PersistentDataPath}/{directPath}");
|
||||
@ -115,7 +114,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
else m_sampledState = default;
|
||||
|
||||
var localState = NesControllerMapper.Get().CreateState();
|
||||
var localState = ControllerMapper.CreateState();
|
||||
var rawData = ToNet(localState);
|
||||
if (LastTestInput != rawData)
|
||||
{
|
||||
@ -126,7 +125,7 @@ namespace AxibugEmuOnline.Client
|
||||
}
|
||||
else
|
||||
{
|
||||
m_sampledState = NesControllerMapper.Get().CreateState();
|
||||
m_sampledState = ControllerMapper.CreateState();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using VirtualNes.Core;
|
||||
|
||||
@ -8,36 +7,10 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class NesControllerMapper
|
||||
{
|
||||
private static readonly string ConfigFilePath = $"{App.PersistentDataPath}/NES/ControllerMapper.json";
|
||||
|
||||
public MapperSetter Player1 = new MapperSetter();
|
||||
public MapperSetter Player2 = new MapperSetter();
|
||||
public MapperSetter Player3 = new MapperSetter();
|
||||
public MapperSetter Player4 = new MapperSetter();
|
||||
|
||||
public NesControllerMapper()
|
||||
{
|
||||
Player1.UP.keyCode = KeyCode.W;
|
||||
Player1.DOWN.keyCode = KeyCode.S;
|
||||
Player1.LEFT.keyCode = KeyCode.A;
|
||||
Player1.RIGHT.keyCode = KeyCode.D;
|
||||
Player1.B.keyCode = KeyCode.J;
|
||||
Player1.A.keyCode = KeyCode.K;
|
||||
Player1.SELECT.keyCode = KeyCode.V;
|
||||
Player1.START.keyCode = KeyCode.B;
|
||||
|
||||
//PC XBOX
|
||||
//Player1.B.keyCode = Common.PC_XBOXKEY.A;
|
||||
//Player1.A.keyCode = Common.PC_XBOXKEY.B;
|
||||
//Player1.SELECT.keyCode = Common.PC_XBOXKEY.ViewBtn;
|
||||
//Player1.START.keyCode = Common.PC_XBOXKEY.MenuBtn;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
var jsonStr = JsonUtility.ToJson(this);
|
||||
File.WriteAllText(ConfigFilePath, jsonStr);
|
||||
}
|
||||
public MapperSetter Player1 = new MapperSetter(1);
|
||||
public MapperSetter Player2 = new MapperSetter(2);
|
||||
public MapperSetter Player3 = new MapperSetter(3);
|
||||
public MapperSetter Player4 = new MapperSetter(4);
|
||||
|
||||
public ControllerState CreateState()
|
||||
{
|
||||
@ -46,86 +19,189 @@ namespace AxibugEmuOnline.Client
|
||||
var state3 = Player3.GetButtons();
|
||||
var state4 = Player4.GetButtons();
|
||||
|
||||
return new ControllerState(state1, state2, state3, state4);
|
||||
var result = new ControllerState(state1, state2, state3, state4);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static NesControllerMapper s_setting;
|
||||
public static NesControllerMapper Get()
|
||||
{
|
||||
if (s_setting == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText($"{App.PersistentDataPath}/Nes/ControllerMapper.json");
|
||||
s_setting = JsonUtility.FromJson<NesControllerMapper>(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
s_setting = new NesControllerMapper();
|
||||
}
|
||||
}
|
||||
|
||||
return s_setting;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Mapper
|
||||
{
|
||||
public EnumButtonType buttonType;
|
||||
public KeyCode keyCode;
|
||||
MapperSetter m_setter;
|
||||
EnumButtonType m_buttonType;
|
||||
IKeyListener m_keyListener;
|
||||
int m_controllerIndex => m_setter.ControllerIndex;
|
||||
|
||||
public Mapper(EnumButtonType buttonType)
|
||||
public Mapper(MapperSetter setter, EnumButtonType buttonType)
|
||||
{
|
||||
this.buttonType = buttonType;
|
||||
m_setter = setter;
|
||||
m_buttonType = buttonType;
|
||||
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
private void loadConfig()
|
||||
{
|
||||
m_keyListener = MapperSetter.GetKey_Legacy(m_controllerIndex, m_buttonType);
|
||||
|
||||
}
|
||||
|
||||
public EnumButtonType SampleKey()
|
||||
{
|
||||
return m_keyListener.IsPressing() ? m_buttonType : 0;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class MapperSetter
|
||||
{
|
||||
public Mapper UP = new Mapper(EnumButtonType.UP);
|
||||
public Mapper DOWN = new Mapper(EnumButtonType.DOWN);
|
||||
public Mapper LEFT = new Mapper(EnumButtonType.LEFT);
|
||||
public Mapper RIGHT = new Mapper(EnumButtonType.RIGHT);
|
||||
public Mapper A = new Mapper(EnumButtonType.A);
|
||||
public Mapper B = new Mapper(EnumButtonType.B);
|
||||
public Mapper SELECT = new Mapper(EnumButtonType.SELECT);
|
||||
public Mapper START = new Mapper(EnumButtonType.START);
|
||||
public Mapper MIC = new Mapper(EnumButtonType.MIC);
|
||||
/// <summary> 控制器序号(手柄1,2,3,4) </summary>
|
||||
public int ControllerIndex { get; }
|
||||
public Mapper UP { get; private set; }
|
||||
public Mapper DOWN { get; private set; }
|
||||
public Mapper LEFT { get; private set; }
|
||||
public Mapper RIGHT { get; private set; }
|
||||
public Mapper A { get; private set; }
|
||||
public Mapper B { get; private set; }
|
||||
public Mapper SELECT { get; private set; }
|
||||
public Mapper START { get; private set; }
|
||||
public Mapper MIC { get; private set; }
|
||||
|
||||
public MapperSetter(int controllerIndex)
|
||||
{
|
||||
ControllerIndex = controllerIndex;
|
||||
UP = new Mapper(this, EnumButtonType.UP);
|
||||
DOWN = new Mapper(this, EnumButtonType.DOWN);
|
||||
LEFT = new Mapper(this, EnumButtonType.LEFT);
|
||||
RIGHT = new Mapper(this, EnumButtonType.RIGHT);
|
||||
A = new Mapper(this, EnumButtonType.A);
|
||||
B = new Mapper(this, EnumButtonType.B);
|
||||
SELECT = new Mapper(this, EnumButtonType.SELECT);
|
||||
START = new Mapper(this, EnumButtonType.START);
|
||||
MIC = new Mapper(this, EnumButtonType.MIC);
|
||||
}
|
||||
|
||||
public EnumButtonType GetButtons()
|
||||
{
|
||||
EnumButtonType res = 0;
|
||||
|
||||
if (Input.GetKey(UP.keyCode))
|
||||
res |= EnumButtonType.UP;
|
||||
|
||||
if (Input.GetKey(DOWN.keyCode))
|
||||
res |= EnumButtonType.DOWN;
|
||||
|
||||
if (Input.GetKey(LEFT.keyCode))
|
||||
res |= EnumButtonType.LEFT;
|
||||
|
||||
if (Input.GetKey(RIGHT.keyCode))
|
||||
res |= EnumButtonType.RIGHT;
|
||||
|
||||
if (Input.GetKey(A.keyCode))
|
||||
res |= EnumButtonType.A;
|
||||
|
||||
if (Input.GetKey(B.keyCode))
|
||||
res |= EnumButtonType.B;
|
||||
|
||||
if (Input.GetKey(SELECT.keyCode))
|
||||
res |= EnumButtonType.SELECT;
|
||||
|
||||
if (Input.GetKey(START.keyCode))
|
||||
res |= EnumButtonType.START;
|
||||
|
||||
if (Input.GetKey(MIC.keyCode))
|
||||
res |= EnumButtonType.MIC;
|
||||
res |= UP.SampleKey();
|
||||
res |= DOWN.SampleKey();
|
||||
res |= LEFT.SampleKey();
|
||||
res |= RIGHT.SampleKey();
|
||||
res |= A.SampleKey();
|
||||
res |= B.SampleKey();
|
||||
res |= SELECT.SampleKey();
|
||||
res |= START.SampleKey();
|
||||
res |= MIC.SampleKey();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public static IKeyListener GetKey_Legacy(int controllerInput, EnumButtonType nesConBtnType)
|
||||
{
|
||||
string configKey = $"NES_{controllerInput}_{nesConBtnType}";
|
||||
|
||||
if (PlayerPrefs.HasKey(configKey))
|
||||
{
|
||||
return new KeyListener_Legacy(PlayerPrefs.GetString(configKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
var defaultKeyCode = GetDefaultKey();
|
||||
PlayerPrefs.SetString(configKey, defaultKeyCode.ToString());
|
||||
return defaultKeyCode;
|
||||
}
|
||||
|
||||
KeyListener_Legacy GetDefaultKey()
|
||||
{
|
||||
switch (controllerInput)
|
||||
{
|
||||
case 1:
|
||||
if (nesConBtnType == EnumButtonType.LEFT) return new KeyListener_Legacy(KeyCode.A, KeyCode.Joystick1Button12);
|
||||
if (nesConBtnType == EnumButtonType.RIGHT) return new KeyListener_Legacy(KeyCode.D, KeyCode.Joystick1Button13);
|
||||
if (nesConBtnType == EnumButtonType.UP) return new KeyListener_Legacy(KeyCode.W, KeyCode.Joystick1Button10);
|
||||
if (nesConBtnType == EnumButtonType.DOWN) return new KeyListener_Legacy(KeyCode.S, KeyCode.Joystick1Button11);
|
||||
if (nesConBtnType == EnumButtonType.START) return new KeyListener_Legacy(KeyCode.B, KeyCode.Joystick1Button7);
|
||||
if (nesConBtnType == EnumButtonType.SELECT) return new KeyListener_Legacy(KeyCode.V, KeyCode.Joystick1Button6);
|
||||
if (nesConBtnType == EnumButtonType.A) return new KeyListener_Legacy(KeyCode.K, KeyCode.Joystick1Button1);
|
||||
if (nesConBtnType == EnumButtonType.B) return new KeyListener_Legacy(KeyCode.J, KeyCode.Joystick1Button2);
|
||||
if (nesConBtnType == EnumButtonType.MIC) return new KeyListener_Legacy(KeyCode.M, KeyCode.Joystick1Button12);
|
||||
break;
|
||||
case 2:
|
||||
if (nesConBtnType == EnumButtonType.LEFT) return new KeyListener_Legacy(KeyCode.Delete, KeyCode.Joystick2Button12);
|
||||
if (nesConBtnType == EnumButtonType.RIGHT) return new KeyListener_Legacy(KeyCode.PageDown, KeyCode.Joystick2Button13);
|
||||
if (nesConBtnType == EnumButtonType.UP) return new KeyListener_Legacy(KeyCode.Home, KeyCode.Joystick2Button10);
|
||||
if (nesConBtnType == EnumButtonType.DOWN) return new KeyListener_Legacy(KeyCode.End, KeyCode.Joystick2Button11);
|
||||
if (nesConBtnType == EnumButtonType.START) return new KeyListener_Legacy(KeyCode.PageUp, KeyCode.Joystick2Button7);
|
||||
if (nesConBtnType == EnumButtonType.SELECT) return new KeyListener_Legacy(KeyCode.Insert, KeyCode.Joystick2Button6);
|
||||
if (nesConBtnType == EnumButtonType.A) return new KeyListener_Legacy(KeyCode.Keypad5, KeyCode.Joystick2Button1);
|
||||
if (nesConBtnType == EnumButtonType.B) return new KeyListener_Legacy(KeyCode.Keypad4, KeyCode.Joystick2Button2);
|
||||
if (nesConBtnType == EnumButtonType.MIC) return new KeyListener_Legacy(KeyCode.KeypadPeriod, KeyCode.Joystick2Button12);
|
||||
break;
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface IKeyListener
|
||||
{
|
||||
bool IsPressing();
|
||||
}
|
||||
|
||||
public struct KeyListener_Legacy : IKeyListener
|
||||
{
|
||||
private KeyCode[] m_keys;
|
||||
|
||||
public KeyListener_Legacy(params KeyCode[] keys)
|
||||
{
|
||||
m_keys = keys;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从配置表字符串构建
|
||||
/// </summary>
|
||||
/// <param name="confStr">以:分割的键值字符串</param>
|
||||
public KeyListener_Legacy(string confStr)
|
||||
{
|
||||
m_keys = new KeyCode[2];
|
||||
|
||||
var temp = confStr.Split(':');
|
||||
m_keys = new KeyCode[temp.Length];
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
if (int.TryParse(temp[i], out int result))
|
||||
m_keys[i] = (KeyCode)result;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPressing()
|
||||
{
|
||||
if (m_keys == null || m_keys.Length == 0) return false;
|
||||
|
||||
foreach (var key in m_keys)
|
||||
{
|
||||
if (Input.GetKey(key)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (m_keys == null || m_keys.Length == 0) return string.Empty;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < m_keys.Length; i++)
|
||||
{
|
||||
var keyVal = (int)m_keys[i];
|
||||
sb.Append(keyVal);
|
||||
if (i != m_keys.Length - 1) sb.Append(':');
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using AxibugEmuOnline.Client.Common;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
@ -12,6 +11,8 @@ namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class NesEmulator : MonoBehaviour, IEmuCore
|
||||
{
|
||||
public EnumPlatform Platform => EnumPlatform.NES;
|
||||
|
||||
//模拟器核心实例化对象
|
||||
public NES NesCore { get; private set; }
|
||||
|
||||
@ -168,6 +169,8 @@ namespace AxibugEmuOnline.Client
|
||||
NesCore.LoadState(st);
|
||||
}
|
||||
|
||||
public uint Frame => NesCore.FrameCount;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// 编辑器用
|
||||
@ -197,7 +200,5 @@ namespace AxibugEmuOnline.Client
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
}
|
||||
#endif
|
||||
|
||||
public uint Frame => NesCore.FrameCount;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
using AxibugEmuOnline.Client.ClientCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@ -18,8 +19,6 @@ namespace AxibugEmuOnline.Client
|
||||
/// <summary> 游戏中UI操作 </summary>
|
||||
public IKeyMapperChanger Gaming { get; private set; }
|
||||
|
||||
public bool LegacyInput;
|
||||
|
||||
private IKeyMapperChanger m_current;
|
||||
public IKeyMapperChanger Current
|
||||
{
|
||||
@ -37,22 +36,11 @@ namespace AxibugEmuOnline.Client
|
||||
Instance = this;
|
||||
|
||||
//初始化command监视器
|
||||
if (LegacyInput)
|
||||
m_listener = new CommandListener_Legacy();
|
||||
else
|
||||
m_listener = new CommandListener();
|
||||
m_listener = new CommandListener_Legacy();
|
||||
|
||||
//初始化键位修改器
|
||||
if (LegacyInput)
|
||||
{
|
||||
Normal = new NormalChanger_Legacy();
|
||||
Gaming = new GamingChanger_Legacy();
|
||||
}
|
||||
else
|
||||
{
|
||||
Normal = new NormalChanger();
|
||||
Gaming = new GamingChanger();
|
||||
}
|
||||
Normal = new NormalChanger_Legacy();
|
||||
Gaming = new GamingChanger_Legacy();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
@ -49,6 +49,8 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public void ExecuteCommand(EnumCommand cmd, bool cancel)
|
||||
{
|
||||
if(cmd == EnumCommand.NONE) return;
|
||||
|
||||
if (!cancel)
|
||||
{
|
||||
switch (cmd)
|
||||
@ -118,6 +120,7 @@ namespace AxibugEmuOnline.Client
|
||||
|
||||
public enum EnumCommand
|
||||
{
|
||||
NONE,
|
||||
SelectItemLeft,
|
||||
SelectItemRight,
|
||||
SelectItemUp,
|
||||
|
@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace AxibugEmuOnline.Client
|
||||
{
|
||||
public class CommandListener : ICommandListener
|
||||
{
|
||||
private PlayerInput m_uiInput;
|
||||
private IEnumerable<CommandExecuter> m_executers;
|
||||
|
||||
public CommandListener()
|
||||
{
|
||||
m_uiInput = GameObject.FindGameObjectWithTag("UIInput").GetComponent<PlayerInput>();
|
||||
m_uiInput.onActionTriggered += M_uiInput_onActionTriggered;
|
||||
}
|
||||
public void Update(IEnumerable<CommandExecuter> executer)
|
||||
{
|
||||
m_executers = executer;
|
||||
}
|
||||
|
||||
private void M_uiInput_onActionTriggered(InputAction.CallbackContext obj)
|
||||
{
|
||||
CommandState? cs = null;
|
||||
switch (obj.action.phase)
|
||||
{
|
||||
case InputActionPhase.Started:
|
||||
cs = new CommandState { Cancel = false, Cmd = ToCommandEnum(obj.action.name) };
|
||||
break;
|
||||
case InputActionPhase.Canceled:
|
||||
cs = new CommandState { Cancel = true, Cmd = ToCommandEnum(obj.action.name) };
|
||||
break;
|
||||
}
|
||||
if (!cs.HasValue) return;
|
||||
|
||||
foreach (var exec in m_executers)
|
||||
{
|
||||
if (!exec.Enable) continue;
|
||||
exec.ExecuteCommand(cs.Value.Cmd, cs.Value.Cancel);
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyKeyMapper(IKeyMapperChanger changer)
|
||||
{
|
||||
var actionMapName = (string)changer.GetConfig();
|
||||
m_uiInput.SwitchCurrentActionMap(actionMapName);
|
||||
}
|
||||
|
||||
EnumCommand ToCommandEnum(string actionName)
|
||||
{
|
||||
return actionName switch
|
||||
{
|
||||
"SelectItemLeft" => EnumCommand.SelectItemLeft,
|
||||
"SelectItemRight" => EnumCommand.SelectItemRight,
|
||||
"SelectItemUp" => EnumCommand.SelectItemUp,
|
||||
"SelectItemDown" => EnumCommand.SelectItemDown,
|
||||
"Enter" => EnumCommand.Enter,
|
||||
"Back" => EnumCommand.Back,
|
||||
"OptionMenu" => EnumCommand.OptionMenu,
|
||||
_ => throw new Exception("Not Support Action")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a493da4af70f32a43b3c558d94cf23a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -60,6 +60,7 @@ namespace VirtualNes.Core
|
||||
[Flags]
|
||||
public enum EnumButtonType
|
||||
{
|
||||
NONE = 0,
|
||||
UP = 1,
|
||||
DOWN = 2,
|
||||
LEFT = 4,
|
||||
|
@ -2,7 +2,6 @@
|
||||
"dependencies": {
|
||||
"com.unity.2d.sprite": "1.0.0",
|
||||
"com.unity.ide.visualstudio": "2.0.22",
|
||||
"com.unity.inputsystem": "1.3.0",
|
||||
"com.unity.postprocessing": "3.2.2",
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
|
@ -22,15 +22,6 @@
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.inputsystem": {
|
||||
"version": "1.3.0",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.modules.uielements": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.postprocessing": {
|
||||
"version": "3.2.2",
|
||||
"depth": 0,
|
||||
|
Loading…
Reference in New Issue
Block a user