Пример #1
0
        /// <summary> Gets prior pressed key, ignoring some specified keys. </summary>
        public VKeyResult topPressedIgnoring(params VKey[] keys)
        {
            var top = this.topDownIgnoring(keys);

            if (top.isNone)
            {
                return(top);
            }
            if (base.isPressed(top.asKey))
            {
                return(top);
            }
            else
            {
                return(VKeyResult.none());
            }
        }
Пример #2
0
        public VKeyResult consumeTopPressedIgnoring(params VKey[] keys)
        {
            var result = topDownIgnoring(keys);

            if (result.isNone)
            {
                return(result);
            }
            var  key       = result.asKey;
            bool isPressed = base.isPressed(key);

            base.consume(key);
            if (isPressed)
            {
                return(result);
            }
            else
            {
                return(VKeyResult.none());
            }
        }
Пример #3
0
        /// <summary>
        /// Gets prior down key, ignoring some specified keys.
        ///
        /// O(N) operation where N = the number of variants in Keys.
        /// (Never refactor to use caches, for the HACK to avoid clearing cache:
        /// c.f. BufNodeTemplate.clearBuf)
        /// </summary>
        public VKeyResult topDownIgnoring(params VKey[] keys)
        {
            VKey top = EnumUtil.allOf <VKey>()
                       .Where(k => !keys.Contains(k) && buttons[k].isDown)
                       .minByOrDefault(k => buttons[k].buf);

            var keyBuf = this.keyBuf(top);
            var dirBuf = this.vDir.buf;

            if (dirBuf == 0 || keys.Contains(VKey.AxisKey))
            {
                // not a dir key
                if (keyBuf == 0)
                {
                    return(VKeyResult.none());
                }
                else
                {
                    return(VKeyResult.newKey(top));
                }
            }

            // Now, dirBuf != 0
            if (keyBuf == 0)
            {
                return(VKeyResult.newDir(this.dirDown));
            }
            if (keyBuf < dirBuf)
            {
                return(VKeyResult.newKey(top));
            }
            else
            {
                return(VKeyResult.newDir(this.dirDown));
            }
        }