using System; using Framework.Services; using UnityEngine.VR; namespace Framework.Input.Profiles { /// Manages the current source of input for the game [ServiceScope(Scope.Global)] public class InputSelector : Service, IInputSelector { #if INPUT_SOURCE_CAN_EVER_BE_SWITCHED /// Triggered when the input profile has been switched public event Action SourceChanged; #endif // INPUT_SOURCE_CAN_EVER_BE_SWITCHED /// Currently active source of inputs public InputSources ActiveSource { get { if(this.activeSource.HasValue) { return this.activeSource.Value; } else { if(VRSettings.enabled && VRSettings.isDeviceActive) { return InputSources.VirtualReality; } else { return InputSources.Controllers; } } } } /// Changes the active source of inputs /// New source inputs will be taken from public void Switch(InputSources newSource) { this.activeSource = newSource; } /// Currently active source of inputs if explicitly assigned private InputSources? activeSource; } } // namespace Framework.Input.Profiles