示例#1
0
        void UpdateBindings(ulong updateTick, float deltaTime)
        {
            var lastInputType            = LastInputType;
            var lastInputTypeChangedTick = LastInputTypeChangedTick;
            var lastUpdateTick           = UpdateTick;
            var lastDeviceClass          = LastDeviceClass;
            var lastDeviceStyle          = LastDeviceStyle;

            var bindingCount = regularBindings.Count;

            for (var i = bindingCount - 1; i >= 0; i--)
            {
                var binding = regularBindings[i];

                if (binding.BoundTo != this)
                {
                    regularBindings.RemoveAt(i);
                    visibleBindings.Remove(binding);
                }
                else
                {
                    var value = binding.GetValue(Device);
                    if (UpdateWithValue(value, updateTick, deltaTime))
                    {
                        lastInputType            = binding.BindingSourceType;
                        lastInputTypeChangedTick = updateTick;
                        lastDeviceClass          = binding.DeviceClass;
                        lastDeviceStyle          = binding.DeviceStyle;
                    }
                }
            }

            Commit();

            Enabled = Owner.Enabled;

            if (lastInputTypeChangedTick > LastInputTypeChangedTick)
            {
                if (lastInputType != BindingSourceType.MouseBindingSource ||
                    Utility.Abs(LastValue - Value) >= MouseBindingSource.JitterThreshold)
                {
                    var triggerEvent = lastInputType != LastInputType;

                    LastInputType            = lastInputType;
                    LastInputTypeChangedTick = lastInputTypeChangedTick;
                    LastDeviceClass          = lastDeviceClass;
                    LastDeviceStyle          = lastDeviceStyle;

                    if (OnLastInputTypeChanged != null && triggerEvent)
                    {
                        OnLastInputTypeChanged.Invoke(lastInputType);
                    }
                }
            }

            if (UpdateTick > lastUpdateTick)
            {
                activeDevice = LastInputTypeIsDevice ? Device : null;
            }
        }
        public static InputControlType LeftCommandControl(this InputDeviceStyle deviceStyle)
        {
            switch (deviceStyle)
            {
            case InputDeviceStyle.Xbox360:
                return(InputControlType.Back);

            case InputDeviceStyle.XboxOne:
            case InputDeviceStyle.XboxSeriesX:
                return(InputControlType.View);

            case InputDeviceStyle.PlayStation2:
            case InputDeviceStyle.PlayStation3:
            case InputDeviceStyle.PlayStationVita:
                return(InputControlType.Select);

            case InputDeviceStyle.PlayStation4:
                return(InputControlType.Share);

            case InputDeviceStyle.PlayStation5:
                return(InputControlType.Create);

            case InputDeviceStyle.Steam:
                return(InputControlType.Back);

            case InputDeviceStyle.AppleMFi:
                return(InputControlType.Menu);                        // TODO: Correct?

            case InputDeviceStyle.AmazonFireTV:
                return(InputControlType.Back);

            case InputDeviceStyle.NVIDIAShield:
                return(InputControlType.Back);

            case InputDeviceStyle.NintendoNES:
            case InputDeviceStyle.NintendoSNES:
                return(InputControlType.Select);

            case InputDeviceStyle.NintendoWii:
            case InputDeviceStyle.NintendoWiiU:
            case InputDeviceStyle.NintendoSwitch:
                return(InputControlType.Minus);

            case InputDeviceStyle.GoogleStadia:
                return(InputControlType.Options);

            case InputDeviceStyle.Nintendo64:
            case InputDeviceStyle.NintendoGameCube:
            case InputDeviceStyle.PlayStationMove:
            case InputDeviceStyle.Ouya:
                return(InputControlType.None);              // Only has one or no button

            case InputDeviceStyle.Vive:                     // TODO: Check?
            case InputDeviceStyle.Oculus:                   // TODO: Check?
            case InputDeviceStyle.Unknown:
            default:
                return(defaultLeftCommandControl);
            }
        }
