Compare commits

...

3 Commits

4 changed files with 46 additions and 5 deletions

View File

@ -29,6 +29,7 @@ namespace AxibugEmuOnline.Client.InputDevices
private void DefineControls()
{
//反射初始化所有控制对象 比如Button_C
foreach (var field in GetType().GetFields(BindingFlags.Instance | BindingFlags.Public))
{
if (!typeof(InputControl_C).IsAssignableFrom(field.FieldType)) continue;

View File

@ -30,6 +30,8 @@ namespace AxibugEmuOnline.Client.InputDevices
public Button_C Right;
public Button_C Down;
public Button_C Left;
public Button_C LeftBackTouch;
public Button_C RightBackTouch;
public Stick_C LeftStick;
public Stick_C RightStick;

View File

@ -8,11 +8,11 @@
#define JOYCON_SUPPORT
#endif
using AxibugEmuOnline.Client.ClientCore;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.DualShock;
using UnityEngine.InputSystem.Switch;
using UnityEngine.InputSystem.XInput;
namespace AxibugEmuOnline.Client.InputDevices.ForInputSystem
@ -31,6 +31,40 @@ namespace AxibugEmuOnline.Client.InputDevices.ForInputSystem
private void AddDevice(InputDevice ipdev)
{
string log = $"{ipdev.deviceId}| {ipdev.name}|{ipdev.displayName}|{ipdev.GetType().FullName}|{ipdev.GetType().BaseType.FullName}";
#if UNITY_ANDROID
if (ipdev is Keyboard)
{
/*
uinput-goodixGoodix
gpio-keysGPIO Keys
pmic_pwrkeyPMIC
pmic_resinresin resin key
pmic_pwrkey_resin_bark+
pineapple-mtp-snd-card Headset Jack线/
On-Screen Keyboard
*/
string deviceName = ipdev.displayName;
if (deviceName.Contains("Virtual") ||
deviceName.Contains("gpio-keys") ||//电源键
deviceName.Contains("pmic") ||
deviceName.Contains("goodix") ||
deviceName.Contains("screen") ||
deviceName.Contains("touch") ||
deviceName.Contains("mtp-snd-card") ||
deviceName.Contains("Headset Jack") ||//耳机线控
deviceName.Contains("On-Screen") ||
deviceName.Equals("AndroidInputManager")
)
{
App.log.Debug($"过滤输入设备:{log}");
return;
}
}
#endif
App.log.Debug($"加入输入设备:{log}");
InputDevice_D newDevice = null;
if (ipdev is Keyboard) newDevice = new Keyboard_D(this);
@ -48,7 +82,7 @@ namespace AxibugEmuOnline.Client.InputDevices.ForInputSystem
newDevice = new XboxController_D(this);
}
#if JOYCON_SUPPORT
else if (ipdev is NPad)
else if (ipdev is UnityEngine.InputSystem.Switch.NPad)
{
newDevice = new SwitchJoyCon_D(this);
}
@ -137,7 +171,7 @@ namespace AxibugEmuOnline.Client.InputDevices.ForInputSystem
}
}
Dictionary<InputDevice_D, Dictionary<InputControl_C, InputControl>> m_deviceMapper = new Dictionary<InputDevice_D, Dictionary<InputControl_C, InputControl>>();
void AddDeviceMapper(InputDevice_D device_d, InputDevice ipdevice)
void AddDeviceMapper(InputDevice_D device_d, UnityEngine.InputSystem.InputDevice ipdevice)
{
m_deviceMapper.Add(device_d, new Dictionary<InputControl_C, InputControl>());
var mapper = m_deviceMapper[device_d];
@ -300,7 +334,7 @@ namespace AxibugEmuOnline.Client.InputDevices.ForInputSystem
#if JOYCON_SUPPORT
else if (device_d is SwitchJoyCon_D joycon_d)
{
var ipdevice_joycon = ipdevice as NPad;
var ipdevice_joycon = ipdevice as UnityEngine.InputSystem.Switch.NPad;
mapper[joycon_d.LeftSL] = ipdevice_joycon.leftSL;
mapper[joycon_d.LeftSR] = ipdevice_joycon.leftSR;
mapper[joycon_d.RightSL] = ipdevice_joycon.rightSL;

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using AxiInputSP;
using System.Collections.Generic;
using UnityEngine;
namespace AxibugEmuOnline.Client.InputDevices.ForPSV
@ -48,6 +49,9 @@ namespace AxibugEmuOnline.Client.InputDevices.ForPSV
else if (control == psvCon.Right) return Input.GetKey(KeyCode.Joystick1Button9);
else if (control == psvCon.Down) return Input.GetKey(KeyCode.Joystick1Button10);
else if (control == psvCon.Left) return Input.GetKey(KeyCode.Joystick1Button11);
else if (control == psvCon.LeftBackTouch) return AxiPSVBackTouchEmuKey.GetKey(AxiPSVBackTouchType.LeftHalf);
else if (control == psvCon.RightBackTouch) return AxiPSVBackTouchEmuKey.GetKey(AxiPSVBackTouchType.RigthHalf);
else if (control == psvCon.LeftStick || control == psvCon.RightStick)
{
var vec2 = control.GetVector2();