56 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using UnityEngine;
public class In : MonoBehaviour
{
[Header("Выбор источника управления")]
static InputSource source;
public void Initialize()
{
#if UNITY_EDITOR
source = new KeyboardInput();
#else
source = new COMinput();
#endif
var success = source.Initialize();
if (!success) Debug.LogWarning("Не удалось проинициалзировать источник управления.");
}
public static bool GetButton(InSignal button) => source.GetButton(button);
public static bool GetButtonDown(InSignal button) => source.GetButtonDown(button);
public static bool GetButtonDown(IEnumerable<InSignal> signals)
{
foreach (var signal in signals)
if (GetButtonDown(signal))
return true;
return false;
}
public static bool GetButtonUp(InSignal button) => source.GetButtonUp(button);
public static bool GetButton(int pinindex) => source.GetButton(pinindex);
public static bool GetButtonDown(int pinindex) => source.GetButtonDown(pinindex);
public static bool GetButtonUp(int pinindex) => source.GetButtonUp(pinindex);
public static bool GetButtonAnyPlayer(PlayerAction button) => source.GetButtonAnyPlayer(button);
public static bool GetButtonDownAnyPlayer(PlayerAction button) => source.GetButtonDownAnyPlayer(button);
public static bool GetButtonUpAnyPlayer(PlayerAction button) => source.GetButtonUpAnyPlayer(button);
public static bool GetButtonCurrentPlayer(PlayerAction button) => source.GetButtonCurrentPlayer(button);
public static bool GetButtonDownCurrentPlayer(PlayerAction button) => source.GetButtonDownCurrentPlayer(button);
public static bool GetButtonUpCurrentPlayer(PlayerAction button) => source.GetButtonUpCurrentPlayer(button);
public static bool AnyButton() => source.AnyButton();
}