using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
namespace AxibugEmuOnline.Client.InputDevices
{
public abstract class InputResolver
{
public static InputResolver Create()
{
#if ENABLE_INPUT_SYSTEM //InputSystem
return new ForInputSystem.InputSystemResolver();
#elif UNITY_PSP2 //特化实现
return new ForPSV.PSVResolver();
#elif UNITY_PS3 //SDK
throw new System.NotImplementedException();
#else
throw new System.NotImplementedException();
#endif
}
/// 禁止外部构造
protected InputResolver()
{
OnInit();
}
protected abstract void OnInit();
///
/// 获得所有当前已连入的输入设备
///
///
public abstract IEnumerable GetDevices();
///
/// 检查指定输入设备是否还保持着连接
///
///
public abstract bool CheckOnline(InputDevice_D device);
/// 丢失的设备
public delegate void OnDeviceLostHandle(InputDevice_D lostDevice);
/// 当设备丢失时触发
public event OnDeviceLostHandle OnDeviceLost;
protected void RaiseDeviceLost(InputDevice_D lostDevice)
{
OnDeviceLost?.Invoke(lostDevice);
}
/// 建立连接的设备
public delegate void OnDeviceConnectedHandle(InputDevice_D connectDevice);
/// 当设备连接时触发
public event OnDeviceConnectedHandle OnDeviceConnected;
protected void RaiseDeviceConnected(InputDevice_D connectDevice)
{
OnDeviceConnected?.Invoke(connectDevice);
}
public abstract bool CheckPerforming(CONTROLLER control) where CONTROLLER : InputControl_C;
public abstract Vector2 GetVector2(CONTROLLER control) where CONTROLLER : InputControl_C;
public abstract float GetFloat(CONTROLLER control) where CONTROLLER : InputControl_C;
///
/// 获得输入设备的唯一名称
///
/// 这个设备必须是由resolver提供,并且保持着连接
///
public abstract string GetDeviceName(InputDevice_D inputDevice);
}
}