예제 #1
0
        public float GetFloat(string name)
        {
            if (_floatPatterns.ContainsKey(name))
            {
                return(_floatPatterns[name].PeekNextValue());
            }

            if (Source == null)
            {
                return(0);
            }

            return(Source.GetFloat(name));
        }
예제 #2
0
        public bool this[string button]
        {
            get
            {
                var  source       = Source[button];
                bool patternValue = false;
                if (_boolPatterns.ContainsKey(button))
                {                 // I can't figure a way to determine right here if it should Peek or Get.
                    patternValue = _boolPatterns[button].PeekNextValue();
                }
                source ^= patternValue;

                return(source);
            }
        }
예제 #3
0
        // TODO: get rid of this, add a SetBool() method or something for the set access, replace get wtih IsPressed
        public bool this[string button]
        {
            get
            {
                return(_myBoolButtons[button]);
            }

            set
            {
                if (_myBoolButtons.ContainsKey(button))
                {
                    _myBoolButtons[button] = value;
                }
            }
        }
예제 #4
0
        void HandleButton(string button, bool newState)
        {
            bool isModifier = IgnoreKeys.Contains(button);

            if (EnableIgnoreModifiers && isModifier)
            {
                return;
            }
            if (LastState[button] && newState)
            {
                return;
            }
            if (!LastState[button] && !newState)
            {
                return;
            }

            //apply
            //NOTE: this is not quite right. if someone held leftshift+rightshift it would be broken. seems unlikely, though.
            if (button == "LeftShift")
            {
                _Modifiers &= ~ModifierKey.Shift;
                if (newState)
                {
                    _Modifiers |= ModifierKey.Shift;
                }
            }
            if (button == "RightShift")
            {
                _Modifiers &= ~ModifierKey.Shift; if (newState)
                {
                    _Modifiers |= ModifierKey.Shift;
                }
            }
            if (button == "LeftControl")
            {
                _Modifiers &= ~ModifierKey.Control; if (newState)
                {
                    _Modifiers |= ModifierKey.Control;
                }
            }
            if (button == "RightControl")
            {
                _Modifiers &= ~ModifierKey.Control; if (newState)
                {
                    _Modifiers |= ModifierKey.Control;
                }
            }
            if (button == "LeftAlt")
            {
                _Modifiers &= ~ModifierKey.Alt; if (newState)
                {
                    _Modifiers |= ModifierKey.Alt;
                }
            }
            if (button == "RightAlt")
            {
                _Modifiers &= ~ModifierKey.Alt; if (newState)
                {
                    _Modifiers |= ModifierKey.Alt;
                }
            }

            if (UnpressState.ContainsKey(button))
            {
                if (newState)
                {
                    return;
                }
                Console.WriteLine("Removing Unpress {0} with newState {1}", button, newState);
                UnpressState.Remove(button);
                LastState[button] = false;
                return;
            }


            //dont generate events for things like Ctrl+LeftControl
            ModifierKey mods = _Modifiers;

            if (button == "LeftShift")
            {
                mods &= ~ModifierKey.Shift;
            }
            if (button == "RightShift")
            {
                mods &= ~ModifierKey.Shift;
            }
            if (button == "LeftControl")
            {
                mods &= ~ModifierKey.Control;
            }
            if (button == "RightControl")
            {
                mods &= ~ModifierKey.Control;
            }
            if (button == "LeftAlt")
            {
                mods &= ~ModifierKey.Alt;
            }
            if (button == "RightAlt")
            {
                mods &= ~ModifierKey.Alt;
            }

            var ie = new InputEvent
            {
                EventType     = newState ? InputEventType.Press : InputEventType.Release,
                LogicalButton = new LogicalButton(button, mods)
            };

            LastState[button] = newState;

            //track the pressed events with modifiers that we send so that we can send corresponding unpresses with modifiers
            //this is an interesting idea, which we may need later, but not yet.
            //for example, you may see this series of events: press:ctrl+c, release:ctrl, release:c
            //but you might would rather have press:ctr+c, release:ctrl+c
            //this code relates the releases to the original presses.
            //UPDATE - this is necessary for the frame advance key, which has a special meaning when it gets stuck down
            //so, i am adding it as of 11-sep-2011
            if (newState)
            {
                ModifierState[button] = ie.LogicalButton;
            }
            else
            {
                if (ModifierState[button] != null)
                {
                    LogicalButton alreadyReleased = ie.LogicalButton;
                    var           ieModified      = new InputEvent
                    {
                        LogicalButton = (LogicalButton)ModifierState[button],
                        EventType     = InputEventType.Release
                    };
                    if (ieModified.LogicalButton != alreadyReleased)
                    {
                        _NewEvents.Add(ieModified);
                    }
                }
                ModifierState[button] = null;
            }

            _NewEvents.Add(ie);
        }
예제 #5
0
 public bool IsSticky(string button)
 {
     return(_boolPatterns.ContainsKey(button) || _axisPatterns.ContainsKey(button));
 }