示例#1
0
        public static bool MetaReleased(MetaKey meta, InputLayer layer)
        {
            // FIXME: this is not precise enough for multiple meta combos.
            bool active = true;

            if ((meta & MetaKey.Shift) != 0 &&
                !layer.GetKeyUp(KeyCode.LeftShift) && !layer.GetKeyUp(KeyCode.RightShift))
            {
                active = false;
            }

            if ((meta & MetaKey.Alt) != 0 &&
                !layer.GetKeyUp(KeyCode.LeftAlt) && !layer.GetKeyUp(KeyCode.RightAlt))
            {
                active = false;
            }

            if ((meta & MetaKey.Control) != 0 &&
                !layer.GetKeyUp(KeyCode.LeftControl) && !layer.GetKeyUp(KeyCode.RightControl))
            {
                active = false;
            }

            if ((meta & MetaKey.Super) != 0 &&
                !layer.GetKeyUp(KeyCode.LeftCommand) && !layer.GetKeyUp(KeyCode.RightCommand) &&
                !layer.GetKeyUp(KeyCode.LeftWindows) && !layer.GetKeyUp(KeyCode.RightWindows))
            {
                active = false;
            }

            return(active);
        }
示例#2
0
 public static bool MatchMetaState(MetaKey meta, InputLayer layer, MetaKey testFlag, KeyCode key1, KeyCode key2, KeyCode key3, KeyCode key4)
 {
     if ((meta & testFlag) != 0 && !layer.GetKey(key1) && !layer.GetKey(key2) && !layer.GetKey(key3) && !layer.GetKey(key4) ||
         (meta & testFlag) == 0 && (layer.GetKey(key1) || layer.GetKey(key2) || layer.GetKey(key3) || layer.GetKey(key4)))
     {
         return(false);
     }
     return(true);
 }
示例#3
0
        public static bool MetaActive(MetaKey meta, InputLayer layer)
        {
            // FIXME: this is not precise enough for multiple meta combos.
            bool active = true;

            active = active && MatchMetaState(meta, layer, MetaKey.Shift, KeyCode.LeftShift, KeyCode.RightShift);
            active = active && MatchMetaState(meta, layer, MetaKey.Alt, KeyCode.LeftAlt, KeyCode.RightAlt);
            active = active && MatchMetaState(meta, layer, MetaKey.Control, KeyCode.LeftControl, KeyCode.RightControl);
            active = active && MatchMetaState(meta, layer, MetaKey.Super, KeyCode.LeftWindows, KeyCode.RightWindows, KeyCode.LeftCommand, KeyCode.RightCommand);

            return(active);
        }
示例#4
0
 /// <summary>
 /// Has the sequence been pressed this frame?
 /// </summary>
 public bool IsDown(InputLayer layer)
 {
     if (_keyCode != KeyCode.None && layer.GetKey(_keyCode) ||
         !string.IsNullOrEmpty(_keyName) && layer.GetButton(_keyName))
     {
         if (MetaActive(Meta, layer))
         {
             return(true);
         }
     }
     return(false);
 }
示例#5
0
 public static bool MatchMetaState(MetaKey meta, InputLayer layer, MetaKey testFlag, KeyCode key)
 {
     return(MatchMetaState(meta, layer, testFlag, key, key));
 }