示例#3
0
        private void UpdateBindings(ulong updateTick, float deltaTime)
        {
            bool flag = IsListeningForBinding || (Owner.IsListeningForBinding && Owner.PreventInputWhileListeningForBinding);
            BindingSourceType bindingSourceType = LastInputType;
            ulong             num             = LastInputTypeChangedTick;
            ulong             updateTick2     = base.UpdateTick;
            InputDeviceClass  lastDeviceClass = LastDeviceClass;
            InputDeviceStyle  lastDeviceStyle = LastDeviceStyle;
            int count = regularBindings.Count;

            for (int num2 = count - 1; num2 >= 0; num2--)
            {
                BindingSource bindingSource = regularBindings[num2];
                if (bindingSource.BoundTo != this)
                {
                    regularBindings.RemoveAt(num2);
                    visibleBindings.Remove(bindingSource);
                }
                else if (!flag)
                {
                    float value = bindingSource.GetValue(Device);
                    if (UpdateWithValue(value, updateTick, deltaTime))
                    {
                        bindingSourceType = bindingSource.BindingSourceType;
                        num             = updateTick;
                        lastDeviceClass = bindingSource.DeviceClass;
                        lastDeviceStyle = bindingSource.DeviceStyle;
                    }
                }
            }
            if (flag || count == 0)
            {
                UpdateWithValue(0f, updateTick, deltaTime);
            }
            Commit();
            Enabled = Owner.Enabled;
            if (num > LastInputTypeChangedTick && (bindingSourceType != BindingSourceType.MouseBindingSource || Utility.Abs(base.LastValue - base.Value) >= MouseBindingSource.JitterThreshold))
            {
                bool flag2 = bindingSourceType != LastInputType;
                LastInputType            = bindingSourceType;
                LastInputTypeChangedTick = num;
                LastDeviceClass          = lastDeviceClass;
                LastDeviceStyle          = lastDeviceStyle;
                if (this.OnLastInputTypeChanged != null && flag2)
                {
                    this.OnLastInputTypeChanged(bindingSourceType);
                }
            }
            if (base.UpdateTick > updateTick2)
            {
                activeDevice = ((!LastInputTypeIsDevice) ? null : Device);
            }
        }
        internal void Update(ulong updateTick, float deltaTime)
        {
            InputDevice       device                   = Device ?? FindActiveDevice();
            BindingSourceType lastInputType            = LastInputType;
            ulong             lastInputTypeChangedTick = LastInputTypeChangedTick;
            InputDeviceClass  lastDeviceClass          = LastDeviceClass;
            InputDeviceStyle  lastDeviceStyle          = LastDeviceStyle;
            int count = actions.Count;

            for (int i = 0; i < count; i++)
            {
                PlayerAction playerAction = actions[i];
                playerAction.Update(updateTick, deltaTime, device);
                if (playerAction.UpdateTick > UpdateTick)
                {
                    UpdateTick   = playerAction.UpdateTick;
                    activeDevice = playerAction.ActiveDevice;
                }
                if (playerAction.LastInputTypeChangedTick > lastInputTypeChangedTick)
                {
                    lastInputType            = playerAction.LastInputType;
                    lastInputTypeChangedTick = playerAction.LastInputTypeChangedTick;
                    lastDeviceClass          = playerAction.LastDeviceClass;
                    lastDeviceStyle          = playerAction.LastDeviceStyle;
                }
            }
            int count2 = oneAxisActions.Count;

            for (int j = 0; j < count2; j++)
            {
                oneAxisActions[j].Update(updateTick, deltaTime);
            }
            int count3 = twoAxisActions.Count;

            for (int k = 0; k < count3; k++)
            {
                twoAxisActions[k].Update(updateTick, deltaTime);
            }
            if (lastInputTypeChangedTick > LastInputTypeChangedTick)
            {
                bool flag = lastInputType != LastInputType;
                LastInputType            = lastInputType;
                LastInputTypeChangedTick = lastInputTypeChangedTick;
                LastDeviceClass          = lastDeviceClass;
                LastDeviceStyle          = lastDeviceStyle;
                if (this.OnLastInputTypeChanged != null && flag)
                {
                    this.OnLastInputTypeChanged(lastInputType);
                }
            }
        }
示例#5
0
        public InputDeviceProfile()
        {
            Name = "";
            Meta = "";

            AnalogMappings = new InputControlMapping[0];
            ButtonMappings = new InputControlMapping[0];

            IncludePlatforms = new string[0];
            ExcludePlatforms = new string[0];

            MinSystemBuildNumber = 0;
            MaxSystemBuildNumber = 0;

            DeviceClass = InputDeviceClass.Unknown;
            DeviceStyle = InputDeviceStyle.Unknown;
        }
示例#6
0
        internal void Update(ulong updateTick, float deltaTime)
        {
            var device = Device ?? FindActiveDevice();

            var lastInputType            = LastInputType;
            var lastInputTypeChangedTick = LastInputTypeChangedTick;
            var lastDeviceClass          = LastDeviceClass;
            var lastDeviceStyle          = LastDeviceStyle;

            var actionsCount = actions.Count;

            for (var i = 0; i < actionsCount; i++)
            {
                var action = actions[i];

                action.Update(updateTick, deltaTime, device);

                if (action.UpdateTick > UpdateTick)
                {
                    UpdateTick   = action.UpdateTick;
                    activeDevice = action.ActiveDevice;
                }

                if (action.LastInputTypeChangedTick > lastInputTypeChangedTick)
                {
                    lastInputType            = action.LastInputType;
                    lastInputTypeChangedTick = action.LastInputTypeChangedTick;
                    lastDeviceClass          = action.LastDeviceClass;
                    lastDeviceStyle          = action.LastDeviceStyle;
                }
            }

            var oneAxisActionsCount = oneAxisActions.Count;

            for (var i = 0; i < oneAxisActionsCount; i++)
            {
                oneAxisActions[i].Update(updateTick, deltaTime);
            }

            var twoAxisActionsCount = twoAxisActions.Count;

            for (var i = 0; i < twoAxisActionsCount; i++)
            {
                twoAxisActions[i].Update(updateTick, deltaTime);
            }

            if (lastInputTypeChangedTick > LastInputTypeChangedTick)
            {
                var triggerEvent = lastInputType != LastInputType;

                LastInputType            = lastInputType;
                LastInputTypeChangedTick = lastInputTypeChangedTick;
                LastDeviceClass          = lastDeviceClass;
                LastDeviceStyle          = lastDeviceStyle;

                if (OnLastInputTypeChanged != null && triggerEvent)
                {
                    OnLastInputTypeChanged.Invoke(lastInputType);
                }
            }
        }