コード例 #1
0
 private FezButtonState GetMappedKeyState(MappedAction action, Keys ifIgnored)
 {
     return(this.GetKeyState(this.IgnoreMapping ? ifIgnored : this.lastMapping[action]));
 }
コード例 #2
0
        public override void Update(TimeSpan elapsed)
        {
            base.Update(elapsed);
            if (this.pendingApply && !SdlGamePad.GetPressedButtonId().HasValue)
            {
                this.pendingApply = false;
                SettingsManager.Settings.ApplyGamepadMapping();
            }
            if (this.TrapInput)
            {
                if (this.forGamepad)
                {
                    if (this.KeyboardManager.GetKeyState(Keys.Escape) == FezButtonState.Pressed)
                    {
                        int          num                    = this.Items.IndexOf(this.keyGrabFor);
                        MappedAction mappedAction           = ControlsMenuLevel.GamepadActionOrder[num - this.otherGamepadsStart];
                        Dictionary <MappedAction, int> gMap = SettingsManager.Settings.GamepadMapping;
                        this.keyGrabFor.SuffixText = (Func <string>)(() => " : " + this.Buttonize(gMap[mappedAction]));
                        this.TrapInput             = false;
                        this.forGamepad            = false;
                        this.pendingApply          = true;
                    }
                    else
                    {
                        int?pressedButtonId = SdlGamePad.GetPressedButtonId();
                        ControlsMenuLevel controlsMenuLevel = this;
                        int num1 = controlsMenuLevel.hasBeenIdle | !pressedButtonId.HasValue ? 1 : 0;
                        controlsMenuLevel.hasBeenIdle = num1 != 0;
                        if (this.hasBeenIdle && pressedButtonId.HasValue)
                        {
                            int          num2                   = this.Items.IndexOf(this.keyGrabFor);
                            MappedAction mappedAction           = ControlsMenuLevel.GamepadActionOrder[num2 - this.otherGamepadsStart];
                            Dictionary <MappedAction, int> gMap = SettingsManager.Settings.GamepadMapping;
                            gMap[mappedAction]         = pressedButtonId.Value;
                            this.keyGrabFor.SuffixText = (Func <string>)(() => " : " + this.Buttonize(gMap[mappedAction]));
                            this.TrapInput             = false;
                            this.forGamepad            = false;
                            this.pendingApply          = true;
                        }
                    }
                }
                else
                {
                    this.thisPressed.Clear();
                    foreach (Keys keys in Keyboard.GetState().GetPressedKeys())
                    {
                        this.thisPressed.Add(keys);
                    }
                    foreach (Keys keys1 in this.keysDown)
                    {
                        if (!this.thisPressed.Contains(keys1))
                        {
                            Keys         keys2                   = keys1;
                            int          num                     = this.Items.IndexOf(this.keyGrabFor);
                            MappedAction mappedAction            = ControlsMenuLevel.KeyboardActionOrder[num - this.keyboardStart];
                            Dictionary <MappedAction, Keys> kMap = SettingsManager.Settings.KeyboardMapping;
                            kMap[mappedAction]         = keys2;
                            this.keyGrabFor.SuffixText = (Func <string>)(() => " : " + this.Localize((object)kMap[mappedAction]));
                            this.KeyboardManager.UpdateMapping();
                            this.TrapInput = false;
                            break;
                        }
                    }
                    foreach (Keys keys in this.thisPressed)
                    {
                        if (!this.lastPressed.Contains(keys))
                        {
                            this.keysDown.Add(keys);
                        }
                    }
                    HashSet <Keys> hashSet = this.thisPressed;
                    this.thisPressed = this.lastPressed;
                    this.lastPressed = hashSet;
                }
            }
            if (this.SelectedIndex < this.Items.Count - 3)
            {
                return;
            }
            Point position = this.MouseState.Position;

            if (this.leftSliderRect.HasValue && this.leftSliderRect.Value.Contains(position))
            {
                this.menuBase.CursorSelectable = true;
                if (this.MouseState.LeftButton.State == MouseButtonStates.Pressed)
                {
                    this.FakeSlideLeft(false);
                }
            }
            else if (this.rightSliderRect.HasValue && this.rightSliderRect.Value.Contains(position))
            {
                this.menuBase.CursorSelectable = true;
                if (this.MouseState.LeftButton.State == MouseButtonStates.Pressed)
                {
                    this.FakeSlideRight(false);
                }
            }
            if (this.InputManager.Right == FezButtonState.Pressed)
            {
                this.FakeSlideRight(false);
            }
            else
            {
                if (this.InputManager.Left != FezButtonState.Pressed)
                {
                    return;
                }
                this.FakeSlideLeft(false);
            }
        }
コード例 #3
0
ファイル: KeyboardStateManager.cs プロジェクト: tanis2000/FEZ
 private FezButtonState GetMappedKeyState(MappedAction action, Keys ifIgnored)
 {
   return this.GetKeyState(this.IgnoreMapping ? ifIgnored : this.lastMapping[action]);
 }