Esempio n. 1
0
 public void SetAxis(string name, float?value)
 {
     if (value.HasValue)
     {
         _axisSet[name] = value;
     }
     else
     {
         _axisSet.Remove(name);
     }
 }
Esempio n. 2
0
 public void SetFloat(string name, float?value)
 {
     if (value.HasValue)
     {
         _floatSet[name] = value;
     }
     else
     {
         _floatSet.Remove(name);
     }
 }
Esempio n. 3
0
 public void SetSticky(string button, bool isSticky, AutoPatternBool pattern = null)
 {
     if (isSticky)
     {
         if (pattern == null)
         {
             pattern = new AutoPatternBool(On, Off);
         }
         _boolPatterns[button] = pattern;
     }
     else
     {
         _boolPatterns.Remove(button);
     }
 }
Esempio n. 4
0
        }                                        // Pretty much a hack,

        public void SetFloat(string name, float?value, AutoPatternFloat pattern = null)
        {
            if (value.HasValue)
            {
                if (pattern == null)
                {
                    pattern = new AutoPatternFloat(value.Value, On, 0, Off);
                }
                _floatPatterns[name] = pattern;
            }
            else
            {
                _floatPatterns.Remove(name);
            }
        }
Esempio n. 5
0
 public void SetAxis(string name, float?value, AutoPatternFloat pattern = null)
 {
     if (value.HasValue)
     {
         pattern ??= new AutoPatternFloat(value.Value, _on, 0, _off);
         _axisPatterns[name] = pattern;
     }
     else
     {
         _axisPatterns.Remove(name);
     }
 }
Esempio n. 6
0
        public void MassToggleStickyState(List <string> buttons)
        {
            foreach (var button in buttons.Where(button => !_justPressed.Contains(button)))
            {
                if (_boolPatterns.ContainsKey(button))
                {
                    _toggledButtons[button] = _boolPatterns[button];
                    SetSticky(button, false);
                }
                else
                {
                    _boolPatterns[button] = _toggledButtons[button];
                    _toggledButtons.Remove(button);
                }
            }

            _justPressed = buttons;
        }
Esempio n. 7
0
        public void SetSticky(string button, bool isSticky)
        {
            if (isSticky)
            {
                _stickySet.Add(button);
                buttonStarts.Add(button, Global.Emulator.Frame);

                if (Global.Emulator.CanPollInput())
                {
                    lagStarts.Add(button, Global.Emulator.AsInputPollable().LagCount);
                }
                else
                {
                    lagStarts.Add(button, 0);
                }
            }
            else
            {
                _stickySet.Remove(button);
                buttonStarts.Remove(button);
                lagStarts.Remove(button);
            }
        }
Esempio n. 8
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);
        }