예제 #1
0
 public void AddStateProvider(Type type, IInputStateProvider provider)
 {
     if (!stateProviders.ContainsKey(type))
     {
         stateProviders[type] = provider;
     }
 }
        public bool TryBindControl(InputControl control, IInputStateProvider stateProvider)
        {
            var controlOfRightType = control as ButtonControl;

            if (controlOfRightType == null)
            {
                return(false);
            }

            for (int i = 0; i < modifierSet.Count; i++)
            {
                if (control.provider == modifierSet[i].sourceControl.provider && control.index == modifierSet[i].sourceControl.index)
                {
                    return(false);
                }
            }

            main.SetSource(controlOfRightType, stateProvider);

            modifiers.Clear();
            for (int i = 0; i < modifierSet.Count; i++)
            {
                // Check if this modifier is held down.
                // Since we don't spend resources updating the states of the possible modifier keys,
                // we look instead directly on the corresponding controls on the InputDevice.
                // the sourceControl is the control in the ActionMap's own state.
                // To get to the InputDevice we need to get its provider and look up the control there.
                if (((ButtonControl)(modifierSet[i].sourceControl.provider.GetControlFromHash(modifierSet[i].supportedControl.hash))).value > 0.5f)
                {
                    modifiers.Add((ControlReferenceBinding <ButtonControl, float>)modifierSet[i].Clone());
                }
            }

            return(true);
        }
예제 #3
0
 public void AddStateProvider(Type type, IInputStateProvider provider)
 {
     if (!stateProviders.ContainsKey(type))
     {
         stateProviders[type] = provider;
     }
 }
예제 #4
0
 public override void Initialize(IInputStateProvider stateProvider)
 {
     m_Values = new T[sources.Count];
     for (int i = 0; i < sources.Count; i++)
     {
         sources[i].Initialize(stateProvider);
     }
 }
예제 #5
0
 public void Initialize(IInputStateProvider stateProvider)
 {
     for (int i = 0; i < bindings.Count; i++)
     {
         var binding = bindings[i];
         if (bindings[i] != null)
         {
             bindings[i].Initialize(stateProvider);
         }
     }
 }
 public override void Initialize(IInputStateProvider stateProvider)
 {
     main.Initialize(stateProvider);
     for (int i = 0; i < m_Modifiers.Count; i++)
     {
         modifiers[i].Initialize(stateProvider);
     }
     for (int i = 0; i < m_ModifierSet.Count; i++)
     {
         modifierSet[i].Initialize(stateProvider);
     }
 }
        public override void Initialize(IInputStateProvider stateProvider)
        {
            if (controlHash == -1)
            {
                return;
            }

            var deviceState  = stateProvider.GetDeviceStateForDeviceSlotKey(deviceKey);
            int controlIndex = deviceState.controlProvider.GetControlIndexFromHash(m_ControlHash);

            m_SourceControl = deviceState.controls[controlIndex] as InputControl <T>;
        }
        public bool TryBindControl(InputControl control, IInputStateProvider stateProvider)
        {
            var controlOfRightType = control as C;

            if (controlOfRightType == null)
            {
                return(false);
            }

            SetSource(controlOfRightType, stateProvider);
            return(true);
        }
 public void SetSource(InputControl <T> source, IInputStateProvider stateProvider)
 {
     deviceKey     = stateProvider.GetOrAddDeviceSlotKey(source.provider as InputDevice);
     m_ControlHash = source.provider.GetHashForControlIndex(source.index);
     Initialize(stateProvider);
 }
예제 #10
0
 public abstract void Initialize(IInputStateProvider stateProvider);
 public override void Initialize(IInputStateProvider stateProvider)
 {
     negative.Initialize(stateProvider);
     positive.Initialize(stateProvider);
 }
예제 #12
0
 public override void Initialize(IInputStateProvider stateProvider)
 {
     x.Initialize(stateProvider);
     y.Initialize(stateProvider);
 }