Esempio n. 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;
            }
        }
Esempio n. 2
0
        internal void Update(ulong updateTick, float deltaTime)
        {
            var device = Device ?? FindActiveDevice();

            var lastInputType            = LastInputType;
            var lastInputTypeChangedTick = LastInputTypeChangedTick;

            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;
                }
            }

            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;

                if (OnLastInputTypeChanged != null && triggerEvent)
                {
                    OnLastInputTypeChanged.Invoke(lastInputType);
                }
            }
        }
Esempio n. 3
0
        void ProcessActionUpdate(PlayerAction action)
        {
            var lastInputType = LastInputType;

            if (action.UpdateTick > UpdateTick)
            {
                UpdateTick    = action.UpdateTick;
                lastInputType = action.LastInputType;
            }

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