Example #1
0
        /// <summary>
        /// Non-blocking. Gets the oldest key mapping pressed or null.
        /// </summary>
        /// <param name="c">The dequeued key mapping or null.</param>
        /// <returns>True if a key mapping was dequeued. Otherwise false.</returns>
        public bool GetMapping(out KeyMapping c)
        {
            //Same idea as GetChar - see that for docs.

            if (scancodeBuffer.Count > 0)
            {
                GetKeyMapping(Dequeue(), out c);
                return true;
            }
            else
            {
                c = null;

                return false;
            }
        }
Example #2
0
        /// <summary>
        /// Gets the first KeyboardMapping which represents the specified scancode.
        /// </summary>
        /// <param name="aScanCode">The scancode to get the character for.</param>
        /// <param name="aValue">
        /// Output. The KeyboardMapping which represents the scancode or null if none found.
        /// </param>
        /// <returns>True if a KeyboardMapping to represent the scancode was found. Otherwise false.</returns>
        public bool GetKeyMapping(uint aScanCode, out KeyMapping aValue)
        {
            //Loops through all the key mappings to find the one which matches
            //  the specified scancode. Output value goes in aValue, return true
            //  indicates key mapping was found. Return false indicates key 
            //  mapping was not found.

            for (int i = 0; i < KeyMappings.Count; i++)
            {
                if (((KeyMapping)KeyMappings[i]).Scancode == aScanCode)
                {
                    aValue = ((KeyMapping)KeyMappings[i]);
                    return true;
                }
            }

            aValue = null;
            return false;
        }